[llvm] 7013638 - [DAG] Add support for `nneg` flag with `uitofp`
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 21:07:10 PDT 2024
Author: Noah Goldstein
Date: 2024-04-09T23:06:55-05:00
New Revision: 70136389788b90c2e6bbaef5ad8bb0285d460068
URL: https://github.com/llvm/llvm-project/commit/70136389788b90c2e6bbaef5ad8bb0285d460068
DIFF: https://github.com/llvm/llvm-project/commit/70136389788b90c2e6bbaef5ad8bb0285d460068.diff
LOG: [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.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 4ba27157ec1c6e..3f69f7ad54477e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3882,7 +3882,11 @@ void SelectionDAGBuilder::visitUIToFP(const User &I) {
SDValue N = getValue(I.getOperand(0));
EVT DestVT = DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
I.getType());
- setValue(&I, DAG.getNode(ISD::UINT_TO_FP, getCurSDLoc(), DestVT, N));
+ SDNodeFlags Flags;
+ if (auto *PNI = dyn_cast<PossiblyNonNegInst>(&I))
+ Flags.setNonNeg(PNI->hasNonNeg());
+
+ setValue(&I, DAG.getNode(ISD::UINT_TO_FP, getCurSDLoc(), DestVT, N, Flags));
}
void SelectionDAGBuilder::visitSIToFP(const User &I) {
More information about the llvm-commits
mailing list