diff options
author | Pan Li <pan2.li@intel.com> | 2024-09-02 09:48:46 +0800 |
---|---|---|
committer | Pan Li <pan2.li@intel.com> | 2024-09-06 10:26:01 +0800 |
commit | 019335b404c8d7fb2d234bb179745cc28693dd20 (patch) | |
tree | 745645560d04a81703bb209b23f497cfa5282fa1 /gcc/cp/parser.cc | |
parent | ead5f587dad3206e45db7ac31f5c34c1530ae529 (diff) | |
download | gcc-019335b404c8d7fb2d234bb179745cc28693dd20.zip gcc-019335b404c8d7fb2d234bb179745cc28693dd20.tar.gz gcc-019335b404c8d7fb2d234bb179745cc28693dd20.tar.bz2 |
Match: Add int type fits check for form 1 of .SAT_SUB imm operand
This patch would like to add strict check for imm operand of .SAT_SUB
matching. We have no type checking for imm operand in previous, which
may result in unexpected IL to be catched by .SAT_SUB pattern.
We leverage the int_fits_type_p here to make sure the imm operand is
a int type fits the result type of the .SAT_SUB. For example:
Fits uint8_t:
uint8_t a;
uint8_t sum = .SAT_SUB (12, a);
uint8_t sum = .SAT_SUB (12u, a);
uint8_t sum = .SAT_SUB (126u, a);
uint8_t sum = .SAT_SUB (128u, a);
uint8_t sum = .SAT_SUB (228, a);
uint8_t sum = .SAT_SUB (223u, a);
Not fits uint8_t:
uint8_t a;
uint8_t sum = .SAT_SUB (-1, a);
uint8_t sum = .SAT_SUB (256u, a);
uint8_t sum = .SAT_SUB (257, a);
The below test suite are passed for this patch:
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.
gcc/ChangeLog:
* match.pd: Add int_fits_type_p check for .SAT_SUB imm operand.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat_u_add_imm_type_check-53.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-54.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-55.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-56.c: New test.
Signed-off-by: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'gcc/cp/parser.cc')
0 files changed, 0 insertions, 0 deletions