[llvm] c7d373a - [SLP][NFC]Add a test with the incorrect transformation result, NFC
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 28 11:57:33 PST 2025
Author: Alexey Bataev
Date: 2025-12-28T11:56:08-08:00
New Revision: c7d373ac038d35d4cc7a9ea8d9c0073da81716aa
URL: https://github.com/llvm/llvm-project/commit/c7d373ac038d35d4cc7a9ea8d9c0073da81716aa
DIFF: https://github.com/llvm/llvm-project/commit/c7d373ac038d35d4cc7a9ea8d9c0073da81716aa.diff
LOG: [SLP][NFC]Add a test with the incorrect transformation result, NFC
Added:
llvm/test/Transforms/SLPVectorizer/test_intermediate_dual_use.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SLPVectorizer/test_intermediate_dual_use.ll b/llvm/test/Transforms/SLPVectorizer/test_intermediate_dual_use.ll
new file mode 100644
index 0000000000000..e7e8a113163ca
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/test_intermediate_dual_use.ll
@@ -0,0 +1,43 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; TEST 3: Intermediate Node Dual Use
+; Construct a chain where an intermediate value becomes poison,
+; and is then used in a safe way and an unsafe way.
+
+; RUN: opt -S --passes=slp-vectorizer < %s | FileCheck %s
+
+define i1 @test_intermediate_dual_use(<4 x i32> %x) {
+; CHECK-LABEL: define i1 @test_intermediate_dual_use(
+; CHECK-SAME: <4 x i32> [[X:%.*]]) {
+; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i32> [[X]], i32 0
+; CHECK-NEXT: [[P_VAL:%.*]] = extractelement <4 x i32> [[X]], i32 -1
+; CHECK-NEXT: [[LEAF_P:%.*]] = icmp eq i32 [[P_VAL]], 0
+; CHECK-NEXT: [[LEAF_F:%.*]] = icmp ugt i32 [[X0]], -1
+; CHECK-NEXT: [[OP_RDX2:%.*]] = select i1 true, i1 [[LEAF_F]], i1 false
+; CHECK-NEXT: [[OP_RDX3:%.*]] = select i1 [[LEAF_P]], i1 [[OP_RDX2]], i1 false
+; CHECK-NEXT: ret i1 [[OP_RDX3]]
+;
+ %x0 = extractelement <4 x i32> %x, i32 0
+
+ ; Leaves
+ %p_val = extractelement <4 x i32> %x, i32 -1
+ %leaf_p = icmp eq i32 %p_val, 0 ; Poison
+ %leaf_f = icmp ugt i32 %x0, -1 ; False
+
+ ; Intermediate 1: Poison
+ ; select poison, true, false -> poison
+ %i1 = select i1 %leaf_p, i1 true, i1 false
+
+ ; Intermediate 2: Safe usage of %i1
+ ; select false, %i1, false -> false
+ %safe = select i1 %leaf_f, i1 %i1, i1 false
+
+ ; Intermediate 3: Unsafe usage of %i1 (as Condition)
+ ; select %i1, true, false -> poison
+ %unsafe = select i1 %i1, i1 true, i1 false
+
+ ; Final: safe && unsafe -> false && poison -> false
+ %res = select i1 %safe, i1 %unsafe, i1 false
+
+ ret i1 %res
+}
+
More information about the llvm-commits
mailing list