Skip to content

Commit 0fc5f4b

Browse files
authored
[DAG] Set nneg flag when forming zext in demanded bits (#72281)
We do the same for the analogous transform in DAGCombine, but this case was missed in the recent patch which added support for zext nneg. Sorry for the lack of test coverage. Not sure how to exercise this piece of logic. It appears to have only minimal impact on LIT tests (only test/CodeGen/X86/wide-scalar-shift-by-byte-multiple-legalization.ll), and even then, the changes without it appear uninteresting. Maybe we should remove this transform instead?
1 parent 2747193 commit 0fc5f4b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,8 +2483,12 @@ bool TargetLowering::SimplifyDemandedBits(
24832483
if (Known.isNonNegative()) {
24842484
unsigned Opc =
24852485
IsVecInReg ? ISD::ZERO_EXTEND_VECTOR_INREG : ISD::ZERO_EXTEND;
2486-
if (!TLO.LegalOperations() || isOperationLegal(Opc, VT))
2487-
return TLO.CombineTo(Op, TLO.DAG.getNode(Opc, dl, VT, Src));
2486+
if (!TLO.LegalOperations() || isOperationLegal(Opc, VT)) {
2487+
SDNodeFlags Flags;
2488+
if (!IsVecInReg)
2489+
Flags.setNonNeg(true);
2490+
return TLO.CombineTo(Op, TLO.DAG.getNode(Opc, dl, VT, Src, Flags));
2491+
}
24882492
}
24892493

24902494
// Attempt to avoid multi-use ops if we don't need anything from them.

0 commit comments

Comments
 (0)