[llvm] [LAA] Add initial support for non-power-of-2 store-load forwarding distance (PR #137873)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 8 05:54:41 PDT 2025
================
@@ -76,22 +92,38 @@ exit:
}
define void @test_may_clobber2(ptr %p) {
-; CHECK-LABEL: 'test_may_clobber2'
-; CHECK-NEXT: loop:
-; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
-; CHECK-NEXT: Backward loop carried data dependence that prevents store-to-load forwarding.
-; CHECK-NEXT: Dependences:
-; CHECK-NEXT: BackwardVectorizableButPreventsForwarding:
-; CHECK-NEXT: %v = load i64, ptr %a1, align 32 ->
-; CHECK-NEXT: store i64 %v, ptr %a2, align 32
-; CHECK-EMPTY:
-; CHECK-NEXT: Run-time memory checks:
-; CHECK-NEXT: Grouped accesses:
-; CHECK-EMPTY:
-; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
-; CHECK-NEXT: SCEV assumptions:
-; CHECK-EMPTY:
-; CHECK-NEXT: Expressions re-written:
+; RISCV64-LABEL: 'test_may_clobber2'
+; RISCV64-NEXT: loop:
+; RISCV64-NEXT: Memory dependences are safe with a maximum safe vector width of 576 bits, with a maximum safe store-load forward width of 192 bits
----------------
alexey-bataev wrote:
That's the case, where non-power-of-2 distance works, but power-of-2 does not. The distance here is 192 bits, which ends with vector factor 3. Vector factor 2 (for 128 bit) won't work here, because there will store-load forwarding conflict on iteration 4 (the distance between store and load is 9), so 128 bit for power-of-2 distance does not work, but 192 bit distance for non-power-of-2 works.
https://github.com/llvm/llvm-project/pull/137873
More information about the llvm-commits
mailing list