Skip to content

Commit 454d7c1

Browse files
phoebewangtstellar
authored andcommitted
[X86] Do not combine LRINT and TRUNC (llvm#125848)
Per to discussions in llvm#125324, most participants are opposed to this optimization. So remove the combination to address the concerns. Fixes llvm#125324 (cherry picked from commit 8c222c1)
1 parent 3c011c6 commit 454d7c1

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53899,11 +53899,6 @@ static SDValue combineTruncate(SDNode *N, SelectionDAG &DAG,
5389953899
return DAG.getNode(X86ISD::MMX_MOVD2W, DL, MVT::i32, BCSrc);
5390053900
}
5390153901

53902-
// Try to combine (trunc (vNi64 (lrint x))) to (vNi32 (lrint x)).
53903-
if (Src.getOpcode() == ISD::LRINT && VT.getScalarType() == MVT::i32 &&
53904-
Src.hasOneUse())
53905-
return DAG.getNode(ISD::LRINT, DL, VT, Src.getOperand(0));
53906-
5390753902
return SDValue();
5390853903
}
5390953904

llvm/test/CodeGen/X86/lrint-conv-i64.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ entry:
4545
ret i64 %0
4646
}
4747

48+
define i32 @PR125324(float %x) {
49+
; SSE-LABEL: PR125324:
50+
; SSE: # %bb.0: # %entry
51+
; SSE-NEXT: cvtss2si %xmm0, %rax
52+
; SSE-NEXT: # kill: def $eax killed $eax killed $rax
53+
; SSE-NEXT: retq
54+
;
55+
; AVX-LABEL: PR125324:
56+
; AVX: # %bb.0: # %entry
57+
; AVX-NEXT: vcvtss2si %xmm0, %rax
58+
; AVX-NEXT: # kill: def $eax killed $eax killed $rax
59+
; AVX-NEXT: retq
60+
entry:
61+
%0 = tail call i64 @llvm.lrint.i64.f32(float %x)
62+
%1 = trunc i64 %0 to i32
63+
ret i32 %1
64+
}
65+
4866
declare i64 @llvm.lrint.i64.f32(float) nounwind readnone
4967
declare i64 @llvm.lrint.i64.f64(double) nounwind readnone
5068
declare i64 @llvm.lrint.i64.f80(x86_fp80) nounwind readnone

0 commit comments

Comments
 (0)