[llvm] 90bbffe - [VPlan] Add VPlan printing tests for recipes with metadata.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 1 15:06:38 PDT 2025


Author: Florian Hahn
Date: 2025-11-01T22:05:51Z
New Revision: 90bbffec02ed5f088fa323ca2480c97b6c431e7e

URL: https://github.com/llvm/llvm-project/commit/90bbffec02ed5f088fa323ca2480c97b6c431e7e
DIFF: https://github.com/llvm/llvm-project/commit/90bbffec02ed5f088fa323ca2480c97b6c431e7e.diff

LOG: [VPlan] Add VPlan printing tests for recipes with metadata.

Added: 
    llvm/test/Transforms/LoopVectorize/vplan-printing-metadata.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LoopVectorize/vplan-printing-metadata.ll b/llvm/test/Transforms/LoopVectorize/vplan-printing-metadata.ll
new file mode 100644
index 0000000000000..857b9131a0b8c
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/vplan-printing-metadata.ll
@@ -0,0 +1,100 @@
+; REQUIRES: asserts
+
+; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -disable-output %s 2>&1 | FileCheck %s
+
+define void @test_widen_metadata(ptr noalias %A, ptr noalias %B, i32 %n) {
+; CHECK-LABEL: Checking a loop in 'test_widen_metadata'
+; CHECK:      VPlan 'Initial VPlan for VF={4},UF>=1' {
+; CHECK:      <x1> vector loop: {
+; CHECK:        vector.body:
+; CHECK:          WIDEN ir<%lv> = load vp<{{.*}}>
+; CHECK:          WIDEN-CAST ir<%conv> = sitofp ir<%lv> to float
+; CHECK:          WIDEN ir<%mul> = fmul ir<%conv>, ir<2.000000e+00>
+; CHECK:          WIDEN-CAST ir<%conv.back> = fptosi ir<%mul> to i32
+; CHECK:          WIDEN store vp<{{.*}}>, ir<%conv.back>
+;
+entry:
+  br label %loop
+
+loop:
+  %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
+  %gep.A = getelementptr inbounds i32, ptr %A, i32 %i
+  %lv = load i32, ptr %gep.A, align 4, !tbaa !0, !range !6
+  %conv = sitofp i32 %lv to float, !fpmath !5
+  %mul = fmul float %conv, 2.0, !fpmath !5
+  %conv.back = fptosi float %mul to i32
+  %gep.B = getelementptr inbounds i32, ptr %B, i32 %i
+  store i32 %conv.back, ptr %gep.B, align 4, !tbaa !0
+  %i.next = add i32 %i, 1
+  %cond = icmp eq i32 %i.next, %n
+  br i1 %cond, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+declare float @llvm.sqrt.f32(float)
+
+define void @test_intrinsic_with_metadata(ptr noalias %A, ptr noalias %B, i32 %n) {
+; CHECK-LABEL: Checking a loop in 'test_intrinsic_with_metadata'
+; CHECK:      VPlan 'Initial VPlan for VF={4},UF>=1' {
+; CHECK:      <x1> vector loop: {
+; CHECK:        vector.body:
+; CHECK:          WIDEN ir<%lv> = load vp<{{.*}}>
+; CHECK:          WIDEN-INTRINSIC ir<%sqrt> = call llvm.sqrt(ir<%lv>)
+; CHECK:          WIDEN store vp<{{.*}}>, ir<%sqrt>
+;
+entry:
+  br label %loop
+
+loop:
+  %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
+  %gep.A = getelementptr inbounds float, ptr %A, i32 %i
+  %lv = load float, ptr %gep.A, align 4, !tbaa !0
+  %sqrt = call float @llvm.sqrt.f32(float %lv), !fpmath !5
+  %gep.B = getelementptr inbounds float, ptr %B, i32 %i
+  store float %sqrt, ptr %gep.B, align 4, !tbaa !0
+  %i.next = add i32 %i, 1
+  %cond = icmp eq i32 %i.next, %n
+  br i1 %cond, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+define void @test_widen_with_multiple_metadata(ptr noalias %A, ptr noalias %B, i32 %n) {
+; CHECK-LABEL: Checking a loop in 'test_widen_with_multiple_metadata'
+; CHECK:      VPlan 'Initial VPlan for VF={4},UF>=1' {
+; CHECK:      <x1> vector loop: {
+; CHECK:        vector.body:
+; CHECK:          WIDEN ir<%lv> = load vp<{{.*}}>
+; CHECK:          WIDEN-CAST ir<%conv> = sitofp ir<%lv> to float
+; CHECK:          WIDEN ir<%mul> = fmul ir<%conv>, ir<2.000000e+00>
+; CHECK:          WIDEN-CAST ir<%conv.back> = fptosi ir<%mul> to i32
+; CHECK:          WIDEN store vp<{{.*}}>, ir<%conv.back>
+;
+entry:
+  br label %loop
+
+loop:
+  %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
+  %gep.A = getelementptr inbounds i32, ptr %A, i32 %i
+  %lv = load i32, ptr %gep.A, align 4, !tbaa !0, !range !6
+  %conv = sitofp i32 %lv to float
+  %mul = fmul float %conv, 2.0
+  %conv.back = fptosi float %mul to i32
+  %gep.B = getelementptr inbounds i32, ptr %B, i32 %i
+  store i32 %conv.back, ptr %gep.B, align 4, !tbaa !0
+  %i.next = add i32 %i, 1
+  %cond = icmp eq i32 %i.next, %n
+  br i1 %cond, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+!0 = !{!1, !1, i64 0}
+!1 = !{!"float", !2}
+!2 = !{!"root"}
+!5 = !{float 2.500000e+00}
+!6 = !{i32 0, i32 100}


        


More information about the llvm-commits mailing list