Skip to content

Commit 68805de

Browse files
committed
[IVDesc] Reuse getBinOpIdentity in getRecurrenceIdentity [nfc]
Avoid duplication so that we can easily tell these lists are in sync.
1 parent 348e741 commit 68805de

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,28 +1040,13 @@ Value *RecurrenceDescriptor::getRecurrenceIdentity(RecurKind K, Type *Tp,
10401040
case RecurKind::Xor:
10411041
case RecurKind::Add:
10421042
case RecurKind::Or:
1043-
// Adding, Xoring, Oring zero to a number does not change it.
1044-
return ConstantInt::get(Tp, 0);
10451043
case RecurKind::Mul:
1046-
// Multiplying a number by 1 does not change it.
1047-
return ConstantInt::get(Tp, 1);
10481044
case RecurKind::And:
1049-
// AND-ing a number with an all-1 value does not change it.
1050-
return ConstantInt::get(Tp, -1, true);
10511045
case RecurKind::FMul:
1052-
// Multiplying a number by 1 does not change it.
1053-
return ConstantFP::get(Tp, 1.0L);
1054-
case RecurKind::FMulAdd:
10551046
case RecurKind::FAdd:
1056-
// Adding zero to a number does not change it.
1057-
// FIXME: Ideally we should not need to check FMF for FAdd and should always
1058-
// use -0.0. However, this will currently result in mixed vectors of 0.0/-0.0.
1059-
// Instead, we should ensure that 1) the FMF from FAdd are propagated to the PHI
1060-
// nodes where possible, and 2) PHIs with the nsz flag + -0.0 use 0.0. This would
1061-
// mean we can then remove the check for noSignedZeros() below (see D98963).
1062-
if (FMF.noSignedZeros())
1063-
return ConstantFP::get(Tp, 0.0L);
1064-
return ConstantFP::get(Tp, -0.0L);
1047+
return ConstantExpr::getBinOpIdentity(getOpcode(K), Tp, false, FMF.noSignedZeros());
1048+
case RecurKind::FMulAdd:
1049+
return ConstantExpr::getBinOpIdentity(Instruction::FAdd, Tp, false, FMF.noSignedZeros());
10651050
case RecurKind::UMin:
10661051
return ConstantInt::get(Tp, -1, true);
10671052
case RecurKind::UMax:

0 commit comments

Comments
 (0)