[llvm] [IR][DAG] Add support for `nneg` flag with `uitofp` (PR #86141)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 12:29:08 PDT 2024
================
@@ -3882,7 +3882,15 @@ 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));
+ bool IsNonNeg = false;
+ if (auto *PNI = dyn_cast<PossiblyNonNegInst>(&I))
+ IsNonNeg = true;
+
+ unsigned Opc = ISD::UINT_TO_FP;
+ if (IsNonNeg && DAG.getTargetLoweringInfo().isSIToFPCheaperThanUIToFP(
----------------
tschuett wrote:
Do you need to do the optimization in the builder or leave it to the combiner? The IRBuilder blindly copies flags:
https://github.com/llvm/llvm-project/blob/22e7e68a40b8b1aac8b44137685d21ac4b98bd17/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp#L300
https://github.com/llvm/llvm-project/pull/86141
More information about the llvm-commits
mailing list