mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-20 16:17:38 +00:00
ComputeMaskedBits: Make knownzero computation more aggressive for ctlz with undef zero.
unsigned foo(unsigned x) { return 31 - __builtin_clz(x); }
now compiles into a single "bsrl" instruction on x86.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147255 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -714,9 +714,16 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
|
||||
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
|
||||
switch (II->getIntrinsicID()) {
|
||||
default: break;
|
||||
case Intrinsic::ctpop:
|
||||
case Intrinsic::ctlz:
|
||||
case Intrinsic::cttz: {
|
||||
unsigned LowBits = Log2_32(BitWidth)+1;
|
||||
// If this call is undefined for 0, the result will be less than 2^n.
|
||||
if (II->getArgOperand(1) == ConstantInt::getTrue(II->getContext()))
|
||||
LowBits -= 1;
|
||||
KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - LowBits);
|
||||
break;
|
||||
}
|
||||
case Intrinsic::ctpop: {
|
||||
unsigned LowBits = Log2_32(BitWidth)+1;
|
||||
KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - LowBits);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user