forked from OSchip/llvm-project
[Analysis] simplify propagation of FMF in recurrences; NFC
This is a mess, but this is hopefully no-functional-change. The 'Prev' descriptor is only used for min/max recurrences or when starting a match from a phi, so it should not be a factor when propagating FMF for fmul/fadd. The API is confusing (and should be reduced in subsequent steps) because the "UnsafeAlgebraInst" appears to actually be a placeholder for a recurrence that does NOT have FMF, but we still want to treat it as reassociative.
This commit is contained in:
parent
295ea050ad
commit
b3f0c2653b
|
@ -565,10 +565,6 @@ RecurrenceDescriptor::isConditionalRdxPattern(RecurKind Kind, Instruction *I) {
|
||||||
RecurrenceDescriptor::InstDesc
|
RecurrenceDescriptor::InstDesc
|
||||||
RecurrenceDescriptor::isRecurrenceInstr(Instruction *I, RecurKind Kind,
|
RecurrenceDescriptor::isRecurrenceInstr(Instruction *I, RecurKind Kind,
|
||||||
InstDesc &Prev, FastMathFlags FMF) {
|
InstDesc &Prev, FastMathFlags FMF) {
|
||||||
Instruction *UAI = Prev.getUnsafeAlgebraInst();
|
|
||||||
if (!UAI && isa<FPMathOperator>(I) && !I->hasAllowReassoc())
|
|
||||||
UAI = I; // Found an unsafe (unvectorizable) algebra instruction.
|
|
||||||
|
|
||||||
switch (I->getOpcode()) {
|
switch (I->getOpcode()) {
|
||||||
default:
|
default:
|
||||||
return InstDesc(false, I);
|
return InstDesc(false, I);
|
||||||
|
@ -587,10 +583,12 @@ RecurrenceDescriptor::isRecurrenceInstr(Instruction *I, RecurKind Kind,
|
||||||
return InstDesc(Kind == RecurKind::Xor, I);
|
return InstDesc(Kind == RecurKind::Xor, I);
|
||||||
case Instruction::FDiv:
|
case Instruction::FDiv:
|
||||||
case Instruction::FMul:
|
case Instruction::FMul:
|
||||||
return InstDesc(Kind == RecurKind::FMul, I, UAI);
|
return InstDesc(Kind == RecurKind::FMul, I,
|
||||||
|
I->hasAllowReassoc() ? nullptr : I);
|
||||||
case Instruction::FSub:
|
case Instruction::FSub:
|
||||||
case Instruction::FAdd:
|
case Instruction::FAdd:
|
||||||
return InstDesc(Kind == RecurKind::FAdd, I, UAI);
|
return InstDesc(Kind == RecurKind::FAdd, I,
|
||||||
|
I->hasAllowReassoc() ? nullptr : I);
|
||||||
case Instruction::Select:
|
case Instruction::Select:
|
||||||
if (Kind == RecurKind::FAdd || Kind == RecurKind::FMul)
|
if (Kind == RecurKind::FAdd || Kind == RecurKind::FMul)
|
||||||
return isConditionalRdxPattern(Kind, I);
|
return isConditionalRdxPattern(Kind, I);
|
||||||
|
@ -598,8 +596,7 @@ RecurrenceDescriptor::isRecurrenceInstr(Instruction *I, RecurKind Kind,
|
||||||
case Instruction::FCmp:
|
case Instruction::FCmp:
|
||||||
case Instruction::ICmp:
|
case Instruction::ICmp:
|
||||||
if (isIntMinMaxRecurrenceKind(Kind) ||
|
if (isIntMinMaxRecurrenceKind(Kind) ||
|
||||||
(FMF.noNaNs() && FMF.noSignedZeros() &&
|
(FMF.noNaNs() && FMF.noSignedZeros() && isFPMinMaxRecurrenceKind(Kind)))
|
||||||
isFPMinMaxRecurrenceKind(Kind)))
|
|
||||||
return isMinMaxSelectCmpPattern(I, Prev);
|
return isMinMaxSelectCmpPattern(I, Prev);
|
||||||
return InstDesc(false, I);
|
return InstDesc(false, I);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue