[PATCH] D22918: [Loop Vectorizer] Support predication of div/rem
Ayal Zaks via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 10 06:33:42 PDT 2016
Ayal added inline comments.
================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:3400
@@ -3392,1 +3399,3 @@
+ Cost += TTI.getCFInstrCost(Instruction::PHI);
Cost += TTI.getVectorInstrCost(Instruction::InsertElement, Ty, I);
+ }
----------------
Suggest to first add the cost of the InsertElement and then the (optional) cost of the Phi, just to keep things in the same order they will be executed. Furthermore, cost if Extract should precede that of Insert.
================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:4346-4347
@@ +4345,4 @@
+ I.getOpcode() == Instruction::SRem) && "Unexpected instruction");
+ Value *Op2 = I.getOperand(1);
+ ConstantInt *CInt = dyn_cast<ConstantInt>(Op2);
+ return !CInt || CInt->isZero();
----------------
Suggest to rename Op2 to Divisor.
It may be worthwhile to generalize and check isKnownNonZero(). Non-zero divisors that are not compile-time constants will not be converted into multiplication, so we will still end up scalarizing the division, but can do so w/o predication.
https://reviews.llvm.org/D22918
More information about the llvm-commits
mailing list