[llvm] [indvars] Allow widenWithVariantUse to succeed without extend users (PR #71557)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 9 07:58:55 PST 2023
================
@@ -365,16 +364,15 @@ define void @zext_postinc_offset_constant_one(ptr %A, i32 %start) {
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT: [[J_016_US:%.*]] = phi i32 [ [[INC_US:%.*]], [[FOR_BODY]] ], [ [[START]], [[FOR_BODY_PREHEADER]] ]
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV]] to i32
; CHECK-NEXT: [[ADD_US:%.*]] = add i32 [[TMP1]], 1
; CHECK-NEXT: [[IDXPROM_US:%.*]] = zext i32 [[ADD_US]] to i64
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM_US]]
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
-; CHECK-NEXT: [[INC_US]] = add nsw i32 [[J_016_US]], -1
-; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[INC_US]], 6
+; CHECK-NEXT: [[TMP2:%.*]] = add nsw i64 [[INDVARS_IV]], 4294967295
----------------
preames wrote:
Actually, hold on. You're right and there's something funky going on here. We have a 64 bit IV which enumerates the same values as the 32 bit IV, but then the actual comparison uses a 64 bit offset (without truncation), and the high bits change the exit condition.
I need to investigate this further, thanks for spotting.
https://github.com/llvm/llvm-project/pull/71557
More information about the llvm-commits
mailing list