[llvm] [IR] Add nowrap flags for trunc instruction (PR #85592)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 24 04:28:07 PDT 2024
================
@@ -420,6 +420,15 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
break;
}
case Instruction::Trunc: {
+ unsigned SrcBitWidth = I->getOperand(0)->getType()->getScalarSizeInBits();
+ APInt InputDemandedMask = DemandedMask.zextOrTrunc(SrcBitWidth);
+ KnownBits InputKnown(SrcBitWidth);
+ if (SimplifyDemandedBits(I, 0, InputDemandedMask, InputKnown, Depth + 1)) {
+ // We may drop the nowrap flags
+ I->dropPoisonGeneratingFlags();
+ return I;
+ }
----------------
nikic wrote:
This addition doesn't make sense to me -- we need to drop flags on existing transforms, not add a new one. But we actually already *do* drop flags because we fall through to zext below, which already has poison-flag handling for nneg. So actually everything is fine here without changes, and just the test addition is enough.
https://github.com/llvm/llvm-project/pull/85592
More information about the llvm-commits
mailing list