diff options
author | Hu, Lin1 <lin1.hu@intel.com> | 2025-04-08 15:43:59 +0800 |
---|---|---|
committer | Hu, Lin1 <lin1.hu@intel.com> | 2025-07-11 16:50:29 +0800 |
commit | 5ca44dfb1389f4c6198283683547143e217f65ab (patch) | |
tree | a72e0604fa477738b6668794d024674f46969176 /gcc | |
parent | 363b29a9cfbb470d6987fb395035c56bae30c64b (diff) | |
download | gcc-5ca44dfb1389f4c6198283683547143e217f65ab.zip gcc-5ca44dfb1389f4c6198283683547143e217f65ab.tar.gz gcc-5ca44dfb1389f4c6198283683547143e217f65ab.tar.bz2 |
i386: Add a new peeophole2 for PR91384 under APX_F
gcc/ChangeLog:
PR target/91384
* config/i386/i386.md: Add new peeophole2 for optimize *negsi_1
followed by *cmpsi_ccno_1 with APX_F.
gcc/testsuite/ChangeLog:
PR target/91384
* gcc.target/i386/pr91384-1.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/i386/i386.md | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr91384-1.c | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 5825aca..83c438b 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -14769,6 +14769,17 @@ (compare:CCZ (neg:SWI (match_dup 0)) (const_int 0))) (set (match_dup 0) (neg:SWI (match_dup 0)))])]) +;; Optimize *negsi_1 followed by *cmpsi_ccno_1 (PR target/91384) with APX_F +(define_peephole2 + [(parallel [(set (match_operand:SWI 0 "general_reg_operand") + (neg:SWI (match_operand:SWI 1 "general_reg_operand"))) + (clobber (reg:CC FLAGS_REG))]) + (set (reg:CCZ FLAGS_REG) (compare:CCZ (match_dup 1) (const_int 0)))] + "TARGET_APX_NDD" + [(parallel [(set (reg:CCZ FLAGS_REG) + (compare:CCZ (neg:SWI (match_dup 1)) (const_int 0))) + (set (match_dup 0) (neg:SWI (match_dup 1)))])]) + ;; Special expand pattern to handle integer mode abs (define_expand "abs<mode>2" diff --git a/gcc/testsuite/gcc.target/i386/pr91384-1.c b/gcc/testsuite/gcc.target/i386/pr91384-1.c new file mode 100644 index 0000000..4f8823d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr91384-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mapxf" } */ + +void foo (void); +void bar (void); + +int +test (int a) +{ + int r; + + if (r = -a) + foo (); + else + bar (); + + return r; +} + +/* { dg-final { scan-assembler-not "testl" } } */ |