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

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 07:25:11 PDT 2016


Phab shows the wrong context for my last comment, and I see that the inline
comment before that one never hit the mailing list.

For the sake of the mailing list:

> "Not all value are true or false, so matching what is NOT true is not the
same as matching false."

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);


On Mon, Aug 8, 2016 at 8:19 AM, Sanjay Patel <spatel at rotateright.com> wrote:

> spatel 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() &&
> ----------------
> 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);
>
>
>
> https://reviews.llvm.org/D23134
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160808/c3460ba5/attachment.html>


More information about the llvm-commits mailing list