[llvm] [LV][NFC] Add another case to cast-costs.ll test (PR #201117)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 01:47:05 PDT 2026


https://github.com/david-arm updated https://github.com/llvm/llvm-project/pull/201117

>From 8426abe09cf765053b680ac82081d7afd293c606 Mon Sep 17 00:00:00 2001
From: David Sherwood <david.sherwood at arm.com>
Date: Tue, 2 Jun 2026 13:18:47 +0000
Subject: [PATCH 1/2] [LV][NFC] Add another case to cast-costs.ll test

---
 .../Transforms/LoopVectorize/cast-costs.ll    | 32 +++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/cast-costs.ll b/llvm/test/Transforms/LoopVectorize/cast-costs.ll
index 14b3e71b39166..6d2f534e43bbf 100644
--- a/llvm/test/Transforms/LoopVectorize/cast-costs.ll
+++ b/llvm/test/Transforms/LoopVectorize/cast-costs.ll
@@ -1,6 +1,6 @@
-; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --filter "Cost.*EMIT-SCALAR.*(trunc|sext|zext)" --filter "Cost.*WIDEN-CAST" --filter-out-after "LV: Selecting VF" --version 6
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --filter "Cost.*(EMIT-SCALAR|CLONE).*(trunc|sext|zext)" --filter "Cost.*WIDEN-CAST" --filter-out-after "LV: Selecting VF" --version 6
 ; REQUIRES: asserts
-; RUN: opt -p loop-vectorize -S -disable-output -debug-only=loop-vectorize %s 2>&1 | FileCheck %s
+; RUN: opt -p loop-vectorize -force-target-supports-scalable-vectors -S -disable-output -debug-only=loop-vectorize %s 2>&1 | FileCheck %s
 
 define void @trunc_store(ptr %dst) {
 ; CHECK-LABEL: 'trunc_store'
@@ -78,3 +78,31 @@ exit:
   %ret = trunc i32 %red.next to i8
   ret i8 %ret
 }
+
+define void @replicate_zext(ptr nocapture noundef writeonly %A, ptr nocapture noundef readonly %B, i32 noundef signext %n) {
+; CHECK-LABEL: 'replicate_zext'
+; CHECK:  Cost of 1 for VF vscale x 1: CLONE ir<%idxprom> = zext ir<%i.0>
+;
+entry:
+  br label %for.body
+
+for.body:
+  %indvars.iv = phi i32 [ %n, %entry ], [ %indvars.iv.next, %for.body ]
+  %i.0.in8 = phi i32 [ %n, %entry ], [ %i.0, %for.body ]
+  %i.0 = add nsw i32 %i.0.in8, -1
+  %idxprom = zext i32 %i.0 to i64
+  %arrayidx = getelementptr inbounds i32, ptr %B, i64 %idxprom
+  %1 = load i32, ptr %arrayidx, align 4
+  %add9 = add i32 %1, 1
+  %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %idxprom
+  store i32 %add9, ptr %arrayidx3, align 4
+  %cmp = icmp ugt i32 %indvars.iv, 1
+  %indvars.iv.next = add nsw i32 %indvars.iv, -1
+  br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0
+
+for.cond.cleanup:
+  ret void
+}
+
+!0 = distinct !{!0, !1}
+!1 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}

>From b6367023ea3d82d573dbedc49864beff8a70a1c5 Mon Sep 17 00:00:00 2001
From: David Sherwood <david.sherwood at arm.com>
Date: Wed, 3 Jun 2026 08:46:23 +0000
Subject: [PATCH 2/2] Address review comments

---
 .../Transforms/LoopVectorize/cast-costs.ll    | 29 ++++++++-----------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/cast-costs.ll b/llvm/test/Transforms/LoopVectorize/cast-costs.ll
index 6d2f534e43bbf..4020807988635 100644
--- a/llvm/test/Transforms/LoopVectorize/cast-costs.ll
+++ b/llvm/test/Transforms/LoopVectorize/cast-costs.ll
@@ -79,28 +79,23 @@ exit:
   ret i8 %ret
 }
 
-define void @replicate_zext(ptr nocapture noundef writeonly %A, ptr nocapture noundef readonly %B, i32 noundef signext %n) {
+define void @replicate_zext(ptr %A, i32 %n) {
 ; CHECK-LABEL: 'replicate_zext'
-; CHECK:  Cost of 1 for VF vscale x 1: CLONE ir<%idxprom> = zext ir<%i.0>
+; CHECK:  Cost of 1 for VF vscale x 1: CLONE ir<%iv.ext> = zext vp<[[VP4:%[0-9]+]]>
 ;
 entry:
-  br label %for.body
+  br label %loop
 
-for.body:
-  %indvars.iv = phi i32 [ %n, %entry ], [ %indvars.iv.next, %for.body ]
-  %i.0.in8 = phi i32 [ %n, %entry ], [ %i.0, %for.body ]
-  %i.0 = add nsw i32 %i.0.in8, -1
-  %idxprom = zext i32 %i.0 to i64
-  %arrayidx = getelementptr inbounds i32, ptr %B, i64 %idxprom
-  %1 = load i32, ptr %arrayidx, align 4
-  %add9 = add i32 %1, 1
-  %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %idxprom
-  store i32 %add9, ptr %arrayidx3, align 4
-  %cmp = icmp ugt i32 %indvars.iv, 1
-  %indvars.iv.next = add nsw i32 %indvars.iv, -1
-  br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0
+loop:
+  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
+  %iv.ext = zext i32 %iv to i64
+  %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv.ext
+  store i32 0, ptr %gep.A, align 4
+  %cmp = icmp ne i32 %iv, 1000
+  %iv.next = add nsw i32 %iv, 1
+  br i1 %cmp, label %loop, label %exit, !llvm.loop !0
 
-for.cond.cleanup:
+exit:
   ret void
 }
 



More information about the llvm-commits mailing list