[llvm] AMDGPU: Simplify synthesis of nextdown(1.0) constant (PR #189039)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 09:10:07 PDT 2026


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/189039

None

>From 893b11fb74c376ad809be288a6d268aaa940ddb7 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 27 Mar 2026 17:09:08 +0100
Subject: [PATCH] AMDGPU: Simplify synthesis of nextdown(1.0) constant

---
 llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
index 79c6a50d77aec..fe5624d824f94 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
@@ -2052,13 +2052,11 @@ Value *AMDGPUCodeGenPrepareImpl::matchFractPat(IntrinsicInst &I) {
   if (!match(Arg1, m_APFloatAllowPoison(C)))
     return nullptr;
 
-  APFloat One(1.0);
-  bool LosesInfo;
-  One.convert(C->getSemantics(), APFloat::rmNearestTiesToEven, &LosesInfo);
+  APFloat OneNextDown = APFloat::getOne(C->getSemantics());
+  OneNextDown.next(true);
 
   // Match nextafter(1.0, -1)
-  One.next(true);
-  if (One != *C)
+  if (OneNextDown != *C)
     return nullptr;
 
   Value *FloorSrc;



More information about the llvm-commits mailing list