[PATCH] D23134: Make cltz and cttz zero undef when the operand cannot be zero in InstCombine

Amaury SECHET via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 08:19:07 PDT 2016


deadalnix added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:1283-1296
@@ -1268,16 +1282,16 @@
 
 /// CallInst simplification. This mostly only handles folding of intrinsic
 /// instructions. For normal calls, it allows visitCallSite to do the heavy
 /// lifting.
 Instruction *InstCombiner::visitCallInst(CallInst &CI) {
   auto Args = CI.arg_operands();
   if (Value *V = SimplifyCall(CI.getCalledValue(), Args.begin(), Args.end(), DL,
                               &TLI, &DT, &AC))
     return replaceInstUsesWith(CI, V);
 
   if (isFreeCall(&CI, &TLI))
     return visitFree(CI);
 
   // If the caller function is nounwind, mark the call as nounwind, even if the
   // callee isn't.
   if (CI.getParent()->getParent()->doesNotThrow() &&
----------------
spatel wrote:
> Sorry for still not seeing it...can you add test case to show the difference?
> 
> AFAICT, the undef param of these intrinsics must be an i1 true/false constant?
> 
>   case Intrinsic::ctlz:  // llvm.ctlz
>   case Intrinsic::cttz:  // llvm.cttz
>     Assert(isa<ConstantInt>(CS.getArgOperand(1)),
>            "is_zero_undef argument of bit counting intrinsics must be a "
>            "constant int",
>            CS);
> 
I has no idea there was an assertion to make sure of this. I'd still go for the logic "if it is anything but true, make it true" rather than it "if it false, make it true".


https://reviews.llvm.org/D23134





More information about the llvm-commits mailing list