Skip to content

Commit 8d943c3

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into amdgcnspirv_hip_does_not_need_ocl_cc
2 parents 05ed2fe + d941254 commit 8d943c3

File tree

5 files changed

+242
-15
lines changed

5 files changed

+242
-15
lines changed

lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ def test_save_linux_mini_dump(self):
117117
expected_number_of_threads = process.GetNumThreads()
118118
expected_threads = []
119119
stacks_to_sp_map = {}
120-
stakcs_to_registers_map = {}
120+
stacks_to_registers_map = {}
121121

122122
for thread_idx in range(process.GetNumThreads()):
123123
thread = process.GetThreadAtIndex(thread_idx)
124124
thread_id = thread.GetThreadID()
125125
expected_threads.append(thread_id)
126126
stacks_to_sp_map[thread_id] = thread.GetFrameAtIndex(0).GetSP()
127-
stakcs_to_registers_map[thread_id] = thread.GetFrameAtIndex(
127+
stacks_to_registers_map[thread_id] = thread.GetFrameAtIndex(
128128
0
129129
).GetRegisters()
130130

@@ -138,7 +138,7 @@ def test_save_linux_mini_dump(self):
138138
expected_modules,
139139
expected_threads,
140140
stacks_to_sp_map,
141-
stakcs_to_registers_map,
141+
stacks_to_registers_map,
142142
)
143143

144144
self.runCmd(base_command + " --style=modified-memory '%s'" % (core_dirty))
@@ -149,7 +149,7 @@ def test_save_linux_mini_dump(self):
149149
expected_modules,
150150
expected_threads,
151151
stacks_to_sp_map,
152-
stakcs_to_registers_map,
152+
stacks_to_registers_map,
153153
)
154154

155155
self.runCmd(base_command + " --style=full '%s'" % (core_full))
@@ -160,7 +160,7 @@ def test_save_linux_mini_dump(self):
160160
expected_modules,
161161
expected_threads,
162162
stacks_to_sp_map,
163-
stakcs_to_registers_map,
163+
stacks_to_registers_map,
164164
)
165165

166166
options = lldb.SBSaveCoreOptions()
@@ -178,7 +178,7 @@ def test_save_linux_mini_dump(self):
178178
expected_modules,
179179
expected_threads,
180180
stacks_to_sp_map,
181-
stakcs_to_registers_map,
181+
stacks_to_registers_map,
182182
)
183183

184184
options = lldb.SBSaveCoreOptions()
@@ -195,7 +195,7 @@ def test_save_linux_mini_dump(self):
195195
expected_modules,
196196
expected_threads,
197197
stacks_to_sp_map,
198-
stakcs_to_registers_map,
198+
stacks_to_registers_map,
199199
)
200200

201201
# Minidump can now save full core files, but they will be huge and
@@ -214,7 +214,7 @@ def test_save_linux_mini_dump(self):
214214
expected_modules,
215215
expected_threads,
216216
stacks_to_sp_map,
217-
stakcs_to_registers_map,
217+
stacks_to_registers_map,
218218
)
219219

220220
self.assertSuccess(process.Kill())

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -955,9 +955,11 @@ static Value *foldIsPowerOf2OrZero(ICmpInst *Cmp0, ICmpInst *Cmp1, bool IsAnd,
955955
}
956956

