[llvm] [LLVM][CodeGen] When expanding ISD::LRINT, non-deterministic results should be frozen. (PR #197435)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Wed May 13 06:18:15 PDT 2026
https://github.com/paulwalker-arm created https://github.com/llvm/llvm-project/pull/197435
This comes from https://github.com/llvm/llvm-project/pull/194342#discussion_r3155677450.
>From 1a8ceee529f8d6ec9dc62bdbe6fb1675d676286c Mon Sep 17 00:00:00 2001
From: Paul Walker <paul.walker at arm.com>
Date: Wed, 13 May 2026 13:10:39 +0000
Subject: [PATCH] [LLVM][CodeGen] When expanding ISD::LRINT non-deterministic
results should be frozen.
---
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 9e4f169cd4f3f..dca1a0b58c16a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -4636,9 +4636,11 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
SDValue Arg = Node->getOperand(0);
EVT ArgVT = Arg.getValueType();
EVT ResVT = Node->getValueType(0);
- SDLoc dl(Node);
- SDValue RoundNode = DAG.getNode(ISD::FRINT, dl, ArgVT, Arg);
- Results.push_back(DAG.getNode(ISD::FP_TO_SINT, dl, ResVT, RoundNode));
+ SDLoc DL(Node);
+ SDValue RoundNode = DAG.getNode(ISD::FRINT, DL, ArgVT, Arg);
+ SDValue ConvertNode = DAG.getNode(ISD::FP_TO_SINT, DL, ResVT, RoundNode);
+ // Non-deterministic results are equivalent to freeze poison.
+ Results.push_back(DAG.getFreeze(ConvertNode));
break;
}
case ISD::ADDRSPACECAST:
More information about the llvm-commits
mailing list