@@ -49,8 +49,7 @@ bool RecurrenceDescriptor::isIntegerRecurrenceKind(RecurKind Kind) {
49
49
case RecurKind::SMin:
50
50
case RecurKind::UMax:
51
51
case RecurKind::UMin:
52
- case RecurKind::IAnyOf:
53
- case RecurKind::FAnyOf:
52
+ case RecurKind::AnyOf:
54
53
case RecurKind::IFindLastIV:
55
54
case RecurKind::FFindLastIV:
56
55
return true ;
@@ -417,11 +416,11 @@ bool RecurrenceDescriptor::AddReductionVar(
417
416
if (IsAPhi && Cur != Phi && !areAllUsesIn (Cur, VisitedInsts))
418
417
return false ;
419
418
420
- if ((isIntMinMaxRecurrenceKind (Kind) || Kind == RecurKind::IAnyOf) &&
421
- (isa<ICmpInst>(Cur) || isa<SelectInst>(Cur)))
419
+ if ((isIntMinMaxRecurrenceKind (Kind) &&
420
+ (isa<ICmpInst>(Cur) || IsASelect)) ||
421
+ (isFPMinMaxRecurrenceKind (Kind) && (isa<FCmpInst>(Cur) || IsASelect)))
422
422
++NumCmpSelectPatternInst;
423
- if ((isFPMinMaxRecurrenceKind (Kind) || Kind == RecurKind::FAnyOf) &&
424
- (isa<FCmpInst>(Cur) || isa<SelectInst>(Cur)))
423
+ if (isAnyOfRecurrenceKind (Kind) && IsASelect)
425
424
++NumCmpSelectPatternInst;
426
425
427
426
// Check whether we found a reduction operator.
@@ -656,8 +655,7 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
656
655
if (!Loop->isLoopInvariant (NonPhi))
657
656
return InstDesc (false , I);
658
657
659
- return InstDesc (I, isa<ICmpInst>(I->getOperand (0 )) ? RecurKind::IAnyOf
660
- : RecurKind::FAnyOf);
658
+ return InstDesc (I, RecurKind::AnyOf);
661
659
}
662
660
663
661
// We are looking for loops that do something like this:
@@ -979,10 +977,10 @@ bool RecurrenceDescriptor::isReductionPHI(PHINode *Phi, Loop *TheLoop,
979
977
LLVM_DEBUG (dbgs () << " Found a UMIN reduction PHI." << *Phi << " \n " );
980
978
return true ;
981
979
}
982
- if (AddReductionVar (Phi, RecurKind::IAnyOf , TheLoop, FMF, RedDes, DB, AC, DT,
980
+ if (AddReductionVar (Phi, RecurKind::AnyOf , TheLoop, FMF, RedDes, DB, AC, DT,
983
981
SE)) {
984
- LLVM_DEBUG (dbgs () << " Found an integer conditional select reduction PHI."
985
- << *Phi << " \n " );
982
+ LLVM_DEBUG (dbgs () << " Found an conditional select reduction PHI." << *Phi
983
+ << " \n " );
986
984
return true ;
987
985
}
988
986
if (AddReductionVar (Phi, RecurKind::IFindLastIV, TheLoop, FMF, RedDes, DB, AC,
@@ -1014,12 +1012,6 @@ bool RecurrenceDescriptor::isReductionPHI(PHINode *Phi, Loop *TheLoop,
1014
1012
LLVM_DEBUG (dbgs () << " Found a float MIN reduction PHI." << *Phi << " \n " );
1015
1013
return true ;
1016
1014
}
1017
- if (AddReductionVar (Phi, RecurKind::FAnyOf, TheLoop, FMF, RedDes, DB, AC, DT,
1018
- SE)) {
1019
- LLVM_DEBUG (dbgs () << " Found a float conditional select reduction PHI."
1020
- << " PHI." << *Phi << " \n " );
1021
- return true ;
1022
- }
1023
1015
if (AddReductionVar (Phi, RecurKind::FMulAdd, TheLoop, FMF, RedDes, DB, AC, DT,
1024
1016
SE)) {
1025
1017
LLVM_DEBUG (dbgs () << " Found an FMulAdd reduction PHI." << *Phi << " \n " );
@@ -1127,7 +1119,7 @@ bool RecurrenceDescriptor::isFixedOrderRecurrence(PHINode *Phi, Loop *TheLoop,
1127
1119
return true ;
1128
1120
}
1129
1121
1130
- unsigned RecurrenceDescriptor::getOpcode (RecurKind Kind) {
1122
+ unsigned RecurrenceDescriptor::getOpcode (RecurKind Kind, Type *Ty ) {
1131
1123
switch (Kind) {
1132
1124
case RecurKind::Add:
1133
1125
return Instruction::Add;
@@ -1148,16 +1140,16 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
1148
1140
case RecurKind::SMin:
1149
1141
case RecurKind::UMax:
1150
1142
case RecurKind::UMin:
1151
- case RecurKind::IAnyOf:
1152
1143
case RecurKind::IFindLastIV:
1153
1144
return Instruction::ICmp;
1154
1145
case RecurKind::FMax:
1155
1146
case RecurKind::FMin:
1156
1147
case RecurKind::FMaximum:
1157
1148
case RecurKind::FMinimum:
1158
- case RecurKind::FAnyOf:
1159
1149
case RecurKind::FFindLastIV:
1160
1150
return Instruction::FCmp;
1151
+ case RecurKind::AnyOf:
1152
+ return Ty->isIntegerTy () ? Instruction::ICmp : Instruction::FCmp;
1161
1153
default :
1162
1154
llvm_unreachable (" Unknown recurrence operation" );
1163
1155
}
0 commit comments