Skip to content

Commit fc0ac26

Browse files
committed
Remove NoUnsignedWrap check
1 parent d170e8d commit fc0ac26

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53919,7 +53919,7 @@ static SDValue combineTruncate(SDNode *N, SelectionDAG &DAG,
5391953919
return DAG.getNode(X86ISD::MMX_MOVD2W, DL, MVT::i32, BCSrc);
5392053920
}
5392153921

53922-
if ((N->getFlags().hasNoUnsignedWrap() || N->getFlags().hasNoSignedWrap()) &&
53922+
if (N->getFlags().hasNoSignedWrap() &&
5392353923
(Src.getOpcode() == ISD::LRINT || Src.getOpcode() == ISD::LLRINT) &&
5392453924
VT.getScalarType() == MVT::i32 && Src.hasOneUse())
5392553925
return DAG.getNode(ISD::LRINT, DL, VT, Src.getOperand(0));

llvm/test/CodeGen/X86/llrint-conv.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ define i32 @combine_f64_trunc(double %x) nounwind {
249249
; X64-AVX-NEXT: retq
250250
entry:
251251
%0 = tail call i64 @llvm.llrint.f64(double %x)
252-
%1 = trunc nuw i64 %0 to i32
252+
%1 = trunc nsw i64 %0 to i32
253253
ret i32 %1
254254
}
255255

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

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,35 @@ entry:
6363
ret i32 %1
6464
}
6565

66-
define i32 @combine_f32_trunc(float %x) {
67-
; SSE-LABEL: combine_f32_trunc:
66+
define i32 @combine_f32_nsw_trunc(float %x) {
67+
; SSE-LABEL: combine_f32_nsw_trunc:
6868
; SSE: # %bb.0: # %entry
6969
; SSE-NEXT: cvtss2si %xmm0, %eax
7070
; SSE-NEXT: retq
7171
;
72-
; AVX-LABEL: combine_f32_trunc:
72+
; AVX-LABEL: combine_f32_nsw_trunc:
7373
; AVX: # %bb.0: # %entry
7474
; AVX-NEXT: vcvtss2si %xmm0, %eax
7575
; AVX-NEXT: retq
76+
entry:
77+
%0 = tail call i64 @llvm.lrint.i64.f32(float %x)
78+
%1 = trunc nsw i64 %0 to i32
79+
ret i32 %1
80+
}
81+
82+
;; Check we don't combine trunc when nuw.
83+
define i32 @not_combine_f32_nuw_trunc(float %x) {
84+
; SSE-LABEL: not_combine_f32_nuw_trunc:
85+
; SSE: # %bb.0: # %entry
86+
; SSE-NEXT: cvtss2si %xmm0, %rax
87+
; SSE-NEXT: # kill: def $eax killed $eax killed $rax
88+
; SSE-NEXT: retq
89+
;
90+
; AVX-LABEL: not_combine_f32_nuw_trunc:
91+
; AVX: # %bb.0: # %entry
92+
; AVX-NEXT: vcvtss2si %xmm0, %rax
93+
; AVX-NEXT: # kill: def $eax killed $eax killed $rax
94+
; AVX-NEXT: retq
7695
entry:
7796
%0 = tail call i64 @llvm.lrint.i64.f32(float %x)
7897
%1 = trunc nuw i64 %0 to i32
@@ -95,6 +114,22 @@ entry:
95114
ret i32 %1
96115
}
97116

117+
;; Check "movl %eax, %eax" is present.
118+
define i64 @zero_upperbits_softfloat(double %x) nounwind "target-features"="+soft-float" {
119+
; CHECK-LABEL: zero_upperbits_softfloat:
120+
; CHECK: # %bb.0: # %entry
121+
; CHECK-NEXT: pushq %rax
122+
; CHECK-NEXT: callq lrint@PLT
123+
; CHECK-NEXT: movl %eax, %eax
124+
; CHECK-NEXT: popq %rcx
125+
; CHECK-NEXT: retq
126+
entry:
127+
%0 = tail call i64 @llvm.lrint.i64.f64(double %x)
128+
%1 = trunc nsw i64 %0 to i32
129+
%2 = zext i32 %1 to i64
130+
ret i64 %2
131+
}
132+
98133
declare i64 @llvm.lrint.i64.f32(float) nounwind readnone
99134
declare i64 @llvm.lrint.i64.f64(double) nounwind readnone
100135
declare i64 @llvm.lrint.i64.f80(x86_fp80) nounwind readnone

llvm/test/CodeGen/X86/vector-lrint.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,6 @@ define <4 x i32> @llrint_v4i32_v4f32(<4 x float> %x) {
559559
; X64-AVX-i64-NEXT: vcvtps2dq %xmm0, %xmm0
560560
; X64-AVX-i64-NEXT: retq
561561
%a = call <4 x i64> @llvm.lrint.v4i64.v4f32(<4 x float> %x)
562-
%b = trunc nuw <4 x i64> %a to <4 x i32>
562+
%b = trunc nsw <4 x i64> %a to <4 x i32>
563563
ret <4 x i32> %b
564564
}

0 commit comments

Comments
 (0)