static void normalizePredicate(ScalarEvolution *SE, Loop *L,
LoopICmp& RC) {
- // LFTR canonicalizes checks to the ICMP_NE form instead of an ULT/SLT form.
- // Normalize back to the ULT/SLT form for ease of handling.
- if (RC.Pred == ICmpInst::ICMP_NE &&
+ // LFTR canonicalizes checks to the ICMP_NE/EQ form; normalize back to the
+ // ULT/UGE form for ease of handling by our caller.
+ if (ICmpInst::isEquality(RC.Pred) &&
RC.IV->getStepRecurrence(*SE)->isOne() &&
SE->isKnownPredicate(ICmpInst::ICMP_ULE, RC.IV->getStart(), RC.Limit))
- RC.Pred = ICmpInst::ICMP_ULT;
- if (RC.Pred == ICmpInst::ICMP_EQ &&
- RC.IV->getStepRecurrence(*SE)->isOne() &&
- SE->isKnownPredicate(ICmpInst::ICMP_ULE, RC.IV->getStart(), RC.Limit))
- RC.Pred = ICmpInst::ICMP_UGE;
-
+ RC.Pred = RC.Pred == ICmpInst::ICMP_NE ?
+ ICmpInst::ICMP_ULT : ICmpInst::ICMP_UGE;
}