Closed
Description
With options "-O3 --target=aarch64 func.cpp -mllvm -enable-loopinterchange" and this input:
unsigned int A[11][11][11] __attribute__((aligned(16)));
void a(int b) {
for (int c;; c += b)
for (long d = 0; d < -3ULL; d += 2ULL)
A[c][d][d] = 0;
}
Loop-interchange runs in an assert:
llvm-project/llvm/include/llvm/ADT/APInt.h:1501: uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits() <= 64 && "Too many bits for uint64_t"' failed.
IR reproducer, compile this with "opt -passes=loop-interchange -S":
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "aarch64-unknown-linux-gnu"
@A = local_unnamed_addr global [11 x [11 x [11 x i32]]] zeroinitializer, align 16
define void @_Z1ai(i32 noundef %b) local_unnamed_addr #0 {
entry:
%0 = sext i32 %b to i64
br label %for.cond
; Loop:
for.cond: ; preds = %for.cond.cleanup, %entry
%indvars.iv = phi i64 [ %indvars.iv.next, %for.cond.cleanup ], [ 0, %entry ]
br label %for.body
for.cond.cleanup: ; preds = %for.body
%indvars.iv.next = add nsw i64 %indvars.iv, %0
br label %for.cond
for.body: ; preds = %for.cond, %for.body
%d.010 = phi i64 [ 0, %for.cond ], [ %add, %for.body ]
%arrayidx3 = getelementptr inbounds [11 x [11 x [11 x i32]]], ptr @A, i64 0, i64 %indvars.iv, i64 %d.010, i64 %d.010
store i32 0, ptr %arrayidx3, align 4
%add = add nuw i64 %d.010, 2
%cmp = icmp ult i64 %d.010, -5
br i1 %cmp, label %for.body, label %for.cond.cleanup
}