[llvm] [LV] Rework collectUnitStridePredicates (PR #216362)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 16 23:50:37 PDT 2026
================
@@ -3464,11 +3464,11 @@ define void @wrappingindvars1(i8 %t, i32 %len, ptr %A) {
; UNROLL: vector.scevcheck:
; UNROLL-NEXT: [[TMP1:%.*]] = trunc i32 [[LEN]] to i8
; UNROLL-NEXT: [[TMP2:%.*]] = add i8 [[T]], [[TMP1]]
-; UNROLL-NEXT: [[TMP3:%.*]] = icmp slt i8 [[TMP2]], [[T]]
+; UNROLL-NEXT: [[TMP3:%.*]] = icmp ult i8 [[TMP2]], [[T]]
; UNROLL-NEXT: [[TMP4:%.*]] = icmp ugt i32 [[LEN]], 255
; UNROLL-NEXT: [[TMP5:%.*]] = or i1 [[TMP3]], [[TMP4]]
; UNROLL-NEXT: [[TMP6:%.*]] = add i8 [[T]], [[TMP1]]
-; UNROLL-NEXT: [[TMP7:%.*]] = icmp ult i8 [[TMP6]], [[T]]
+; UNROLL-NEXT: [[TMP7:%.*]] = icmp slt i8 [[TMP6]], [[T]]
----------------
david-arm wrote:
Are the changes in this file safe? Previously for values of t=0,len=255 we would skip the vector loop and jump to the scalar loop. That's because we did
tmp2 = add i8 0, 255
tmp3 = icmp slt i8 tmp2, t (i.e. icmp slt i8 -1, 0) -> true
I think that's because in the scalar loop we have:
```
%idx = phi i8 [ %t, %entry ], [ %idx.inc, %loop ]
...
%ptr = getelementptr inbounds i32, ptr %A, i8 %idx
```
where the offset passed to getelementptr is a signed value. So for t=0, len=255 there would effectively be signed overflow as %idx is incremented past a value of 127.
https://github.com/llvm/llvm-project/pull/216362
More information about the llvm-commits
mailing list