aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorRoger Sayle <roger@nextmovesoftware.com>2021-08-24 02:59:02 +0100
committerRoger Sayle <roger@nextmovesoftware.com>2021-08-24 02:59:02 +0100
commit78fa5112b4c2dcd94b78ee79baddebbf14d6ad98 (patch)
tree365cb89be7786601b7ba46c76eb7b21b74a9cb90 /gcc/match.pd
parent819b7c3a339e3bdaf85cd55954c5536bd98aae09 (diff)
downloadgcc-78fa5112b4c2dcd94b78ee79baddebbf14d6ad98.zip
gcc-78fa5112b4c2dcd94b78ee79baddebbf14d6ad98.tar.gz
gcc-78fa5112b4c2dcd94b78ee79baddebbf14d6ad98.tar.bz2
[Committed] PR middle-end/102029: Stricter typing in LSHIFT_EXPR sign folding.
My sincere apologies to everyone (again). As diagnosed by Jakub Jelinek, my recent patch to fold the signedness of LSHIFT_EXPR needs to be careful not to attempt transforming a left shift in an integer type into an invalid left shift of a pointer type. 2021-08-24 Roger Sayle <roger@nextmovesoftware.com> Jakub Jelinek <jakub@redhat.com> gcc/ChangeLog PR middle-end/102029 * match.pd (shift transformations): Add an additional check for !POINTER_TYPE_P in the recently added left shift transformation. gcc/testsuite/ChangeLog PR middle-end/102029 * gcc.dg/fold-convlshift-3.c: New test case.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 978a1b0..e5bbb12 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3389,7 +3389,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
the form that minimizes the number of conversions. */
(simplify
(convert (lshift:s@0 (convert:s@1 @2) INTEGER_CST@3))
- (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
+ (if (INTEGRAL_TYPE_P (type)
+ && !POINTER_TYPE_P (type)
+ && tree_nop_conversion_p (type, TREE_TYPE (@0))
&& INTEGRAL_TYPE_P (TREE_TYPE (@2))
&& TYPE_PRECISION (TREE_TYPE (@2)) <= TYPE_PRECISION (type))
(lshift (convert @2) @3)))