| ; 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 [[OP_RDX2]], i1 [[LEAF_P]], 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 | |
| } | |