[llvm] [LoopInterchange] Check all inner-exit LCSSA PHIs (PR #200860)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 01:59:30 PDT 2026
================
@@ -0,0 +1,54 @@
+; Non-reduction LCSSA PHIs in the inner-loop exit must still be validated
+; even when a reduction LCSSA PHI is present. Used to crash.
+;
+; RUN: opt < %s -passes=loop-interchange -loop-interchange-reduction-to-mem \
+; RUN: -pass-remarks-missed=loop-interchange -pass-remarks-output=%t -S \
+; RUN: | FileCheck -check-prefix=IR %s
+; RUN: FileCheck --input-file=%t %s
+
+; CHECK: --- !Missed
+; CHECK-NEXT: Pass: loop-interchange
+; CHECK-NEXT: Name: UnsupportedExitPHI
+; CHECK-NEXT: Function: reduction_lcssa_with_non_phi_user
+; CHECK-NEXT: Args:
+; CHECK-NEXT: - String: Found unsupported PHI node in loop exit.
+
+ at A = common global [100 x [100 x i32]] zeroinitializer
+ at sum = common global [100 x i32] zeroinitializer
+
+; IR-LABEL: @reduction_lcssa_with_non_phi_user(
+; IR-NOT: split
+define void @reduction_lcssa_with_non_phi_user() {
+entry:
+ br label %outer.header
+
+outer.header:
+ %i = phi i64 [ 0, %entry ], [ %i.next, %outer.latch ]
+ %sum.ptr = getelementptr inbounds [100 x i32], ptr @sum, i64 0, i64 %i
----------------
nikic wrote:
The canonical form is `%sum.ptr = getelementptr inbounds [4 x i8], ptr @sum, i64 %i`, see https://llvm.godbolt.org/z/eqTW6M5Pz.
I don't think you need to use `[4 x i8]` instead of `i32` here, but omitting the `[100 x ]` is indeed preferred, as it will no longer occur in any realistic IR.
(Though I don't think this is super important, these tests will get updated at some future point when migrating to ptradd.)
https://github.com/llvm/llvm-project/pull/200860
More information about the llvm-commits
mailing list