aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/match.pd2
-rw-r--r--gcc/testsuite/gcc.dg/gimplefe-45.c19
2 files changed, 20 insertions, 1 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index e01bb7a..1fc6b7b 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -4840,7 +4840,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(cond
(ne (bit_and @0 integer_pow2p@1) integer_zerop)
INTEGER_CST@2 integer_zerop)
- (if (integer_pow2p (@2))
+ (if (!POINTER_TYPE_P (type) && integer_pow2p (@2))
(with {
int shift = (wi::exact_log2 (wi::to_wide (@2))
- wi::exact_log2 (wi::to_wide (@1)));
diff --git a/gcc/testsuite/gcc.dg/gimplefe-45.c b/gcc/testsuite/gcc.dg/gimplefe-45.c
new file mode 100644
index 0000000..b1d3cbb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-45.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fgimple" } */
+
+/* This used to ICE when simplifying (A & C) != 0 ? D : 0
+ for pointer types. */
+
+int *__GIMPLE ()
+p (int n)
+{
+ int *_2;
+ int *_t;
+ int *_t1;
+ _t = (int*)8;
+ _t1 = 0;
+ n = n & 2;
+ _2 = n != 0 ? _t : _t1;
+ return _2;
+}
+