Skip to content

Commit 43e0891

Browse files
committed
Do not commit: merge ppc soft promotion change with lrint fix
2 parents a65aca6 + 06e92fa commit 43e0891

File tree

13 files changed

+167
-103
lines changed

13 files changed

+167
-103
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "LegalizeTypes.h"
2222
#include "llvm/Analysis/TargetLibraryInfo.h"
23+
#include "llvm/CodeGen/ISDOpcodes.h"
2324
#include "llvm/Support/ErrorHandling.h"
2425
#include "llvm/Support/raw_ostream.h"
2526
using namespace llvm;
@@ -3737,10 +3738,20 @@ bool DAGTypeLegalizer::SoftPromoteHalfOperand(SDNode *N, unsigned OpNo) {
37373738
Res = SoftPromoteHalfOp_FAKE_USE(N, OpNo);
37383739
break;
37393740
case ISD::FCOPYSIGN: Res = SoftPromoteHalfOp_FCOPYSIGN(N, OpNo); break;
3741+
case ISD::FP_TO_SINT:
3742+
case ISD::FP_TO_UINT:
3743+
case ISD::LLRINT:
3744+
case ISD::LLROUND:
3745+
case ISD::LRINT:
3746+
case ISD::LROUND:
37403747
case ISD::STRICT_FP_TO_SINT:
37413748
case ISD::STRICT_FP_TO_UINT:
3742-
case ISD::FP_TO_SINT:
3743-
case ISD::FP_TO_UINT: Res = SoftPromoteHalfOp_FP_TO_XINT(N); break;
3749+
case ISD::STRICT_LLRINT:
3750+
case ISD::STRICT_LLROUND:
3751+
case ISD::STRICT_LRINT:
3752+
case ISD::STRICT_LROUND:
3753+
Res = SoftPromoteHalfOp_FP_TO_XINT(N);
3754+
break;
37443755
case ISD::FP_TO_SINT_SAT:
37453756
case ISD::FP_TO_UINT_SAT:
37463757
Res = SoftPromoteHalfOp_FP_TO_XINT_SAT(N); break;

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
843843
SDValue SoftPromoteHalfOp_FAKE_USE(SDNode *N, unsigned OpNo);
844844
SDValue SoftPromoteHalfOp_FCOPYSIGN(SDNode *N, unsigned OpNo);
845845
SDValue SoftPromoteHalfOp_FP_EXTEND(SDNode *N);
846-
SDValue SoftPromoteHalfOp_FP_TO_XINT(SDNode *N);
846+
SDValue SoftPromoteHalfOp_UnaryOp(SDNode *N);
847847
SDValue SoftPromoteHalfOp_FP_TO_XINT_SAT(SDNode *N);
848848
SDValue SoftPromoteHalfOp_SETCC(SDNode *N);
849849
SDValue SoftPromoteHalfOp_SELECT_CC(SDNode *N, unsigned OpNo);

llvm/test/CodeGen/ARM/lrint-conv.ll

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
; RUN: llc < %s -mtriple=arm-eabi -float-abi=soft | FileCheck %s --check-prefix=SOFTFP
22
; RUN: llc < %s -mtriple=arm-eabi -float-abi=hard | FileCheck %s --check-prefix=HARDFP
33

4-
; FIXME: crash
5-
; define i32 @testmswh_builtin(half %x) {
6-
; entry:
7-
; %0 = tail call i32 @llvm.lrint.i32.f16(half %x)
8-
; ret i32 %0
9-
; }
4+
; SOFTFP-LABEL: testmswh_builtin:
5+
; SOFTFP: bl lrintf
6+
; HARDFP-LABEL: testmswh_builtin:
7+
; HARDFP: bl lrintf
8+
define i32 @testmswh_builtin(half %x) {
9+
entry:
10+
%0 = tail call i32 @llvm.lrint.i32.f16(half %x)
11+
ret i32 %0
12+
}
1013

1114
; SOFTFP-LABEL: testmsws_builtin:
1215
; SOFTFP: bl lrintf

llvm/test/CodeGen/LoongArch/lrint-conv.ll

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@
55
; RUN: sed 's/ITy/i32/g' %s | llc -mtriple=loongarch64 | FileCheck %s --check-prefixes=LA64-I32
66
; RUN: sed 's/ITy/i64/g' %s | llc -mtriple=loongarch64 | FileCheck %s --check-prefixes=LA64-I64
77

8-
; FIXME: crash
9-
; define ITy @test_lrint_ixx_f16(half %x) nounwind {
10-
; %res = tail call ITy @llvm.lrint.ITy.f16(half %x)
11-
; ret ITy %res
12-
; }
8+
define ITy @test_lrint_ixx_f16(half %x) nounwind {
9+
; LA32-LABEL: test_lrint_ixx_f16:
10+
; LA32: bl lrintf
11+
;
12+
; LA64-I32-LABEL: test_lrint_ixx_f16:
13+
; LA64-I32: pcaddu18i $ra, %call36(lrintf)
14+
;
15+
; LA64-I64-LABEL: test_lrint_ixx_f16:
16+
; LA64-I64: pcaddu18i $t8, %call36(lrintf)
17+
%res = tail call ITy @llvm.lrint.ITy.f16(half %x)
18+
ret ITy %res
19+
}
1320

14-
; define ITy @test_llrint_ixx_f16(half %x) nounwind {
15-
; %res = tail call ITy @llvm.llrint.ITy.f16(half %x)
16-
; ret ITy %res
17-
; }
21+
define ITy @test_llrint_ixx_f16(half %x) nounwind {
22+
; LA32-LABEL: test_llrint_ixx_f16:
23+
; LA32: bl llrintf
24+
;
25+
; LA64-I32-LABEL: test_llrint_ixx_f16:
26+
; LA64-I32: pcaddu18i $ra, %call36(llrintf)
27+
;
28+
; LA64-I64-LABEL: test_llrint_ixx_f16:
29+
; LA64-I64: pcaddu18i $t8, %call36(llrintf)
30+
%res = tail call ITy @llvm.llrint.ITy.f16(half %x)
31+
ret ITy %res
32+
}
1833

1934
define ITy @test_lrint_ixx_f32(float %x) nounwind {
2035
; LA32-LABEL: test_lrint_ixx_f32:

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
; RUN: llc < %s -mtriple=mips64el -mattr=+soft-float | FileCheck %s
22
; RUN: llc < %s -mtriple=mips -mattr=+soft-float | FileCheck %s
33

4-
; FIXME: crash
5-
; define signext i32 @testmswh(half %x) {
6-
; entry:
7-
; %0 = tail call i64 @llvm.llrint.i64.f16(half %x)
8-
; %conv = trunc i64 %0 to i32
9-
; ret i32 %conv
10-
; }
4+
define signext i32 @testmswh(half %x) {
5+
entry:
6+
%0 = tail call i64 @llvm.llrint.i64.f16(half %x)
7+
%conv = trunc i64 %0 to i32
8+
ret i32 %conv
9+
}
1110

12-
; define i64 @testmsxh(half %x) {
13-
; entry:
14-
; %0 = tail call i64 @llvm.llrint.i64.f16(half %x)
15-
; ret i64 %0
16-
; }
11+
define i64 @testmsxh(half %x) {
12+
entry:
13+
%0 = tail call i64 @llvm.llrint.i64.f16(half %x)
14+
ret i64 %0
15+
}
1716

1817
define signext i32 @testmsws(float %x) {
1918
; CHECK-LABEL: testmsws:

llvm/test/CodeGen/Mips/lrint-conv.ll

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
; RUN: llc < %s -mtriple=mips64el -mattr=+soft-float | FileCheck %s
22
; RUN: llc < %s -mtriple=mips -mattr=+soft-float | FileCheck %s
33

4-
; FIXME: crash
5-
; define signext i32 @testmswh(half %x) {
6-
; entry:
7-
; %0 = tail call i64 @llvm.lrint.i64.f16(half %x)
8-
; %conv = trunc i64 %0 to i32
9-
; ret i32 %conv
10-
; }
4+
define signext i32 @testmswh(half %x) {
5+
; CHECK-LABEL: testmswh:
6+
; CHECK: jal lrintf
7+
entry:
8+
%0 = tail call i64 @llvm.lrint.i64.f16(half %x)
9+
%conv = trunc i64 %0 to i32
10+
ret i32 %conv
11+
}
1112

12-
; define i64 @testmsxh(half %x) {
13-
; entry:
14-
; %0 = tail call i64 @llvm.lrint.i64.f16(half %x)
15-
; ret i64 %0
16-
; }
13+
define i64 @testmsxh(half %x) {
14+
; CHECK-LABEL: testmsxh:
15+
; CHECK: jal lrintf
16+
entry:
17+
%0 = tail call i64 @llvm.lrint.i64.f16(half %x)
18+
ret i64 %0
19+
}
1720

1821
define signext i32 @testmsws(float %x) {
1922
; CHECK-LABEL: testmsws:

llvm/test/CodeGen/RISCV/lrint-conv.ll

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@
55
; RUN: sed 's/ITy/i32/g' %s | llc -mtriple=riscv64 | FileCheck %s --check-prefixes=RV64
66
; RUN: sed 's/ITy/i64/g' %s | llc -mtriple=riscv64 | FileCheck %s --check-prefixes=RV64
77

8-
; FIXME: crash
9-
; define ITy @test_lrint_ixx_f16(half %x) nounwind {
10-
; %res = tail call ITy @llvm.lrint.ITy.f16(half %x)
11-
; }
8+
define ITy @test_lrint_ixx_f16(half %x) nounwind {
9+
; RV32-LABEL: test_lrint_ixx_f16:
10+
; RV32: call lrintf
11+
;
12+
; RV64-LABEL: test_lrint_ixx_f16:
13+
; RV64: call lrintf
14+
%res = tail call ITy @llvm.lrint.ITy.f16(half %x)
15+
ret ITy %res
16+
}
1217

13-
; define ITy @test_llrint_ixx_f16(half %x) nounwind {
14-
; %res = tail call ITy @llvm.llrint.ITy.f16(half %x)
15-
; }
18+
define ITy @test_llrint_ixx_f16(half %x) nounwind {
19+
; RV32-LABEL: test_llrint_ixx_f16:
20+
; RV32: call llrintf
21+
;
22+
; RV64-LABEL: test_llrint_ixx_f16:
23+
; RV64: call llrintf
24+
%res = tail call ITy @llvm.llrint.ITy.f16(half %x)
25+
ret ITy %res
26+
}
1627

1728
define ITy @test_lrint_ixx_f32(float %x) nounwind {
1829
; RV32-LABEL: test_lrint_ixx_f32:

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

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,44 @@
77
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx | FileCheck %s --check-prefixes=X64,X64-AVX
88
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx512f | FileCheck %s --check-prefixes=X64,X64-AVX
99

10-
; FIXME: crash
11-
; define i64 @test_llrint_i64_f16(half %x) nounwind {
12-
; entry:
13-
; %0 = tail call i64 @llvm.llrint.i64.f16(half %x)
14-
; ret i64 %0
15-
; }
10+
define i64 @test_llrint_i64_f16(half %x) nounwind {
11+
; X86-NOSSE-LABEL: test_llrint_i64_f16:
12+
; X86-NOSSE: # %bb.0: # %entry
13+
; X86-NOSSE-NEXT: pushl %eax
14+
; X86-NOSSE-NEXT: movzwl {{[0-9]+}}(%esp), %eax
15+
; X86-NOSSE-NEXT: movl %eax, (%esp)
16+
; X86-NOSSE-NEXT: calll __extendhfsf2
17+
; X86-NOSSE-NEXT: fstps (%esp)
18+
; X86-NOSSE-NEXT: calll llrintf
19+
; X86-NOSSE-NEXT: popl %ecx
20+
; X86-NOSSE-NEXT: retl
21+
;
22+
; X86-SSE2-LABEL: test_llrint_i64_f16:
23+
; X86-SSE2: # %bb.0: # %entry
24+
; X86-SSE2-NEXT: pushl %eax
25+
; X86-SSE2-NEXT: pinsrw $0, {{[0-9]+}}(%esp), %xmm0
26+
; X86-SSE2-NEXT: pextrw $0, %xmm0, %eax
27+
; X86-SSE2-NEXT: movw %ax, (%esp)
28+
; X86-SSE2-NEXT: calll __extendhfsf2
29+
; X86-SSE2-NEXT: fstps (%esp)
30+
; X86-SSE2-NEXT: calll llrintf
31+
; X86-SSE2-NEXT: popl %ecx
32+
; X86-SSE2-NEXT: retl
33+
;
34+
; X64-SSE-LABEL: test_llrint_i64_f16:
35+
; X64-SSE: # %bb.0: # %entry
36+
; X64-SSE-NEXT: pushq %rax
37+
; X64-SSE-NEXT: callq __extendhfsf2@PLT
38+
; X64-SSE-NEXT: callq rintf@PLT
39+
; X64-SSE-NEXT: callq __truncsfhf2@PLT
40+
; X64-SSE-NEXT: callq __extendhfsf2@PLT
41+
; X64-SSE-NEXT: cvttss2si %xmm0, %rax
42+
; X64-SSE-NEXT: popq %rcx
43+
; X64-SSE-NEXT: retq
44+
entry:
45+
%0 = tail call i64 @llvm.llrint.i64.f16(half %x)
46+
ret i64 %0
47+
}
1648

1749
define i64 @test_llrint_i64_f32(float %x) nounwind {
1850
; X86-NOSSE-LABEL: test_llrint_i64_f32:
@@ -217,12 +249,11 @@ entry:
217249
ret i64 %0
218250
}
219251

220-
; FIXME: crash
221-
; define i64 @test_llrint_i64_f16_strict(half %x) nounwind strictfp {
222-
; entry:
223-
; %0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f16(half %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
224-
; ret i64 %0
225-
; }
252+
define i64 @test_llrint_i64_f16_strict(half %x) nounwind strictfp {
253+
entry:
254+
%0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f16(half %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
255+
ret i64 %0
256+
}
226257

227258
define i64 @test_llrint_i64_f32_strict(float %x) nounwind strictfp {
228259
; X86-NOSSE-LABEL: test_llrint_i64_f32_strict:

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86
66
; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64
77

8-
; FIXME: crash
9-
; define i64 @test_llround_f16(half %x) nounwind {
10-
; %conv = tail call i64 @llvm.llround.f16(half %x)
11-
; ret i64 %conv
12-
; }
8+
define i64 @test_llround_f16(half %x) nounwind {
9+
%conv = tail call i64 @llvm.llround.f16(half %x)
10+
ret i64 %conv
11+
}
1312

1413
define i64 @test_llround_f32(float %x) nounwind {
1514
; X86-NOSSE-LABEL: test_llround_f32:
@@ -184,11 +183,10 @@ define i64 @test_llround_f128(fp128 %x) nounwind {
184183
ret i64 %conv
185184
}
186185

187-
; FIXME: crash
188-
; define i64 @test_llround_i64_f16(half %x) nounwind {
189-
; %conv = call i64 @llvm.llround.i64.f16(half %x)
190-
; ret i64 %conv
191-
; }
186+
define i64 @test_llround_i64_f16(half %x) nounwind {
187+
%conv = call i64 @llvm.llround.i64.f16(half %x)
188+
ret i64 %conv
189+
}
192190

193191
define i64 @test_llround_i64_f32(float %x) nounwind {
194192
; X86-NOSSE-LABEL: test_llround_i64_f32:

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx | FileCheck %s --check-prefixes=X64,X64-AVX
88
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx512f | FileCheck %s --check-prefixes=X64,X64-AVX
99

10-
; FIXME: crash
11-
; define i32 @test_lrint_i32_f16(half %x) nounwind {
12-
; entry:
13-
; %0 = tail call i32 @llvm.lrint.i32.f16(half %x)
14-
; ret i32 %0
15-
; }
10+
define i32 @test_lrint_i32_f16(half %x) nounwind {
11+
%conv = tail call i32 @llvm.lrint.i32.f16(half %x)
12+
ret i32 %conv
13+
}
1614

1715
define i32 @test_lrint_i32_f32(float %x) nounwind {
1816
; X86-NOSSE-LABEL: test_lrint_i32_f32:
@@ -154,11 +152,10 @@ define i32 @test_lrint_i32_f128(fp128 %x) nounwind {
154152
ret i32 %conv
155153
}
156154

157-
; FIXME: crash
158-
; define i32 @test_lrint_i32_f16_strict(half %x) nounwind strictfp {
159-
; %conv = tail call i32 @llvm.experimental.constrained.lrint.i32.f16(half %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
160-
; ret i32 %conv
161-
; }
155+
define i32 @test_lrint_i32_f16_strict(half %x) nounwind strictfp {
156+
%conv = tail call i32 @llvm.experimental.constrained.lrint.i32.f16(half %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
157+
ret i32 %conv
158+
}
162159

163160
define i32 @test_lrint_i32_f32_strict(float %x) nounwind strictfp {
164161
; X86-NOSSE-LABEL: test_lrint_i32_f32_strict:

0 commit comments

Comments
 (0)