[PATCH] D147539: [LV] Enable stride versioning to support Fortran IR

Peixin Qiao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 09:05:01 PDT 2023


peixin added a comment.

In D147539#4245938 <https://reviews.llvm.org/D147539#4245938>, @reames wrote:

> JFYI, I find the description on this patch confusing.  I think I've managed to understand it, but let me confirm.
>
> Given an induction variable with a loop invariant (but not constant) stride, LAA currently speculates the stride is 1.  In the case where the access type and the index type differ, this results in a meaningless speculation.  Instead of unconditionally speculating 1, we can speculate that the stride is the constant required to stride sizeof(element-type) on each iteration.
>
> Is that a correct understanding?

Yes, that's what this patch does. Sorry to bother you. Should I change the description like you said?

> Also, why does this depend on the prior patch?  This seems like an independent change.

The IR filecheck depends on the prior patch since I develop this patch after that locally. I removed the dependence now.



================
Comment at: llvm/test/Transforms/LoopVectorize/stride-accesses-unit-check-fix.ll:34
+
+; CHECK-LABEL: define void @test_
+; CHECK: vector.scevcheck:
----------------
reames wrote:
> Please use update_test_checks.py
Thanks. Fixed.


================
Comment at: llvm/test/Transforms/LoopVectorize/stride-accesses-unit-check-fix.ll:56
+
+.lr.ph:                                           ; preds = %4
+  %7 = zext i32 %5 to i64
----------------
reames wrote:
> Please reduce this test further.
I renamed the IR variable names and try my best to reduce it. It can still be reduced to reproduce the problem, but it will have different meanings as the source code.


================
Comment at: llvm/test/Transforms/LoopVectorize/stride-accesses-unit-check-fix.ll:96
+
+!1 = !{!2, !2, i64 0}
+!2 = !{!"any data access", !3, i64 0}
----------------
reames wrote:
> Please remove stray metadata.
Thanks. Fixed.


================
Comment at: llvm/test/Transforms/LoopVectorize/stride-accesses-unit-check-fix.ll:102
+!6 = !{!"descriptor member", !3, i64 0}
+
----------------
reames wrote:
> You definitely need more than one test here.  A few cornercases to consider:
> * element type == index type
> * element type < index type
> * gep with multiple uses
> element type == index type

Added it.

> element type < index type

It does not exist in Fortran IR. So in function code, I still use 1 for this case.

> gep with multiple uses

Do you mean the following:
```
  %0 = getelementptr i8, ptr %base, i64 %offset
  %1 = load float, ptr %0
  %2 = load i32, ptr %0
```
I cannot find one IR generated from real code including C/C++/Fortran.


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

https://reviews.llvm.org/D147539



More information about the llvm-commits mailing list