diff options
author | Pan Li <pan2.li@intel.com> | 2024-09-02 11:33:08 +0800 |
---|---|---|
committer | Pan Li <pan2.li@intel.com> | 2024-09-06 10:26:06 +0800 |
commit | a2e28b105cea4c44c3903d8d979c7a4afa1193f0 (patch) | |
tree | b244f4bd70014eab744563952c60f66483282617 /gcc/cp/parser.cc | |
parent | 019335b404c8d7fb2d234bb179745cc28693dd20 (diff) | |
download | gcc-a2e28b105cea4c44c3903d8d979c7a4afa1193f0.zip gcc-a2e28b105cea4c44c3903d8d979c7a4afa1193f0.tar.gz gcc-a2e28b105cea4c44c3903d8d979c7a4afa1193f0.tar.bz2 |
Match: Add int type fits check for form 2 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 (a, 12);
uint8_t sum = .SAT_SUB (a, 12u);
uint8_t sum = .SAT_SUB (a, 126u);
uint8_t sum = .SAT_SUB (a, 128u);
uint8_t sum = .SAT_SUB (a, 228);
uint8_t sum = .SAT_SUB (a, 223u);
Not fits uint8_t:
uint8_t a;
uint8_t sum = .SAT_SUB (a, -1);
uint8_t sum = .SAT_SUB (a, 256u);
uint8_t sum = .SAT_SUB (a, 257);
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-57.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-58.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-59.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-60.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