[PATCH] D20289: [InstCombine] check vector elements before trying to transform LE/GE vector icmp (PR27756)
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 11:06:41 PDT 2016
majnemer added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:3165-3185
@@ +3164,23 @@
+ Constant *OneOrNegOne = nullptr;
+ switch (I.getPredicate()) {
+ case ICmpInst::ICMP_ULE:
+ if (!allElementsValid(Op1C, true, false))
+ return nullptr;
+ NewPred = ICmpInst::ICMP_ULT;
+ OneOrNegOne = ConstantInt::get(Op1Type, 1);
+ break;
+ case ICmpInst::ICMP_SLE:
+ if (!allElementsValid(Op1C, true, true))
+ return nullptr;
+ NewPred = ICmpInst::ICMP_SLT;
+ OneOrNegOne = ConstantInt::get(Op1Type, 1);
+ break;
+ case ICmpInst::ICMP_UGE:
+ if (!allElementsValid(Op1C, false, false))
+ return nullptr;
+ NewPred = ICmpInst::ICMP_UGT;
+ OneOrNegOne = ConstantInt::get(Op1Type, -1);
+ break;
+ case ICmpInst::ICMP_SGE:
+ if (!allElementsValid(Op1C, false, true))
+ return nullptr;
----------------
I'd recommend passing `I.isSigned()` in instead of hard-coding true/false. Makes it harder to make a mistake when updating this switch/case.
http://reviews.llvm.org/D20289
More information about the llvm-commits
mailing list