aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-05-06 07:38:27 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-05-06 07:38:27 +0000
commita4f510181a4a6ac49317acdda7036f0370517cb9 (patch)
tree8a41ca6eb178466e811be3f7bc6506293faa1a24 /gcc/fold-const.c
parentf5d6c2d81c656ec92b3f190b29260479d63e3ce5 (diff)
downloadgcc-a4f510181a4a6ac49317acdda7036f0370517cb9.zip
gcc-a4f510181a4a6ac49317acdda7036f0370517cb9.tar.gz
gcc-a4f510181a4a6ac49317acdda7036f0370517cb9.tar.bz2
re PR target/70941 (Test miscompiled with -O2.)
2016-05-06 Richard Biener <rguenther@suse.de> PR middle-end/70941 * fold-const.c (split_tree): Always convert to the original type before negating. * gcc.dg/torture/pr70941.c: New testcase. From-SVN: r235943
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9ef43bf..8aabe21 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -836,11 +836,10 @@ split_tree (location_t loc, tree in, tree type, enum tree_code code,
*minus_litp = *litp, *litp = 0;
if (neg_conp_p)
*conp = negate_expr (*conp);
- if (neg_var_p)
+ if (neg_var_p && var)
{
- /* Convert to TYPE before negating a pointer type expr. */
- if (var && POINTER_TYPE_P (TREE_TYPE (var)))
- var = fold_convert_loc (loc, type, var);
+ /* Convert to TYPE before negating. */
+ var = fold_convert_loc (loc, type, var);
var = negate_expr (var);
}
}
@@ -863,10 +862,12 @@ split_tree (location_t loc, tree in, tree type, enum tree_code code,
else if (*minus_litp)
*litp = *minus_litp, *minus_litp = 0;
*conp = negate_expr (*conp);
- /* Convert to TYPE before negating a pointer type expr. */
- if (var && POINTER_TYPE_P (TREE_TYPE (var)))
- var = fold_convert_loc (loc, type, var);
- var = negate_expr (var);
+ if (var)
+ {
+ /* Convert to TYPE before negating. */
+ var = fold_convert_loc (loc, type, var);
+ var = negate_expr (var);
+ }
}
return var;