aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2021-05-16 10:40:16 -0700
committerAndrew Pinski <apinski@marvell.com>2021-05-23 08:08:14 +0000
commit99b76adb94d9363d0ca31a7d34ce850e2ca9ffc5 (patch)
treecbfa31dec87d011b45c6a5204bc44b3dc707ae73 /gcc/match.pd
parent15d30d2f20794d29ceabcfd57d230d6387284115 (diff)
downloadgcc-99b76adb94d9363d0ca31a7d34ce850e2ca9ffc5.zip
gcc-99b76adb94d9363d0ca31a7d34ce850e2ca9ffc5.tar.gz
gcc-99b76adb94d9363d0ca31a7d34ce850e2ca9ffc5.tar.bz2
Don't simplify (A & C) != 0 ? D : 0 for pointer types.
While rewriting part of PHI-OPT to use match-and-simplify, I ran into a bug where this pattern in match.pd would hit and would produce invalid gimple; a shift of a pointer type. This just disables this simplification for pointer types similarly to what is already done in PHI-OPT for the generic A ? D : 0 case. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Andrew Pinski 2021-5-23 Andrew Pinski <apinski@marvell.com> gcc/ * match.pd ((A & C) != 0 ? D : 0): Limit to non pointer types. gcc/testsuite/ * gcc.dg/gimplefe-45.c: New test.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd2
1 files changed, 1 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)));