diff options
author | Richard Guenther <rguenther@suse.de> | 2007-11-16 21:34:39 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2007-11-16 21:34:39 +0000 |
commit | 5abe96858868a873bddbb41b4e32599daa6f385c (patch) | |
tree | a2048e1254f70d5a8f267c703cc73c6bd6733224 /gcc/fold-const.c | |
parent | f6dfe2fc46ac63fafbfdd9c5a505e72e8fe2b861 (diff) | |
download | gcc-5abe96858868a873bddbb41b4e32599daa6f385c.zip gcc-5abe96858868a873bddbb41b4e32599daa6f385c.tar.gz gcc-5abe96858868a873bddbb41b4e32599daa6f385c.tar.bz2 |
re PR middle-end/34030 (ICE in in compare_values_warnv, at tree-vrp.c:701)
2007-11-16 Richard Guenther <rguenther@suse.de>
PR middle-end/34030
* fold-const.c (fold_binary): Use correct types for folding
1 << X & Y to Y >> X & 1.
* gcc.c-torture/compile/pr34030.c: New testcase.
From-SVN: r130238
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 0d6524e..1057d26 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11858,24 +11858,24 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree arg01 = TREE_OPERAND (arg0, 1); if (TREE_CODE (arg00) == LSHIFT_EXPR && integer_onep (TREE_OPERAND (arg00, 0))) - return - fold_build2 (code, type, - build2 (BIT_AND_EXPR, TREE_TYPE (arg0), - build2 (RSHIFT_EXPR, TREE_TYPE (arg00), - arg01, TREE_OPERAND (arg00, 1)), - fold_convert (TREE_TYPE (arg0), - integer_one_node)), - arg1); - else if (TREE_CODE (TREE_OPERAND (arg0, 1)) == LSHIFT_EXPR - && integer_onep (TREE_OPERAND (TREE_OPERAND (arg0, 1), 0))) - return - fold_build2 (code, type, - build2 (BIT_AND_EXPR, TREE_TYPE (arg0), - build2 (RSHIFT_EXPR, TREE_TYPE (arg01), - arg00, TREE_OPERAND (arg01, 1)), - fold_convert (TREE_TYPE (arg0), - integer_one_node)), - arg1); + { + tree tem = fold_build2 (RSHIFT_EXPR, TREE_TYPE (arg00), + arg01, TREE_OPERAND (arg00, 1)); + tem = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), tem, + build_int_cst (TREE_TYPE (arg0), 1)); + return fold_build2 (code, type, + fold_convert (TREE_TYPE (arg1), tem), arg1); + } + else if (TREE_CODE (arg01) == LSHIFT_EXPR + && integer_onep (TREE_OPERAND (arg01, 0))) + { + tree tem = fold_build2 (RSHIFT_EXPR, TREE_TYPE (arg01), + arg00, TREE_OPERAND (arg01, 1)); + tem = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), tem, + build_int_cst (TREE_TYPE (arg0), 1)); + return fold_build2 (code, type, + fold_convert (TREE_TYPE (arg1), tem), arg1); + } } /* If this is an NE or EQ comparison of zero against the result of a |