957957
/// Reduce a pair of compares that check if a value has exactly 1 bit set.
958-
/// Also used for logical and/or, must be poison safe.
958+
/// Also used for logical and/or, must be poison safe if range attributes are
959+
/// dropped.
959960
static Value *foldIsPowerOf2(ICmpInst *Cmp0, ICmpInst *Cmp1, bool JoinedByAnd,
960-
InstCombiner::BuilderTy &Builder) {
961+
InstCombiner::BuilderTy &Builder,
962+
InstCombinerImpl &IC) {
961963
// Handle 'and' / 'or' commutation: make the equality check the first operand.
962964
if (JoinedByAnd && Cmp1->getPredicate() == ICmpInst::ICMP_NE)
963965
std::swap(Cmp0, Cmp1);
@@ -971,7 +973,10 @@ static Value *foldIsPowerOf2(ICmpInst *Cmp0, ICmpInst *Cmp1, bool JoinedByAnd,
971973
match(Cmp1, m_SpecificICmp(ICmpInst::ICMP_ULT,
972974
m_Intrinsic<Intrinsic::ctpop>(m_Specific(X)),
973975
m_SpecificInt(2)))) {
974-
Value *CtPop = Cmp1->getOperand(0);
976+
auto *CtPop = cast<Instruction>(Cmp1->getOperand(0));
977+
// Drop range attributes and re-infer them in the next iteration.
978+
CtPop->dropPoisonGeneratingAnnotations();
979+
IC.addToWorklist(CtPop);
975980
return Builder.CreateICmpEQ(CtPop, ConstantInt::get(CtPop->getType(), 1));
976981
}
977982
// (X == 0) || (ctpop(X) u> 1) --> ctpop(X) != 1
@@ -980,7 +985,10 @@ static Value *foldIsPowerOf2(ICmpInst *Cmp0, ICmpInst *Cmp1, bool JoinedByAnd,
980985
match(Cmp1, m_SpecificICmp(ICmpInst::ICMP_UGT,
981986
m_Intrinsic<Intrinsic::ctpop>(m_Specific(X)),
982987
m_SpecificInt(1)))) {
983-
Value *CtPop = Cmp1->getOperand(0);
988+
auto *CtPop = cast<Instruction>(Cmp1->getOperand(0));
989+
// Drop range attributes and re-infer them in the next iteration.
990+
CtPop->dropPoisonGeneratingAnnotations();
991+
IC.addToWorklist(CtPop);
984992
return Builder.CreateICmpNE(CtPop, ConstantInt::get(CtPop->getType(), 1));
985993
}
986994
return nullptr;
@@ -3375,7 +3383,7 @@ Value *InstCombinerImpl::foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,
33753383
if (Value *V = foldSignedTruncationCheck(LHS, RHS, I, Builder))
33763384
return V;
33773385

3378-
if (Value *V = foldIsPowerOf2(LHS, RHS, IsAnd, Builder))
3386+
if (Value *V = foldIsPowerOf2(LHS, RHS, IsAnd, Builder, *this))
33793387
return V;
33803388

33813389
if (Value *V = foldPowerOf2AndShiftedMask(LHS, RHS, IsAnd, Builder))

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6480,12 +6480,32 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
64806480
// Phi nodes in non-header blocks (not inductions, reductions, etc.) are
64816481
// converted into select instructions. We require N - 1 selects per phi
64826482
// node, where N is the number of incoming values.
6483-
if (VF.isVector() && Phi->getParent() != TheLoop->getHeader())
6483+
if (VF.isVector() && Phi->getParent() != TheLoop->getHeader()) {
6484+
Type *ResultTy = Phi->getType();
6485+
6486+
// All instructions in an Any-of reduction chain are narrowed to bool.
6487+
// Check if that is the case for this phi node.
6488+
auto *HeaderUser = cast_if_present<PHINode>(
6489+
find_singleton<User>(Phi->users(), [this](User *U, bool) -> User * {
6490+
auto *Phi = dyn_cast<PHINode>(U);
6491+
if (Phi && Phi->getParent() == TheLoop->getHeader())
6492+
return Phi;
6493+
return nullptr;
6494+
}));
6495+
if (HeaderUser) {
6496+
auto &ReductionVars = Legal->getReductionVars();
6497+
auto Iter = ReductionVars.find(HeaderUser);
6498+
if (Iter != ReductionVars.end() &&
6499+
RecurrenceDescriptor::isAnyOfRecurrenceKind(
6500+
Iter->second.getRecurrenceKind()))
6501+
ResultTy = Type::getInt1Ty(Phi->getContext());
6502+
}
64846503
return (Phi->getNumIncomingValues() - 1) *
64856504
TTI.getCmpSelInstrCost(
6486-
Instruction::Select, ToVectorTy(Phi->getType(), VF),
6505+
Instruction::Select, ToVectorTy(ResultTy, VF),
64876506
ToVectorTy(Type::getInt1Ty(Phi->getContext()), VF),
64886507
CmpInst::BAD_ICMP_PREDICATE, CostKind);
6508+
}
64896509

64906510
return TTI.getCFInstrCost(Instruction::PHI, CostKind);
64916511
}

llvm/test/Transforms/InstCombine/ispow2.ll

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,3 +1522,35 @@ define <2 x i1> @not_pow2_or_z_known_bits_fail_wrong_cmp(<2 x i32> %xin) {
15221522
%r = icmp ugt <2 x i32> %cnt, <i32 2, i32 2>
15231523
ret <2 x i1> %r
15241524
}
1525+
1526+
; Make sure that range attributes on return values are dropped after merging these two icmps
1527+
1528+
define i1 @has_single_bit(i32 %x) {
1529+
; CHECK-LABEL: @has_single_bit(
1530+
; CHECK-NEXT: entry:
1531+
; CHECK-NEXT: [[POPCNT:%.*]] = call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 [[X:%.*]])
1532+
; CHECK-NEXT: [[SEL:%.*]] = icmp eq i32 [[POPCNT]], 1
1533+
; CHECK-NEXT: ret i1 [[SEL]]
1534+
;
1535+
entry:
1536+
%cmp1 = icmp ne i32 %x, 0
1537+
%popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)
1538+
%cmp2 = icmp ult i32 %popcnt, 2
1539+
%sel = select i1 %cmp1, i1 %cmp2, i1 false
1540+
ret i1 %sel
1541+
}
1542+
1543+
define i1 @has_single_bit_inv(i32 %x) {
1544+
; CHECK-LABEL: @has_single_bit_inv(
1545+
; CHECK-NEXT: entry:
1546+
; CHECK-NEXT: [[POPCNT:%.*]] = call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 [[X:%.*]])
1547+
; CHECK-NEXT: [[SEL:%.*]] = icmp ne i32 [[POPCNT]], 1
1548+
; CHECK-NEXT: ret i1 [[SEL]]
1549+
;
1550+
entry:
1551+
%cmp1 = icmp eq i32 %x, 0
1552+
%popcnt = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)
1553+
%cmp2 = icmp ugt i32 %popcnt, 1
1554+
%sel = select i1 %cmp1, i1 true, i1 %cmp2
1555+
ret i1 %sel
1556+
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -p loop-vectorize -S %s | FileCheck %s
3+
4+
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
5+
target triple = "riscv64-unknown-linux-gnu"
6+
7+
; Test case for https://github.com/llvm/llvm-project/issues/111874.
8+
define i32 @any_of_reduction_used_in_blend(ptr %src, i64 %N, i1 %c.0, i1 %c.1) #0 {
9+
; CHECK-LABEL: define i32 @any_of_reduction_used_in_blend(
10+
; CHECK-SAME: ptr [[SRC:%.*]], i64 [[N:%.*]], i1 [[C_0:%.*]], i1 [[C_1:%.*]]) #[[ATTR0:[0-9]+]] {
11+
; CHECK-NEXT: [[ENTRY:.*]]:
12+
; CHECK-NEXT: br label %[[LOOP_HEADER:.*]]
13+
; CHECK: [[LOOP_HEADER]]:
14+
; CHECK-NEXT: [[ANY_OF_RED:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[ANY_OF_RED_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
15+
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH]] ]
16+
; CHECK-NEXT: br i1 [[C_0]], label %[[LOOP_LATCH]], label %[[ELSE_1:.*]]
17+
; CHECK: [[ELSE_1]]:
18+
; CHECK-NEXT: br i1 [[C_1]], label %[[LOOP_LATCH]], label %[[ELSE_2:.*]]
19+
; CHECK: [[ELSE_2]]:
20+
; CHECK-NEXT: [[L:%.*]] = load ptr, ptr [[SRC]], align 8
21+
; CHECK-NEXT: [[C_2:%.*]] = icmp eq ptr [[L]], null
22+
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[C_2]], i32 0, i32 [[ANY_OF_RED]]
23+
; CHECK-NEXT: br label %[[LOOP_LATCH]]
24+
; CHECK: [[LOOP_LATCH]]:
25+
; CHECK-NEXT: [[ANY_OF_RED_NEXT]] = phi i32 [ [[ANY_OF_RED]], %[[LOOP_HEADER]] ], [ [[ANY_OF_RED]], %[[ELSE_1]] ], [ [[SEL]], %[[ELSE_2]] ]
26+
; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
27+
; CHECK-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
28+
; CHECK-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
29+
; CHECK: [[EXIT]]:
30+
; CHECK-NEXT: [[RES:%.*]] = phi i32 [ [[ANY_OF_RED_NEXT]], %[[LOOP_LATCH]] ]
31+
; CHECK-NEXT: ret i32 [[RES]]
32+
;
33+
entry:
34+
br label %loop.header
35+
36+
loop.header:
37+
%any.of.red = phi i32 [ 0, %entry ], [ %any.of.red.next, %loop.latch ]
38+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
39+
br i1 %c.0, label %loop.latch, label %else.1
40+
41+
else.1:
42+
br i1 %c.1, label %loop.latch, label %else.2
43+
44+
else.2:
45+
%l = load ptr, ptr %src, align 8
46+
%c.2 = icmp eq ptr %l, null
47+
%sel = select i1 %c.2, i32 0, i32 %any.of.red
48+
br label %loop.latch
49+
50+
loop.latch:
51+
%any.of.red.next = phi i32 [ %any.of.red, %loop.header ], [ %any.of.red, %else.1 ], [ %sel, %else.2 ]
52+
%iv.next = add i64 %iv, 1
53+
%ec = icmp eq i64 %iv.next, %N
54+
br i1 %ec, label %exit, label %loop.header
55+
56+
exit:
57+
%res = phi i32 [ %any.of.red.next, %loop.latch ]
58+
ret i32 %res
59+
}
60+
61+
define i32 @any_of_reduction_used_in_blend_with_mutliple_phis(ptr %src, i64 %N, i1 %c.0, i1 %c.1) #0 {
62+
; CHECK-LABEL: define i32 @any_of_reduction_used_in_blend_with_mutliple_phis(
63+
; CHECK-SAME: ptr [[SRC:%.*]], i64 [[N:%.*]], i1 [[C_0:%.*]], i1 [[C_1:%.*]]) #[[ATTR0]] {
64+
; CHECK-NEXT: [[ENTRY:.*]]:
65+
; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
66+
; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 2
67+
; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[N]], [[TMP1]]
68+
; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
69+
; CHECK: [[VECTOR_PH]]:
70+
; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
71+
; CHECK-NEXT: [[TMP3:%.*]] = mul i64 [[TMP2]], 2
72+
; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N]], [[TMP3]]
73+
; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N]], [[N_MOD_VF]]
74+
; CHECK-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64()
75+
; CHECK-NEXT: [[TMP5:%.*]] = mul i64 [[TMP4]], 2
76+
; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i1> poison, i1 [[C_0]], i64 0
77+
; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 2 x i1> [[BROADCAST_SPLATINSERT]], <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer
78+
; CHECK-NEXT: [[BROADCAST_SPLATINSERT1:%.*]] = insertelement <vscale x 2 x i1> poison, i1 [[C_1]], i64 0
79+
; CHECK-NEXT: [[BROADCAST_SPLAT2:%.*]] = shufflevector <vscale x 2 x i1> [[BROADCAST_SPLATINSERT1]], <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer
80+
; CHECK-NEXT: [[BROADCAST_SPLATINSERT3:%.*]] = insertelement <vscale x 2 x ptr> poison, ptr [[SRC]], i64 0
81+
; CHECK-NEXT: [[BROADCAST_SPLAT4:%.*]] = shufflevector <vscale x 2 x ptr> [[BROADCAST_SPLATINSERT3]], <vscale x 2 x ptr> poison, <vscale x 2 x i32> zeroinitializer
82+
; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
83+
; CHECK: [[VECTOR_BODY]]:
84+
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
85+
; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <vscale x 2 x i1> [ zeroinitializer, %[[VECTOR_PH]] ], [ [[PREDPHI:%.*]], %[[VECTOR_BODY]] ]
86+
; CHECK-NEXT: [[TMP6:%.*]] = xor <vscale x 2 x i1> [[BROADCAST_SPLAT]], shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer)
87+
; CHECK-NEXT: [[TMP7:%.*]] = xor <vscale x 2 x i1> [[BROADCAST_SPLAT2]], shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer)
88+
; CHECK-NEXT: [[TMP8:%.*]] = select <vscale x 2 x i1> [[TMP6]], <vscale x 2 x i1> [[TMP7]], <vscale x 2 x i1> zeroinitializer
89+
; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <vscale x 2 x ptr> @llvm.masked.gather.nxv2p0.nxv2p0(<vscale x 2 x ptr> [[BROADCAST_SPLAT4]], i32 8, <vscale x 2 x i1> [[TMP8]], <vscale x 2 x ptr> poison)
90+
; CHECK-NEXT: [[TMP9:%.*]] = icmp eq <vscale x 2 x ptr> [[WIDE_MASKED_GATHER]], zeroinitializer
91+
; CHECK-NEXT: [[TMP10:%.*]] = or <vscale x 2 x i1> [[VEC_PHI]], [[TMP9]]
92+
; CHECK-NEXT: [[PREDPHI]] = select <vscale x 2 x i1> [[TMP8]], <vscale x 2 x i1> [[TMP10]], <vscale x 2 x i1> [[VEC_PHI]]
93+
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP5]]
94+
; CHECK-NEXT: [[TMP11:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
95+
; CHECK-NEXT: br i1 [[TMP11]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
96+
; CHECK: [[MIDDLE_BLOCK]]:
97+
; CHECK-NEXT: [[TMP12:%.*]] = call i1 @llvm.vector.reduce.or.nxv2i1(<vscale x 2 x i1> [[PREDPHI]])
98+
; CHECK-NEXT: [[TMP13:%.*]] = freeze i1 [[TMP12]]
99+
; CHECK-NEXT: [[RDX_SELECT:%.*]] = select i1 [[TMP13]], i32 0, i32 0
100+
; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[N]], [[N_VEC]]
101+
; CHECK-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]
102+
; CHECK: [[SCALAR_PH]]:
103+
; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]
104+
; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi i32 [ [[RDX_SELECT]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]
105+
; CHECK-NEXT: br label %[[LOOP_HEADER:.*]]
106+
; CHECK: [[LOOP_HEADER]]:
107+
; CHECK-NEXT: [[ANY_OF_RED:%.*]] = phi i32 [ [[BC_MERGE_RDX]], %[[SCALAR_PH]] ], [ [[ANY_OF_RED_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
108+
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH]] ]
109+
; CHECK-NEXT: br i1 [[C_0]], label %[[X_1:.*]], label %[[ELSE_1:.*]]
110+
; CHECK: [[ELSE_1]]:
111+
; CHECK-NEXT: br i1 [[C_1]], label %[[X_1]], label %[[ELSE_2:.*]]
112+
; CHECK: [[ELSE_2]]:
113+
; CHECK-NEXT: [[L:%.*]] = load ptr, ptr [[SRC]], align 8
114+
; CHECK-NEXT: [[C_2:%.*]] = icmp eq ptr [[L]], null
115+
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[C_2]], i32 0, i32 [[ANY_OF_RED]]
116+
; CHECK-NEXT: br label %[[LOOP_LATCH]]
117+
; CHECK: [[X_1]]:
118+
; CHECK-NEXT: [[P:%.*]] = phi i32 [ [[ANY_OF_RED]], %[[LOOP_HEADER]] ], [ [[ANY_OF_RED]], %[[ELSE_1]] ]
119+
; CHECK-NEXT: br label %[[LOOP_LATCH]]
120+
; CHECK: [[LOOP_LATCH]]:
121+
; CHECK-NEXT: [[ANY_OF_RED_NEXT]] = phi i32 [ [[P]], %[[X_1]] ], [ [[SEL]], %[[ELSE_2]] ]
122+
; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
123+
; CHECK-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
124+
; CHECK-NEXT: br i1 [[EC]], label %[[EXIT]], label %[[LOOP_HEADER]], !llvm.loop [[LOOP3:![0-9]+]]
125+
; CHECK: [[EXIT]]:
126+
; CHECK-NEXT: [[RES:%.*]] = phi i32 [ [[ANY_OF_RED_NEXT]], %[[LOOP_LATCH]] ], [ [[RDX_SELECT]], %[[MIDDLE_BLOCK]] ]
127+
; CHECK-NEXT: ret i32 [[RES]]
128+
;
129+
entry:
130+
br label %loop.header
131+
132+
loop.header:
133+
%any.of.red = phi i32 [ 0, %entry ], [ %any.of.red.next, %loop.latch ]
134+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
135+
br i1 %c.0, label %x.1, label %else.1
136+
137+
else.1:
138+
br i1 %c.1, label %x.1, label %else.2
139+
140+
else.2:
141+
%l = load ptr, ptr %src, align 8
142+
%c.2 = icmp eq ptr %l, null
143+
%sel = select i1 %c.2, i32 0, i32 %any.of.red
144+
br label %loop.latch
145+
146+
x.1:
147+
%p = phi i32 [ %any.of.red, %loop.header ], [ %any.of.red, %else.1 ]
148+
br label %loop.latch
149+
150+
loop.latch:
151+
%any.of.red.next = phi i32 [ %p, %x.1 ], [ %sel, %else.2 ]
152+
%iv.next = add i64 %iv, 1
153+
%ec = icmp eq i64 %iv.next, %N
154+
br i1 %ec, label %exit, label %loop.header
155+
156+
exit:
157+
%res = phi i32 [ %any.of.red.next, %loop.latch ]
158+
ret i32 %res
159+
}
160+
161+
attributes #0 = { "target-cpu"="sifive-p670" }
162+
;.
163+
; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]}
164+
; CHECK: [[META1]] = !{!"llvm.loop.isvectorized", i32 1}
165+
; CHECK: [[META2]] = !{!"llvm.loop.unroll.runtime.disable"}
166+
; CHECK: [[LOOP3]] = distinct !{[[LOOP3]], [[META2]], [[META1]]}
167+
;.

0 commit comments

Comments
 (0)