diff options
author | Sebastian Pop <sebpop@gmail.com> | 2007-06-24 20:59:02 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2007-06-24 20:59:02 +0000 |
commit | a49c5793d5df1c90f00aa0419b1f218bb4983fd9 (patch) | |
tree | b5ef95b7a52b4aaad86fe4118925cd68be322d23 /gcc/fold-const.c | |
parent | 4e16ca9a8206d0951baab2140533c8e59d8bf3d3 (diff) | |
download | gcc-a49c5793d5df1c90f00aa0419b1f218bb4983fd9.zip gcc-a49c5793d5df1c90f00aa0419b1f218bb4983fd9.tar.gz gcc-a49c5793d5df1c90f00aa0419b1f218bb4983fd9.tar.bz2 |
re PR tree-optimization/32461 (Segmentation fault in build_classic_dist_vector_1() at tree-data-ref.c:2700)
PR middle-end/32461
* fold-const.c (fold_binary): Strip nops of operand 0
of BIT_NOT_EXPR before calling operand_equal_p.
* testsuite/gcc.dg/tree-ssa/pr32461-1.c: New.
* testsuite/gcc.dg/tree-ssa/pr32461-2.c: New.
From-SVN: r125988
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index cd8d386..e2d57c9 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9260,21 +9260,31 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* ~X + X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR - && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) && !TYPE_OVERFLOW_TRAPS (type)) { - t1 = build_int_cst_type (type, -1); - return omit_one_operand (type, t1, arg1); + tree tem = TREE_OPERAND (arg0, 0); + + STRIP_NOPS (tem); + if (operand_equal_p (tem, arg1, 0)) + { + t1 = build_int_cst_type (type, -1); + return omit_one_operand (type, t1, arg1); + } } /* X + ~X is -1. */ if (TREE_CODE (arg1) == BIT_NOT_EXPR - && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0) && !TYPE_OVERFLOW_TRAPS (type)) { - t1 = build_int_cst_type (type, -1); - return omit_one_operand (type, t1, arg0); - } + tree tem = TREE_OPERAND (arg1, 0); + + STRIP_NOPS (tem); + if (operand_equal_p (arg0, tem, 0)) + { + t1 = build_int_cst_type (type, -1); + return omit_one_operand (type, t1, arg0); + } + } /* If we are adding two BIT_AND_EXPR's, both of which are and'ing with a constant, and the two constants have no bits in common, |