[llvm-branch-commits] [llvm] release/20.x: [X86] Do not combine LRINT and TRUNC (#125848) (PR #125995)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Feb 5 19:48:33 PST 2025
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/125995
Backport 8c222c122f1a8edb1be96e482511ad547f7db7b3
Requested by: @phoebewang
>From 442ca17b8ef073b71f2947e4b7a6b4b3df44283b Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Thu, 6 Feb 2025 10:58:37 +0800
Subject: [PATCH] [X86] Do not combine LRINT and TRUNC (#125848)
Per to discussions in #125324, most participants are opposed to this
optimization. So remove the combination to address the concerns.
Fixes #125324
(cherry picked from commit 8c222c122f1a8edb1be96e482511ad547f7db7b3)
---
llvm/lib/Target/X86/X86ISelLowering.cpp | 5 -----
llvm/test/CodeGen/X86/lrint-conv-i64.ll | 18 ++++++++++++++++++
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 8f904209d8a3ad9..627cef9ead7ffac 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -53899,11 +53899,6 @@ static SDValue combineTruncate(SDNode *N, SelectionDAG &DAG,
return DAG.getNode(X86ISD::MMX_MOVD2W, DL, MVT::i32, BCSrc);
}
- // Try to combine (trunc (vNi64 (lrint x))) to (vNi32 (lrint x)).
- if (Src.getOpcode() == ISD::LRINT && VT.getScalarType() == MVT::i32 &&
- Src.hasOneUse())
- return DAG.getNode(ISD::LRINT, DL, VT, Src.getOperand(0));
-
return SDValue();
}
diff --git a/llvm/test/CodeGen/X86/lrint-conv-i64.ll b/llvm/test/CodeGen/X86/lrint-conv-i64.ll
index 01b0af2f807f200..38fa09085e1898d 100644
--- a/llvm/test/CodeGen/X86/lrint-conv-i64.ll
+++ b/llvm/test/CodeGen/X86/lrint-conv-i64.ll
@@ -45,6 +45,24 @@ entry:
ret i64 %0
}
+define i32 @PR125324(float %x) {
+; SSE-LABEL: PR125324:
+; SSE: # %bb.0: # %entry
+; SSE-NEXT: cvtss2si %xmm0, %rax
+; SSE-NEXT: # kill: def $eax killed $eax killed $rax
+; SSE-NEXT: retq
+;
+; AVX-LABEL: PR125324:
+; AVX: # %bb.0: # %entry
+; AVX-NEXT: vcvtss2si %xmm0, %rax
+; AVX-NEXT: # kill: def $eax killed $eax killed $rax
+; AVX-NEXT: retq
+entry:
+ %0 = tail call i64 @llvm.lrint.i64.f32(float %x)
+ %1 = trunc i64 %0 to i32
+ ret i32 %1
+}
+
declare i64 @llvm.lrint.i64.f32(float) nounwind readnone
declare i64 @llvm.lrint.i64.f64(double) nounwind readnone
declare i64 @llvm.lrint.i64.f80(x86_fp80) nounwind readnone
More information about the llvm-branch-commits
mailing list