aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-05-19 13:35:07 +0200
committerRichard Biener <rguenther@suse.de>2021-05-19 15:41:19 +0200
commit8d51039cb7c807ed84ff7df5416a1e3ba07a5e63 (patch)
tree4db5ca7df36f333472033131dd2b72e26b40ded2 /gcc/fold-const.c
parent32bd0353db37af2cb023e575ed4ce8c944fd9dba (diff)
downloadgcc-8d51039cb7c807ed84ff7df5416a1e3ba07a5e63.zip
gcc-8d51039cb7c807ed84ff7df5416a1e3ba07a5e63.tar.gz
gcc-8d51039cb7c807ed84ff7df5416a1e3ba07a5e63.tar.bz2
middle-end/100672 - fix bogus right shift folding
This fixes the bogus use of TYPE_PRECISION on vector types from optimizing -((int)x >> 31) into (unsigned)x >> 31. 2021-05-19 Richard Biener <rguenther@suse.de> PR middle-end/100672 * fold-const.c (fold_negate_expr_1): Use element_precision. (negate_expr_p): Likewise. * gcc.dg/torture/pr100672.c: New testcase.
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 5a41524..3be9c15 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -512,7 +512,7 @@ negate_expr_p (tree t)
if (TREE_CODE (TREE_OPERAND (t, 1)) == INTEGER_CST)
{
tree op1 = TREE_OPERAND (t, 1);
- if (wi::to_wide (op1) == TYPE_PRECISION (type) - 1)
+ if (wi::to_wide (op1) == element_precision (type) - 1)
return true;
}
break;
@@ -705,7 +705,7 @@ fold_negate_expr_1 (location_t loc, tree t)
if (TREE_CODE (TREE_OPERAND (t, 1)) == INTEGER_CST)
{
tree op1 = TREE_OPERAND (t, 1);
- if (wi::to_wide (op1) == TYPE_PRECISION (type) - 1)
+ if (wi::to_wide (op1) == element_precision (type) - 1)
{
tree ntype = TYPE_UNSIGNED (type)
? signed_type_for (type)