diff options
author | Kugan Vivekanandarajah <kuganv@linaro.org> | 2018-07-18 22:11:24 +0000 |
---|---|---|
committer | Kugan Vivekanandarajah <kugan@gcc.gnu.org> | 2018-07-18 22:11:24 +0000 |
commit | 7f15cc4dd931f708b0340dceaa62df159c943755 (patch) | |
tree | 39a34260c1a873c0a2b66b49fe543988e78c6615 /gcc/tree-ssa-phiopt.c | |
parent | d46d010b770bfdfbc166a555e96f38bc8bf9d2a4 (diff) | |
download | gcc-7f15cc4dd931f708b0340dceaa62df159c943755.zip gcc-7f15cc4dd931f708b0340dceaa62df159c943755.tar.gz gcc-7f15cc4dd931f708b0340dceaa62df159c943755.tar.bz2 |
re PR tree-optimization/86544 (Popcount detection generates different code on C and C++)
gcc/ChangeLog:
2018-07-18 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/86544
* tree-ssa-phiopt.c (cond_removal_in_popcount_pattern): Handle comparision with EQ_EXPR
in last stmt.
gcc/testsuite/ChangeLog:
2018-07-18 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/86544
* g++.dg/tree-ssa/pr86544.C: New test.
From-SVN: r262864
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 656f840..1667bad 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -1614,8 +1614,22 @@ cond_removal_in_popcount_pattern (basic_block cond_bb, basic_block middle_bb, arg = gimple_assign_rhs1 (cast); } + cond = last_stmt (cond_bb); + + /* Cond_bb has a check for b_4 [!=|==] 0 before calling the popcount + builtin. */ + if (gimple_code (cond) != GIMPLE_COND + || (gimple_cond_code (cond) != NE_EXPR + && gimple_cond_code (cond) != EQ_EXPR) + || !integer_zerop (gimple_cond_rhs (cond)) + || arg != gimple_cond_lhs (cond)) + return false; + /* Canonicalize. */ - if (e2->flags & EDGE_TRUE_VALUE) + if ((e2->flags & EDGE_TRUE_VALUE + && gimple_cond_code (cond) == NE_EXPR) + || (e1->flags & EDGE_TRUE_VALUE + && gimple_cond_code (cond) == EQ_EXPR)) { std::swap (arg0, arg1); std::swap (e1, e2); @@ -1625,16 +1639,6 @@ cond_removal_in_popcount_pattern (basic_block cond_bb, basic_block middle_bb, if (lhs != arg0 || !integer_zerop (arg1)) return false; - cond = last_stmt (cond_bb); - - /* Cond_bb has a check for b_4 != 0 before calling the popcount - builtin. */ - if (gimple_code (cond) != GIMPLE_COND - || gimple_cond_code (cond) != NE_EXPR - || !integer_zerop (gimple_cond_rhs (cond)) - || arg != gimple_cond_lhs (cond)) - return false; - /* And insert the popcount builtin and cast stmt before the cond_bb. */ gsi = gsi_last_bb (cond_bb); if (cast) |