[llvm] 3c554de - [LV] Add reg-usage test with values only used by llvm.assume.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 19 05:18:16 PDT 2025
Author: Florian Hahn
Date: 2025-03-19T12:17:50Z
New Revision: 3c554deaaaa9aaa4f1aebc0d19f56424a32fe5e3
URL: https://github.com/llvm/llvm-project/commit/3c554deaaaa9aaa4f1aebc0d19f56424a32fe5e3
DIFF: https://github.com/llvm/llvm-project/commit/3c554deaaaa9aaa4f1aebc0d19f56424a32fe5e3.diff
LOG: [LV] Add reg-usage test with values only used by llvm.assume.
Add test checking we are not counting registers that are only used by
ephemeral users, like llvm.assume.
Added:
Modified:
llvm/test/Transforms/LoopVectorize/AArch64/reg-usage.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/reg-usage.ll b/llvm/test/Transforms/LoopVectorize/AArch64/reg-usage.ll
index 8239d32445c10..79d4215cca50f 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/reg-usage.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/reg-usage.ll
@@ -11,14 +11,15 @@
; invariant %0
@string = internal unnamed_addr constant [5 x i8] c"abcd\00", align 1
+
define void @get_invariant_reg_usage(ptr %z) {
-; CHECK: LV: Checking a loop in 'get_invariant_reg_usage'
+; CHECK-LABEL: LV: Checking a loop in 'get_invariant_reg_usage'
; CHECK: LV(REG): VF = vscale x 16
; CHECK-NEXT: LV(REG): Found max usage: 1 item
; CHECK-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 3 registers
; CHECK-NEXT: LV(REG): Found invariant usage: 2 item
; CHECK-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 2 registers
-; CHECK-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 8 registers
+; CHECK-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 8 registers
L.entry:
%0 = load i128, ptr %z, align 16
@@ -39,3 +40,31 @@ loopbody: ;preds = %L.entry, %loopbody
return: ;preds = %loopexit, %L.entry
ret void
}
+
+define void @load_and_compare_only_used_by_assume(ptr %a, ptr noalias %b) {
+; CHECK-LABEL: LV: Checking a loop in 'load_and_compare_only_used_by_assume'
+; CHECK: LV(REG): VF = vscale x 4
+; CHECK-NEXT: LV(REG): Found max usage: 2 item
+; CHECK-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 2 registers
+; CHECK-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 1 registers
+; CHECK-NEXT: LV(REG): Found invariant usage: 0 item
+
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+ %gep.a = getelementptr inbounds i32, ptr %a, i64 %iv
+ %l.a = load i32, ptr %gep.a
+ %gep.b = getelementptr inbounds i32, ptr %b, i64 %iv
+ %l.b = load i32, ptr %gep.b
+ %c = icmp ugt i32 %l.b, 10
+ call void @llvm.assume(i1 %c)
+ store i32 %l.a, ptr %gep.b
+ %iv.next = add i64 %iv, 1
+ %ec = icmp eq i64 %iv.next, 1000
+ br i1 %ec, label %exit, label %loop
+
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list