[PATCH] D156055: [NewGVN][PHIOFOPS] Relax conditions when checking safety of memory accesses

Konstantina Mitropoulou via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 01:23:44 PDT 2023


kmitropoulou added a comment.

LGTM :)



================
Comment at: llvm/lib/Transforms/Scalar/NewGVN.cpp:2649
+        // Clobbering MemoryPhi - unsafe.
+        // Note : Only checking memory phis allows us to skip constant stores
+        if (isa<MemoryPhi>(MemAccess) &&
----------------
Can you please give us more details?

In the following example, the load depends on a memory phi.  But, the check in line 2651 rejects phi-of-ops optimization. This can be optimized If we do some changes in findPHIOfOpsLeader().

define i32 @mytest(ptr %p, ptr %q, i1 %cond1, i32 %TC){
entry:
  br label %loop.header

loop.header:
  %phi = phi i32 [0, %entry], [%ind, %loop.latch]
  br i1 %cond1, label %bb1, label %bb2

bb1:
  store i32 100, ptr %p
  br label %loop.latch

bb2:
  store i32 10, ptr %p
  br label %loop.latch

loop.latch:
   %phi2 = phi i32 [1, %bb1], [0, %bb2]
   %ld = load i32, ptr %p
   %mul = mul i32 %ld, %phi2
   %ind = add i32 %phi, 1
   %cond2 = icmp ule i32 %ind, %TC
   br i1 %cond2, label %loop.header, label %exit

exit:
  ret i32 %mul
}




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156055/new/

https://reviews.llvm.org/D156055



More information about the llvm-commits mailing list