diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-20 21:09:11 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-20 21:09:11 +0000 |
commit | 6189c51747cfc6264794f369268019538512f1ba (patch) | |
tree | befe401eb3201bc82589618ec4f366a7daa6ced7 /gcc/fold-const.c | |
parent | af0f9c72ce981e237c6f07e51862c508823c52e5 (diff) | |
download | gcc-6189c51747cfc6264794f369268019538512f1ba.tar.gz |
PR middle-end/40204
* fold-const.c (fold_binary) <case BIT_AND_EXPR>: Avoid infinite
recursion if build_int_cst_type returns the same INTEGER_CST as
arg1.
* gcc.c-torture/compile/pr40204.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147749 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 0ac9e296c66..e322ecb2cf8 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11382,6 +11382,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (prec < HOST_BITS_PER_WIDE_INT || newmask == ~(unsigned HOST_WIDE_INT) 0) { + tree newmaskt; + if (shift_type != TREE_TYPE (arg0)) { tem = fold_build2 (TREE_CODE (arg0), shift_type, @@ -11392,9 +11394,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) } else tem = op0; - return fold_build2 (BIT_AND_EXPR, type, tem, - build_int_cst_type (TREE_TYPE (op1), - newmask)); + newmaskt = build_int_cst_type (TREE_TYPE (op1), newmask); + if (!tree_int_cst_equal (newmaskt, arg1)) + return fold_build2 (BIT_AND_EXPR, type, tem, newmaskt); } } } |