[llvm] [NFC][LV] Improve ee with sideeffects legality test (PR #158275)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 16 05:29:51 PDT 2025
https://github.com/huntergr-arm updated https://github.com/llvm/llvm-project/pull/158275
>From 38c5072217a8a21098cffd63079a500b8329e0e2 Mon Sep 17 00:00:00 2001
From: Graham Hunter <graham.hunter at arm.com>
Date: Fri, 12 Sep 2025 11:09:58 +0000
Subject: [PATCH 1/3] [NFC][LV] Improve ee with sideeffects legality test
---
.../early_exit_store_legality.ll | 39 ++++++++-----------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll b/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll
index 4226c5d9e650b..0f5f8876b6ef1 100644
--- a/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll
+++ b/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll
@@ -604,36 +604,31 @@ exit:
;; ICE was caused by assert for the load used in the uncountable exit condition
;; being guaranteed to execute.
- at e = external addrspace(21) global [4 x i8]
-define void @crash_conditional_load_for_uncountable_exit() {
+ at ee.global = external global [4 x i8]
+define void @crash_conditional_load_for_uncountable_exit(ptr dereferenceable(40) noalias %store.area) {
; CHECK-LABEL: LV: Checking a loop in 'crash_conditional_load_for_uncountable_exit'
; CHECK: LV: Not vectorizing: Load for uncountable exit not guaranteed to execute.
entry:
- br label %cont
-
-handler.out_of_bounds:
- unreachable
+ br label %for.body
-cont:
- %h.06 = phi i64 [ 0, %entry ], [ %inc, %a.exit ]
- %arrayidx = getelementptr i8, ptr addrspace(21) @e, i64 %h.06
- br i1 false, label %cont1, label %handler.type_mismatch
+for.body:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.inc ]
+ %ee.addr = getelementptr i8, ptr @ee.global, i64 %iv
+ br i1 false, label %ee.block, label %invalid.block
-handler.type_mismatch:
- unreachable
+ee.block:
+ %ee.val = load i8, ptr %ee.addr, align 1
+ store i16 0, ptr %store.area, align 2
+ %ee.cmp = icmp eq i8 %ee.val, 0
+ br i1 %ee.cmp, label %for.inc, label %invalid.block
-cont1:
- %0 = load i8, ptr addrspace(21) %arrayidx, align 1
- store i16 0, ptr null, align 2
- %cmp.not.i.i = icmp eq i8 %0, 0
- br i1 %cmp.not.i.i, label %a.exit, label %if.then.i.i
+for.inc:
+ %iv.next = add nuw nsw i64 %iv, 1
+ %counted.cond = icmp eq i64 %iv.next, 10
+ br i1 %counted.cond, label %invalid.block, label %for.body
-if.then.i.i:
+invalid.block:
unreachable
-
-a.exit:
- %inc = add i64 %h.06, 1
- br i1 true, label %handler.out_of_bounds, label %cont
}
>From f3f27ce6194ca42407e334a109137e70cd38ca0a Mon Sep 17 00:00:00 2001
From: Graham Hunter <graham.hunter at arm.com>
Date: Tue, 16 Sep 2025 10:28:17 +0000
Subject: [PATCH 2/3] Added variant with ptr via argument
---
.../early_exit_store_legality.ll | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll b/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll
index 0f5f8876b6ef1..4cf71a610dcdf 100644
--- a/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll
+++ b/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll
@@ -631,6 +631,32 @@ invalid.block:
unreachable
}
+define void @crash_conditional_load_for_uncountable_exit_argptr(ptr dereferenceable(40) noalias %store.area, ptr dereferenceable(4) %load.area) {
+; CHECK-LABEL: LV: Checking a loop in 'crash_conditional_load_for_uncountable_exit_argptr'
+; CHECK: LV: Not vectorizing: Load for uncountable exit not guaranteed to execute.
+entry:
+ br label %for.body
+
+for.body:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.inc ]
+ %ee.addr = getelementptr i8, ptr %load.area, i64 %iv
+ br i1 false, label %ee.block, label %invalid.block
+
+ee.block:
+ %ee.val = load i8, ptr %ee.addr, align 1
+ store i16 0, ptr %store.area, align 2
+ %ee.cmp = icmp eq i8 %ee.val, 0
+ br i1 %ee.cmp, label %for.inc, label %invalid.block
+
+for.inc:
+ %iv.next = add nuw nsw i64 %iv, 1
+ %counted.cond = icmp eq i64 %iv.next, 10
+ br i1 %counted.cond, label %invalid.block, label %for.body
+
+invalid.block:
+ unreachable
+}
+
declare void @init_mem(ptr, i64);
declare i64 @get_an_unknown_offset();
>From c838536c65a2afdd913ab97398f55e555128b73b Mon Sep 17 00:00:00 2001
From: Graham Hunter <graham.hunter at arm.com>
Date: Tue, 16 Sep 2025 12:14:55 +0000
Subject: [PATCH 3/3] Use an argument for branch condition instead of false
---
.../Transforms/LoopVectorize/early_exit_store_legality.ll | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll b/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll
index 4cf71a610dcdf..4e8b8e51df6c2 100644
--- a/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll
+++ b/llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll
@@ -631,16 +631,16 @@ invalid.block:
unreachable
}
-define void @crash_conditional_load_for_uncountable_exit_argptr(ptr dereferenceable(40) noalias %store.area, ptr dereferenceable(4) %load.area) {
+define void @crash_conditional_load_for_uncountable_exit_argptr(ptr dereferenceable(40) noalias %store.area, ptr dereferenceable(4) %load.area, i1 %skip.cond) {
; CHECK-LABEL: LV: Checking a loop in 'crash_conditional_load_for_uncountable_exit_argptr'
-; CHECK: LV: Not vectorizing: Load for uncountable exit not guaranteed to execute.
+; CHECK: LV: Not vectorizing: Loop has too many uncountable exits.
entry:
br label %for.body
for.body:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.inc ]
%ee.addr = getelementptr i8, ptr %load.area, i64 %iv
- br i1 false, label %ee.block, label %invalid.block
+ br i1 %skip.cond, label %ee.block, label %invalid.block
ee.block:
%ee.val = load i8, ptr %ee.addr, align 1
More information about the llvm-commits
mailing list