[llvm] r331975 - [InstCombine] Only propagate known leading zeros from udiv input to output.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Thu May 10 04:45:18 PDT 2018
Author: d0k
Date: Thu May 10 04:45:18 2018
New Revision: 331975
URL: http://llvm.org/viewvc/llvm-project?rev=331975&view=rev
Log:
[InstCombine] Only propagate known leading zeros from udiv input to output.
Put in a conservatively correct estimate for now. Avoids miscompiling
clang in FDO mode. This is really tricky to trigger in reality as
basically all interesting cases will be folded away by computeKnownBits
earlier, I was unable to find a reasonably small test case.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=331975&r1=331974&r2=331975&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Thu May 10 04:45:18 2018
@@ -554,10 +554,15 @@ Value *InstCombiner::SimplifyDemandedUse
break;
// FIXME: Take the demanded mask of the result into account.
+ unsigned RHSTrailingZeros = SA->countTrailingZeros();
APInt DemandedMaskIn =
- APInt::getHighBitsSet(BitWidth, BitWidth - SA->countTrailingZeros());
- if (SimplifyDemandedBits(I, 0, DemandedMaskIn, Known, Depth + 1))
+ APInt::getHighBitsSet(BitWidth, BitWidth - RHSTrailingZeros);
+ if (SimplifyDemandedBits(I, 0, DemandedMaskIn, LHSKnown, Depth + 1))
return I;
+
+ // Propagate zero bits from the input.
+ Known.Zero.setHighBits(std::min(
+ BitWidth, LHSKnown.Zero.countLeadingOnes() + RHSTrailingZeros));
}
break;
}
More information about the llvm-commits
mailing list