The following fixes the index guards on the component stripping
loops, I swapped them it seems.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        PR tree-optimization/121362
        * tree-ssa-sccvn.cc (vn_reference_lookup_3): Swap index
        guards on component stripping loops.
---
 gcc/tree-ssa-sccvn.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 5c617e17a15..dd6ed2fa73f 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -3573,7 +3573,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void 
*data_,
             try finding a match in one of the outer components and continue
             stripping there.  This happens when addresses of components get
             forwarded into dereferences.  */
-         if (j > 0)
+         if (i > 0)
            {
              int temi = i - 1;
              extra_off = vr->operands[i].off;
@@ -3598,7 +3598,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void 
*data_,
                  temi--;
                }
            }
-         if (!found && i > 0)
+         if (!found && j > 0)
            {
              int temj = j - 1;
              extra_off = -lhs_ops[j].off;
-- 
2.43.0

Reply via email to