gcc/0203-Remove-erroneous-pattern-from-gimple-ifcvt.patch
2024-06-22 15:57:01 +08:00

55 lines
1.4 KiB
Diff

From 0dcab0809ada30b09f553dbbe5b2df8d830e95f3 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 13 Jun 2024 22:04:16 +0800
Subject: [PATCH] Remove erroneous pattern from gimple ifcvt
---
gcc/match.pd | 2 +-
gcc/testsuite/gcc.dg/ifcvt-gimple-1.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/ifcvt-gimple-1.c
diff --git a/gcc/match.pd b/gcc/match.pd
index 1097cd926..efd2db209 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3450,7 +3450,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
)
(if (flag_if_conversion_gimple)
- (for simple_op (plus minus bit_and bit_ior bit_xor)
+ (for simple_op (plus minus bit_ior bit_xor)
(simplify
(cond @0 (simple_op @1 INTEGER_CST@2) @1)
(switch
diff --git a/gcc/testsuite/gcc.dg/ifcvt-gimple-1.c b/gcc/testsuite/gcc.dg/ifcvt-gimple-1.c
new file mode 100644
index 000000000..381a4ad51
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ifcvt-gimple-1.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fif-conversion-gimple" } */
+
+#include <stdlib.h>
+
+void foo(int a, int *p) {
+ *p = a;
+}
+
+void verify (int a) {
+ if (a != 3)
+ abort ();
+}
+
+int main() {
+ int a = 0;
+ foo (3, &a);
+ int tmp = (a > 7) ? a & 1 : a;
+ verify (tmp);
+ return 0;
+}
--
2.33.0