Skip to content

Commit 7013638

Browse files
committed
[DAG] Add support for nneg flag with uitofp
Copy `nneg` flag when building `UINT_TO_FP` from `uitofp` and use `nneg` flag in the one place we transform `UINT_TO_FP` -> `SINT_TO_FP` if the operand is non-negative.
1 parent 84a5332 commit 7013638

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3882,7 +3882,11 @@ void SelectionDAGBuilder::visitUIToFP(const User &I) {
38823882
SDValue N = getValue(I.getOperand(0));
38833883
EVT DestVT = DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
38843884
I.getType());
3885-
setValue(&I, DAG.getNode(ISD::UINT_TO_FP, getCurSDLoc(), DestVT, N));
3885+
SDNodeFlags Flags;
3886+
if (auto *PNI = dyn_cast<PossiblyNonNegInst>(&I))
3887+
Flags.setNonNeg(PNI->hasNonNeg());
3888+
3889+
setValue(&I, DAG.getNode(ISD::UINT_TO_FP, getCurSDLoc(), DestVT, N, Flags));
38863890
}
38873891

38883892
void SelectionDAGBuilder::visitSIToFP(const User &I) {

0 commit comments

Comments
 (0)