When backporting the fix of updating PHI arguments with SET_PHI_ARG_DEF
in PR128095 test gcc.dg/vect/vect-reduc-cond-2.c started failing on the
branch.
It didn't fail on master because commit r17-1507-gc43fed44d9a changed
the tests and so hid the problem.
The code in factor_out_operators dealt with the broken SSA by having
this variable "repeated" which first time around checked for
has_single_use because SSA was up to date. Then when it did the
rewrite for subsequent passes checked has_zero_uses because the SSA
wasn't single use anymore.
But as far as I can tell, the optimization was always intended to
only work on single use PHIs and the "repeated" thing was just a
hack around the broken SSA.
This removes the hack and the test now passes.
Bootstrapped Regtested on aarch64-none-linux-gnu,
arm-none-linux-gnueabihf, x86_64-pc-linux-gnu
-m32, -m64 and no issues.
I think this is OK, but in case I misunderstood something here..
Any feedback? Otherwise I'll push to trunk and GCC 16.
Sashiko Review:
https://gcc.sashiko.dev/#/patchset/patch-21119-rb-rev-1-tamar%40arm.com
Apply Series: b4 shazam
https://inbox.sourceware.org/gcc-patches/[email protected]/
Thanks,
Tamar
gcc/ChangeLog:
PR tree-optimization/128095
* tree-if-conv.cc (factor_out_operators): Fix Checks.
base-commit: 78c5290e696d76fdbe7f3b006df9145d1ed7927c
---
--
diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc
index
05780b4a374802a2581def071a388240abed9df9..b08e1072b52147818950583371b9a2344d23c228
100644
--- a/gcc/tree-if-conv.cc
+++ b/gcc/tree-if-conv.cc
@@ -2213,7 +2213,6 @@ factor_out_operators (tree *res, gimple_stmt_iterator
*gsi,
tree *arg0, tree *arg1, gphi *phi)
{
gimple_match_op arg0_op, arg1_op;
- bool repeated = false;
again:
if (TREE_CODE (*arg0) != SSA_NAME || TREE_CODE (*arg1) != SSA_NAME)
@@ -2224,9 +2223,7 @@ again:
/* If either args have > 1 use, then this transformation actually
increases the number of expressions evaluated at runtime. */
- if (repeated
- ? (!has_zero_uses (*arg0) || !has_zero_uses (*arg1))
- : (!has_single_use (*arg0) || !has_single_use (*arg1)))
+ if (!has_single_use (*arg0) || !has_single_use (*arg1))
return;
gimple *arg0_def_stmt = SSA_NAME_DEF_STMT (*arg0);
@@ -2314,7 +2311,6 @@ again:
SET_PHI_ARG_DEF (phi, 1, new_arg1);
update_stmt (phi);
- repeated = true;
goto again;
}