[llvm] [SDAG] Fix type checks in `ShrinkDemandedOp` to avoid creating invalid truncates (PR #92730)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 04:53:38 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) &&
----------------
dtcxzyw wrote:
> Don't understand the diff from the description. isTruncateFree can't guard against invalid transforms
Oops, it just so happens that all implementations of `XXXTargetLowering::isTruncateFree` guarantee this.
I will fix this.
https://github.com/llvm/llvm-project/pull/92730
More information about the llvm-commits
mailing list