[PATCH] D28968: LoopUnswitch - Simplify based on known not to a be constant.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 17:42:36 PST 2017


efriedma added inline comments.


================
Comment at: lib/Transforms/Scalar/LoopUnswitch.cpp:1395
+    Value *Op1 = CI->getOperand(1);
+    if ((Op0 == Cond && Op1 == Val) || (Op0 == Val && Op1 == Cond)) {
+      LLVMContext &Ctx = Inst->getContext();
----------------
trentxintong wrote:
> efriedma wrote:
> > trentxintong wrote:
> > > efriedma wrote:
> > > > Missing check that Val is a ConstantInt.
> > > Val is going to be a ConstantInt, as its used by ICmpInst, I will add an assert though =).
> > It will  be a Constant of integer type... but that's not the same thing as a ConstantInt.  (For example `ptrtoint i32* @g to i64`. is a Constant of integer type.)
> I see. Thanks for pointing this out to me. But does Val have to be a constantInt here. What we know here is that the Cond != Val and we are trying to simplify a icmpinst, we are not getting the actual integer value of this constant.
> 
> Even though I think the Val is always going to be the constant int in the current state of pass.
Err, no, you're right... this particular transform works out even if Val isn't a ConstantInt, because you're checking for equality.

Sorry, I feel like I'm completely screwing up this review; I'll take another look tomorrow, and hopefully it's clearer then.


https://reviews.llvm.org/D28968





More information about the llvm-commits mailing list