[llvm] [SDAG] Fix type checks in `ShrinkDemandedOp` to avoid creating invalid truncates (PR #92730)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 04:44:33 PDT 2024
================
@@ -599,7 +599,11 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned BitWidth,
for (unsigned SmallVTBits = llvm::bit_ceil(DemandedSize);
SmallVTBits < BitWidth; SmallVTBits = NextPowerOf2(SmallVTBits)) {
EVT SmallVT = EVT::getIntegerVT(*DAG.getContext(), SmallVTBits);
- if (TLI.isTruncateFree(VT, SmallVT) && TLI.isZExtFree(SmallVT, VT)) {
+ // Types of LHS and RHS may differ before legalization (e.g., shl), so we
+ // need to check both.
+ if (TLI.isTruncateFree(Op.getOperand(0).getValueType(), SmallVT) &&
+ TLI.isTruncateFree(Op.getOperand(1).getValueType(), SmallVT) &&
----------------
arsenm wrote:
Don't understand the diff from the description. isTruncateFree can't guard against invalid transforms
https://github.com/llvm/llvm-project/pull/92730
More information about the llvm-commits
mailing list