diff options
author | Richard Biener <rguenther@suse.de> | 2016-05-06 07:38:27 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-05-06 07:38:27 +0000 |
commit | a4f510181a4a6ac49317acdda7036f0370517cb9 (patch) | |
tree | 8a41ca6eb178466e811be3f7bc6506293faa1a24 /gcc/fold-const.c | |
parent | f5d6c2d81c656ec92b3f190b29260479d63e3ce5 (diff) | |
download | gcc-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.c | 17 |
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; |