llvm.org GIT mirror llvm / a3d05d4
[GlobalISel][X86] Add the support for G_FPTRUNC Differential Revision: https://reviews.llvm.org/D49855 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341202 91177308-0d34-0410-b5e6-96231b3b80d8 Alexander Ivchenko 1 year, 11 months ago
6 changed file(s) with 141 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
304304 setAction({G_FPEXT, s64}, Legal);
305305 setAction({G_FPEXT, 1, s32}, Legal);
306306
307 setAction({G_FPTRUNC, s32}, Legal);
308 setAction({G_FPTRUNC, 1, s64}, Legal);
309
307310 // Constants
308311 setAction({TargetOpcode::G_FCONSTANT, s64}, Legal);
309312
193193
194194 switch (Opc) {
195195 case TargetOpcode::G_FPEXT:
196 case TargetOpcode::G_FPTRUNC:
196197 case TargetOpcode::G_FCONSTANT:
197198 // Instruction having only floating-point operands (all scalars in VECRReg)
198199 getInstrPartialMappingIdxs(MI, MRI, /* isFP */ true, OpRegBankIdx);
0 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
1 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefix=ALL
2 --- |
3
4 define float @test_fptrunc(double %in) {
5 %res = fptrunc double %in to float
6 ret float %res
7 }
8
9 ...
10 ---
11 name: test_fptrunc
12 alignment: 4
13 tracksRegLiveness: true
14 registers:
15 - { id: 0, class: _ }
16 - { id: 1, class: _ }
17 - { id: 2, class: _ }
18 - { id: 3, class: _ }
19 body: |
20 bb.1 (%ir-block.0):
21 liveins: $xmm0
22
23 ; ALL-LABEL: name: test_fptrunc
24 ; ALL: liveins: $xmm0
25 ; ALL: [[COPY:%[0-9]+]]:_(s128) = COPY $xmm0
26 ; ALL: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[COPY]](s128)
27 ; ALL: [[FPTRUNC:%[0-9]+]]:_(s32) = G_FPTRUNC [[TRUNC]](s64)
28 ; ALL: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[FPTRUNC]](s32)
29 ; ALL: $xmm0 = COPY [[ANYEXT]](s128)
30 ; ALL: RET 0, implicit $xmm0
31 %1:_(s128) = COPY $xmm0
32 %0:_(s64) = G_TRUNC %1(s128)
33 %2:_(s32) = G_FPTRUNC %0(s64)
34 %3:_(s128) = G_ANYEXT %2(s32)
35 $xmm0 = COPY %3(s128)
36 RET 0, implicit $xmm0
37
38 ...
235235 entry:
236236 %conv = fpext float %a to double
237237 ret double %conv
238 }
239
240 define float @test_fptrunc(double %a) {
241 entry:
242 %conv = fptrunc double %a to float
243 ret float %conv
238244 }
239245
240246 define void @test_fconstant() {
20122018
20132019 ...
20142020 ---
2021 name: test_fptrunc
2022 alignment: 4
2023 legalized: true
2024 tracksRegLiveness: true
2025 registers:
2026 - { id: 0, class: _ }
2027 - { id: 1, class: _ }
2028 - { id: 2, class: _ }
2029 - { id: 3, class: _ }
2030 body: |
2031 bb.1.entry:
2032 liveins: $xmm0
2033
2034 ; FAST-LABEL: name: test_fptrunc
2035 ; FAST: liveins: $xmm0
2036 ; FAST: [[COPY:%[0-9]+]]:vecr(s128) = COPY $xmm0
2037 ; FAST: [[TRUNC:%[0-9]+]]:vecr(s64) = G_TRUNC [[COPY]](s128)
2038 ; FAST: [[FPTRUNC:%[0-9]+]]:vecr(s32) = G_FPTRUNC [[TRUNC]](s64)
2039 ; FAST: [[ANYEXT:%[0-9]+]]:vecr(s128) = G_ANYEXT [[FPTRUNC]](s32)
2040 ; FAST: $xmm0 = COPY [[ANYEXT]](s128)
2041 ; FAST: RET 0, implicit $xmm0
2042 ; GREEDY-LABEL: name: test_fptrunc
2043 ; GREEDY: liveins: $xmm0
2044 ; GREEDY: [[COPY:%[0-9]+]]:vecr(s128) = COPY $xmm0
2045 ; GREEDY: [[TRUNC:%[0-9]+]]:vecr(s64) = G_TRUNC [[COPY]](s128)
2046 ; GREEDY: [[FPTRUNC:%[0-9]+]]:vecr(s32) = G_FPTRUNC [[TRUNC]](s64)
2047 ; GREEDY: [[ANYEXT:%[0-9]+]]:vecr(s128) = G_ANYEXT [[FPTRUNC]](s32)
2048 ; GREEDY: $xmm0 = COPY [[ANYEXT]](s128)
2049 ; GREEDY: RET 0, implicit $xmm0
2050 %1:_(s128) = COPY $xmm0
2051 %0:_(s64) = G_TRUNC %1(s128)
2052 %2:_(s32) = G_FPTRUNC %0(s64)
2053 %3:_(s128) = G_ANYEXT %2(s32)
2054 $xmm0 = COPY %3(s128)
2055 RET 0, implicit $xmm0
2056
2057 ...
2058 ---
20152059 name: test_fconstant
20162060 # ALL-LABEL: name: test_fconstant
20172061 legalized: true
0 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
1 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=ALL
2 --- |
3
4 define float @test_fptrunc(double %in) {
5 %res = fptrunc double %in to float
6 ret float %res
7 }
8
9 ...
10 ---
11 name: test_fptrunc
12 alignment: 4
13 legalized: true
14 regBankSelected: true
15 tracksRegLiveness: true
16 registers:
17 - { id: 0, class: vecr }
18 - { id: 1, class: vecr }
19 - { id: 2, class: vecr }
20 - { id: 3, class: vecr }
21 body: |
22 bb.1 (%ir-block.0):
23 liveins: $xmm0
24
25 ; ALL-LABEL: name: test_fptrunc
26 ; ALL: liveins: $xmm0
27 ; ALL: [[COPY:%[0-9]+]]:vr128 = COPY $xmm0
28 ; ALL: [[COPY1:%[0-9]+]]:fr64 = COPY [[COPY]]
29 ; ALL: [[CVTSD2SSrr:%[0-9]+]]:fr32 = CVTSD2SSrr [[COPY1]]
30 ; ALL: [[COPY2:%[0-9]+]]:vr128 = COPY [[CVTSD2SSrr]]
31 ; ALL: $xmm0 = COPY [[COPY2]]
32 ; ALL: RET 0, implicit $xmm0
33 %1:vecr(s128) = COPY $xmm0
34 %0:vecr(s64) = G_TRUNC %1(s128)
35 %2:vecr(s32) = G_FPTRUNC %0(s64)
36 %3:vecr(s128) = G_ANYEXT %2(s32)
37 $xmm0 = COPY %3(s128)
38 RET 0, implicit $xmm0
39
40 ...
184184 %res = sdiv i64 %arg1, %arg2
185185 ret i64 %res
186186 }
187 define float @test_fptrunc(double %in) {
188 ; CHECK-LABEL: name: test_fptrunc
189 ; CHECK: bb.1 (%ir-block.0):
190 ; CHECK: liveins: $xmm0
191 ; CHECK: [[COPY:%[0-9]+]]:_(s128) = COPY $xmm0
192 ; CHECK: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[COPY]](s128)
193 ; CHECK: [[FPTRUNC:%[0-9]+]]:_(s32) = G_FPTRUNC [[TRUNC]](s64)
194 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[FPTRUNC]](s32)
195 ; CHECK: $xmm0 = COPY [[ANYEXT]](s128)
196 ; CHECK: RET 0, implicit $xmm0
197 %res = fptrunc double %in to float
198 ret float %res
199 }