| Issue |
203188
|
| Summary |
[LV] Incorrect uniform GEP generation for gather under CM_INTERLEAVE
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
arcbbb
|
While reviewing #190191 and #195445, I noticed a case in pointer-induction.ll where a uniform GEP is incorrectly generated for a gather operation, instead of the expected widened GEP.
IR Snippet:
```
%18 = getelementptr i8, ptr %next.gep, i64 4
%broadcast.splatinsert = insertelement <vscale x 2 x ptr> poison, ptr %18, i64 0
%broadcast.splat = shufflevector <vscale x 2 x ptr> %broadcast.splatinsert, <vscale x 2 x ptr> poison, <vscale x 2 x i32> zeroinitializer
%wide.masked.gather = call <vscale x 2 x i32> @llvm.masked.gather.nxv2i32.nxv2p0(<vscale x 2 x ptr> align 4 %broadcast.splat, <vscale x 2 x i1> splat (i1 true), <vscale x 2 x i32> poison)
```
Reproducer: https://godbolt.org/z/zG4s8nnWx
Note: -tail-folding-policy=dont-fold-tail is required to trigger interleavedAccessCanBeWidened.
```
target triple = "riscv64-unknown-linux-gnu"
define i1 @scalarize_ptr_induction(ptr %start, ptr %end, ptr noalias %dst, i1 %c) #1 {
entry:
br label %loop
loop:
%ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop ]
%gep = getelementptr i8, ptr %ptr.iv, i64 4
%l = load i32, ptr %gep, align 4
%ext = zext i32 %l to i64
%unused = load i32, ptr %ptr.iv, align 4
%mul1 = mul i64 %ext, -7070675565921424023
%mul2 = add i64 %mul1, -4
store i64 %mul2, ptr %dst, align 1
%ptr.iv.next = getelementptr nusw i8, ptr %ptr.iv, i64 12
%cmp = icmp eq ptr %ptr.iv.next, %end
br i1 %cmp, label %exit, label %loop
exit:
ret i1 %cmp
}
attributes #0 = { "target-features"="+v" }
attributes #1 = { "target-cpu"="sifive-p670" }
```
The GEP is marked as uniform because the widening decision is set to CM_INTERLEAVE. However, because an interleave recipe is never actually generated, marking the GEP as uniform is incorrect.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs