Issue 203375
Summary [LoopInterchange] Assertion failure with constant LCSSA phi argument
Labels crash-on-valid
Assignees
Reporter nikic
    ```llvm
; RUN: opt -S -passes=loop-interchange < %s

@A = global [16 x [16 x i32]] zeroinitializer
@B = global [16 x [16 x i32]] zeroinitializer
@S = global i32 0

define void @kernel() {
entry:
  br label %outer.header

outer.header:
  %i = phi i64 [ 0, %entry ], [ %i.next, %outer.latch ]
  br label %inner.header

inner.header:
  %j = phi i64 [ 0, %outer.header ], [ %j.next, %inner.latch ]
  %g = getelementptr inbounds [16 x [16 x i32]], ptr @A, i64 0, i64 %j, i64 %i
  %v = load i32, ptr %g
 %g2 = getelementptr inbounds [16 x [16 x i32]], ptr @B, i64 0, i64 %j, i64 %i
  store i32 %v, ptr %g2
  br label %inner.latch

inner.latch:
  %x = phi i32 [ 5, %inner.header ]          ; single-incoming PHI, constant value
 %j.next = add nuw nsw i64 %j, 1
  %j.cmp = icmp slt i64 %j.next, 14
  br i1 %j.cmp, label %inner.header, label %inner.exit

inner.exit:
  %x.lcssa = phi i32 [ %x, %inner.latch ]    ; LCSSA carrying %x out of the loop
  br label %outer.latch

outer.latch:
  %x.lcssa2 = phi i32 [ %x.lcssa, %inner.exit ]
  %i.next = add nuw nsw i64 %i, 1
  %i.cmp = icmp slt i64 %i.next, 14
  br i1 %i.cmp, label %outer.header, label %exit

exit:
 %x.final = phi i32 [ %x.lcssa2, %outer.latch ]
  store i32 %x.final, ptr @S
  ret void
}
```

> opt: /workspace/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From *) [To = llvm::Instruction, From = llvm::Value]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

Disclosure: The test case is AI generated.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to