diff options
author | Richard Biener <rguenther@suse.de> | 2016-09-15 12:35:13 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-09-15 12:35:13 +0000 |
commit | 7c05f5c46d5b0db80d65bec5f14a893d0e939c85 (patch) | |
tree | fee08b4a7ab85ef71f6d59ed2f9505aea883f3a2 /gcc/fold-const.c | |
parent | 63c879fca4a3d82c0b8a5c5f42926419259f01ec (diff) | |
download | gcc-7c05f5c46d5b0db80d65bec5f14a893d0e939c85.zip gcc-7c05f5c46d5b0db80d65bec5f14a893d0e939c85.tar.gz gcc-7c05f5c46d5b0db80d65bec5f14a893d0e939c85.tar.bz2 |
re PR tree-optimization/77544 (segfault at -O0 - infinite loop in simplification)
2016-09-15 Richard Biener <rguenther@suse.de>
PR middle-end/77544
* fold-const.c (split_tree): Do not split constant ~X.
* c-c++-common/torture/pr77544.c: New testcase.
From-SVN: r240164
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index bf177b6..e5c2052 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -837,15 +837,16 @@ split_tree (location_t loc, tree in, tree type, enum tree_code code, var = negate_expr (var); } } + else if (TREE_CONSTANT (in)) + *conp = in; else if (TREE_CODE (in) == BIT_NOT_EXPR && code == PLUS_EXPR) { - /* -X - 1 is folded to ~X, undo that here. */ + /* -X - 1 is folded to ~X, undo that here. Do _not_ do this + when IN is constant. */ *minus_litp = build_one_cst (TREE_TYPE (in)); var = negate_expr (TREE_OPERAND (in, 0)); } - else if (TREE_CONSTANT (in)) - *conp = in; else var = in; |