[llvm] [SDAG] fix miss opt: shl nuw + zext adds unnecessary masking (PR #172046)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 08:59:41 PST 2025
================
@@ -1673,8 +1673,10 @@ SDValue DAGCombiner::PromoteIntShiftOp(SDValue Op) {
SDLoc DL(Op);
SDValue N1 = Op.getOperand(1);
- SDValue RV =
- DAG.getNode(ISD::TRUNCATE, DL, VT, DAG.getNode(Opc, DL, PVT, N0, N1));
+ SDValue POp = DAG.getNode(Opc, DL, PVT, N0, N1);
+ if (Opc == ISD::SHL && Op->getFlags().hasNoUnsignedWrap())
+ POp = DAG.getNode(ISD::AssertZext, DL, PVT, POp, DAG.getValueType(VT));
----------------
arsenm wrote:
Shouldn't introduce a new assert zext in a combine; it will only get in the way of future combines. Isn't this equivalent to adding NUW to the TRUNCATE?
https://github.com/llvm/llvm-project/pull/172046
More information about the llvm-commits
mailing list