aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2021-08-06 14:21:27 +0200
committerUros Bizjak <ubizjak@gmail.com>2021-08-06 14:22:15 +0200
commitcd04e829c3ae244abd711e2597f8b72d6c58c713 (patch)
treee4be2fd321c7829640f8377eccb8c8a6e7fccc17 /gcc
parent9d8eacc2ae8b9ad6490fc14cbb5127a103847b21 (diff)
downloadgcc-cd04e829c3ae244abd711e2597f8b72d6c58c713.zip
gcc-cd04e829c3ae244abd711e2597f8b72d6c58c713.tar.gz
gcc-cd04e829c3ae244abd711e2597f8b72d6c58c713.tar.bz2
i386: Fix conditional move reg-to-reg move elimination peepholes [PR101797]
Add missing operand predicate, otherwise any RTX will match. 2021-08-06 Uroš Bizjak <ubizjak@gmail.com> gcc/ PR target/101797 * config/i386/i386.md (cmove reg-to-reg move elimination peephole2s): Add general_gr_operand predicate to operand 3. gcc/testsuite/ PR target/101797 * gcc.target/i386/pr101797.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/i386/i386.md4
-rw-r--r--gcc/testsuite/gcc.target/i386/pr101797.c15
2 files changed, 17 insertions, 2 deletions
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 51e8b47..bc1c30b 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -19428,7 +19428,7 @@
(parallel [(set (reg FLAGS_REG) (match_operand 5))
(set (match_dup 0) (match_operand:SWI248 6))])
(set (match_operand:SWI248 2 "general_reg_operand")
- (match_operand:SWI248 3))
+ (match_operand:SWI248 3 "general_gr_operand"))
(set (match_dup 0)
(if_then_else:SWI248 (match_operator 4 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
@@ -19456,7 +19456,7 @@
;; mov r2,r3; mov r0,r1; dec r0; cmov r0,r2 -> dec r1; mov r0,r3; cmov r0, r1
(define_peephole2
[(set (match_operand:SWI248 2 "general_reg_operand")
- (match_operand:SWI248 3))
+ (match_operand:SWI248 3 "general_gr_operand"))
(set (match_operand:SWI248 0 "general_reg_operand")
(match_operand:SWI248 1 "general_reg_operand"))
(parallel [(set (reg FLAGS_REG) (match_operand 5))
diff --git a/gcc/testsuite/gcc.target/i386/pr101797.c b/gcc/testsuite/gcc.target/i386/pr101797.c
new file mode 100644
index 0000000..d5cc34e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr101797.c
@@ -0,0 +1,15 @@
+/* PR target/101797 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a;
+int main() {
+ int b, c, d, e = 0;
+ if (a) {
+ c += a;
+ e = ~(a % c);
+ e || c || (b & d);
+ }
+ a = e;
+ return 0;
+}