diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-04 11:44:58 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-04 11:44:58 +0000 |
commit | d9022390cd43f3fd58df12acc041460e34aef614 (patch) | |
tree | c56451a80746f69f5417de37ab545e4e904fa2a8 /gcc/tree-ssa-ifcombine.c | |
parent | 6f50e0d867b33da77b9c99f7fa469ef66c49a0db (diff) | |
download | gcc-d9022390cd43f3fd58df12acc041460e34aef614.tar.gz |
2007-07-04 Richard Guenther <rguenther@suse.de>
PR tree-optimization/32482
* tree-ssa-ifcombine.c (recognize_single_bit_test): Use the
original ssa name if we didn't find a shift expression.
Fix shift constant for bit zero test.
* gcc.c-torture/compile/pr32482.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126314 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-ifcombine.c')
-rw-r--r-- | gcc/tree-ssa-ifcombine.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c index 89fd61d2405..94038573165 100644 --- a/gcc/tree-ssa-ifcombine.c +++ b/gcc/tree-ssa-ifcombine.c @@ -167,17 +167,22 @@ recognize_single_bit_test (tree cond_expr, tree *name, tree *bit) && integer_onep (TREE_OPERAND (t, 1)) && TREE_CODE (TREE_OPERAND (t, 0)) == SSA_NAME) { - t = TREE_OPERAND (t, 0); + tree orig_name = TREE_OPERAND (t, 0); + + /* Look through copies and conversions to eventually + find the stmt that computes the shift. */ + t = orig_name; do { t = SSA_NAME_DEF_STMT (t); if (TREE_CODE (t) != GIMPLE_MODIFY_STMT) - return false; + break; t = GIMPLE_STMT_OPERAND (t, 1); if (TREE_CODE (t) == NOP_EXPR || TREE_CODE (t) == CONVERT_EXPR) t = TREE_OPERAND (t, 0); } while (TREE_CODE (t) == SSA_NAME); + /* If we found such, decompose it. */ if (TREE_CODE (t) == RSHIFT_EXPR) { /* op0 & (1 << op1) */ @@ -187,8 +192,8 @@ recognize_single_bit_test (tree cond_expr, tree *name, tree *bit) else { /* t & 1 */ - *bit = integer_one_node; - *name = t; + *bit = integer_zero_node; + *name = orig_name; } return true; |