@@ -1040,28 +1040,13 @@ Value *RecurrenceDescriptor::getRecurrenceIdentity(RecurKind K, Type *Tp,
1040
1040
case RecurKind::Xor:
1041
1041
case RecurKind::Add:
1042
1042
case RecurKind::Or:
1043
- // Adding, Xoring, Oring zero to a number does not change it.
1044
- return ConstantInt::get (Tp, 0 );
1045
1043
case RecurKind::Mul:
1046
- // Multiplying a number by 1 does not change it.
1047
- return ConstantInt::get (Tp, 1 );
1048
1044
case RecurKind::And:
1049
- // AND-ing a number with an all-1 value does not change it.
1050
- return ConstantInt::get (Tp, -1 , true );
1051
1045
case RecurKind::FMul:
1052
- // Multiplying a number by 1 does not change it.
1053
- return ConstantFP::get (Tp, 1 .0L );
1054
- case RecurKind::FMulAdd:
1055
1046
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 ());
1065
1050
case RecurKind::UMin:
1066
1051
return ConstantInt::get (Tp, -1 , true );
1067
1052
case RecurKind::UMax:
0 commit comments