re PR tree-optimization/52631 (VN does not use simplified expression for lookup)

PR tree-optimization/52631
        * tree-ssa-sccvn (visit_use): Before looking up the original
        statement, try looking up the simplified expression.

        PR tree-optimization/52631
        * tree-ssa/pr52631.c: New test.
        * tree-ssa/ssa-fre-9: Update expected output.

From-SVN: r195318
This commit is contained in:
Jeff Law 2013-01-19 22:00:56 -07:00
parent 424bac9482
commit 5630e3e157
5 changed files with 49 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2013-01-19 Andrew Pinski <apinski@cavium.com>
PR tree-optimization/52631
* tree-ssa-sccvn (visit_use): Before looking up the original
statement, try looking up the simplified expression.
2013-01-19 Anthony Green <green@moxielogic.com>
* config/moxie/moxie.c (moxie_expand_prologue): Set

View File

@ -1,3 +1,9 @@
2013-01-19 Jeff Law <law@redhat.com>
PR tree-optimization/52631
* tree-ssa/pr52631.c: New test.
* tree-ssa/ssa-fre-9: Update expected output.
2013-01-19 Anthony Green <green@moxielogic.com>
* gcc.dg/tree-ssa/asm-2.c (REGISTER): Pick an appropriate register

View File

@ -0,0 +1,14 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-fre1-details" } */
unsigned f(unsigned a)
{
unsigned b = a >> 31;
return b&1;
}
/* We want to verify that we replace the b & 1 with b. */
/* { dg-final { scan-tree-dump-times "Replaced b_\[0-9\]+ & 1 with b_\[0-9\]+ in" 1 "fre1"} } */
/* { dg-final { cleanup-tree-dump "fre1" } } */

View File

@ -23,6 +23,6 @@ void __frame_state_for1 (volatile char *state_in)
}
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 2 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Eliminated: 2" 2 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Insertions: 1" 2 "fre1" } } */
/* { dg-final { cleanup-tree-dump "fre1" } } */

View File

@ -3422,6 +3422,28 @@ visit_use (tree use)
}
else
{
/* First try to lookup the simplified expression. */
if (simplified)
{
enum gimple_rhs_class rhs_class;
rhs_class = get_gimple_rhs_class (TREE_CODE (simplified));
if ((rhs_class == GIMPLE_UNARY_RHS
|| rhs_class == GIMPLE_BINARY_RHS
|| rhs_class == GIMPLE_TERNARY_RHS)
&& valid_gimple_rhs_p (simplified))
{
tree result = vn_nary_op_lookup (simplified, NULL);
if (result)
{
changed = set_ssa_val_to (lhs, result);
goto done;
}
}
}
/* Otherwise visit the original statement. */
switch (vn_get_stmt_kind (stmt))
{
case VN_NARY: