Skip to content

Commit e0f14e1

Browse files
authored
[SLPVectorizer] Refine the scope of RdxOpcode in HorizontalReduction::createOp (NFC) (#122239)
This patch is one part of unifying IAnyOf and FAnyOf reduction. #118393 The related patch is #118777.
1 parent 5e92e8c commit e0f14e1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19393,27 +19393,32 @@ class HorizontalReduction {
1939319393
/// Creates reduction operation with the current opcode.
1939419394
static Value *createOp(IRBuilderBase &Builder, RecurKind Kind, Value *LHS,
1939519395
Value *RHS, const Twine &Name, bool UseSelect) {
19396-
unsigned RdxOpcode = RecurrenceDescriptor::getOpcode(Kind);
1939719396
switch (Kind) {
19398-
case RecurKind::Or:
19397+
case RecurKind::Or: {
1939919398
if (UseSelect &&
1940019399
LHS->getType() == CmpInst::makeCmpResultType(LHS->getType()))
1940119400
return Builder.CreateSelect(LHS, Builder.getTrue(), RHS, Name);
19401+
unsigned RdxOpcode = RecurrenceDescriptor::getOpcode(Kind);
1940219402
return Builder.CreateBinOp((Instruction::BinaryOps)RdxOpcode, LHS, RHS,
1940319403
Name);
19404-
case RecurKind::And:
19404+
}
19405+
case RecurKind::And: {
1940519406
if (UseSelect &&
1940619407
LHS->getType() == CmpInst::makeCmpResultType(LHS->getType()))
1940719408
return Builder.CreateSelect(LHS, RHS, Builder.getFalse(), Name);
19409+
unsigned RdxOpcode = RecurrenceDescriptor::getOpcode(Kind);
1940819410
return Builder.CreateBinOp((Instruction::BinaryOps)RdxOpcode, LHS, RHS,
1940919411
Name);
19412+
}
1941019413
case RecurKind::Add:
1941119414
case RecurKind::Mul:
1941219415
case RecurKind::Xor:
1941319416
case RecurKind::FAdd:
19414-
case RecurKind::FMul:
19417+
case RecurKind::FMul: {
19418+
unsigned RdxOpcode = RecurrenceDescriptor::getOpcode(Kind);
1941519419
return Builder.CreateBinOp((Instruction::BinaryOps)RdxOpcode, LHS, RHS,
1941619420
Name);
19421+
}
1941719422
case RecurKind::FMax:
1941819423
return Builder.CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS);
1941919424
case RecurKind::FMin:

0 commit comments

Comments
 (0)