assert(ISD && "Invalid opcode");
unsigned ExtraCost = 0;
- if (I && (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp)) {
+ if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
// Some vector comparison predicates cost extra instructions.
+ // TODO: Should we invert this and assume worst case cmp costs
+ // and reduce for particular predicates?
if (MTy.isVector() &&
!((ST->hasXOP() && (!ST->hasAVX2() || MTy.is128BitVector())) ||
(ST->hasAVX512() && 32 <= MTy.getScalarSizeInBits()) ||
ST->hasBWI())) {
- switch (cast<CmpInst>(I)->getPredicate()) {
+ // Fallback to I if a specific predicate wasn't specified.
+ CmpInst::Predicate Pred = VecPred;
+ if (I && (Pred == CmpInst::BAD_ICMP_PREDICATE ||
+ Pred == CmpInst::BAD_FCMP_PREDICATE))
+ Pred = cast<CmpInst>(I)->getPredicate();
+
+ switch (Pred) {
case CmpInst::Predicate::ICMP_NE:
// xor(cmpeq(x,y),-1)
ExtraCost = 1;