[llvm] [VPlan] Introduce VPlanConstantFolder (PR #125365)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon May 5 13:02:36 PDT 2025


https://github.com/fhahn commented:

Thanks for the latest updates.

It looks like some checks related to pointers may be missing, I am seeing a crash with the following IR

```
; opt -p loop-vectorize

target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "arm64-apple-macosx15.0.0"

@postscale = external constant [64 x float]

define void @test(ptr %data) {
entry:
  br label %for.body

for.body:                                         ; preds = %for.body, %entry
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %for.body ], [ 0, %entry ]
  %0 = or disjoint i64 %indvars.iv78, 1
  %arrayidx142 = getelementptr [64 x float], ptr @postscale, i64 0, i64 %0
  %1 = load float, ptr %arrayidx142, align 4, !tbaa !0
  %2 = tail call i64 @llvm.lrint.i64.f32(float %1)
  %conv145 = trunc i64 %2 to i16
  store i16 %conv145, ptr %data, align 2, !tbaa !4
  %indvars.iv.next79 = add i64 %indvars.iv78, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next79, 8
  br i1 %exitcond.not, label %for.end, label %for.body

for.end:                                          ; preds = %for.body
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.lrint.i64.f32(float) #0

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!0 = !{!1, !1, i64 0}
!1 = !{!"float", !2, i64 0}
!2 = !{!"omnipotent char", !3, i64 0}
!3 = !{!"Simple C/C++ TBAA"}
!4 = !{!5, !5, i64 0}
!5 = !{!"short", !2, i64 0}
```

https://github.com/llvm/llvm-project/pull/125365


More information about the llvm-commits mailing list