llvm.org GIT mirror llvm / ce09bda
R600: Handle fnearbyint The difference from rint isn't really relevant here, so treat them as equivalent. OpenCL doesn't have nearbyint, so this is sort of pointless other than for completeness. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211229 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 5 years ago
3 changed file(s) with 70 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
324324 setOperationAction(ISD::FTRUNC, VT, Expand);
325325 setOperationAction(ISD::FMUL, VT, Expand);
326326 setOperationAction(ISD::FRINT, VT, Expand);
327 setOperationAction(ISD::FNEARBYINT, VT, Expand);
327328 setOperationAction(ISD::FSQRT, VT, Expand);
328329 setOperationAction(ISD::FSIN, VT, Expand);
329330 setOperationAction(ISD::FSUB, VT, Expand);
332333 setOperationAction(ISD::VSELECT, VT, Expand);
333334 setOperationAction(ISD::FCOPYSIGN, VT, Expand);
334335 }
336
337 setOperationAction(ISD::FNEARBYINT, MVT::f32, Custom);
338 setOperationAction(ISD::FNEARBYINT, MVT::f64, Custom);
335339
336340 setTargetDAGCombine(ISD::MUL);
337341 setTargetDAGCombine(ISD::SELECT_CC);
500504 case ISD::FCEIL: return LowerFCEIL(Op, DAG);
501505 case ISD::FTRUNC: return LowerFTRUNC(Op, DAG);
502506 case ISD::FRINT: return LowerFRINT(Op, DAG);
507 case ISD::FNEARBYINT: return LowerFNEARBYINT(Op, DAG);
503508 case ISD::FFLOOR: return LowerFFLOOR(Op, DAG);
504509 case ISD::UINT_TO_FP: return LowerUINT_TO_FP(Op, DAG);
505510
16801685 SDValue Cond = DAG.getSetCC(SL, SetCCVT, Fabs, C2, ISD::SETOGT);
16811686
16821687 return DAG.getSelect(SL, MVT::f64, Cond, Src, Tmp2);
1688 }
1689
1690 SDValue AMDGPUTargetLowering::LowerFNEARBYINT(SDValue Op, SelectionDAG &DAG) const {
1691 // FNEARBYINT and FRINT are the same, except in their handling of FP
1692 // exceptions. Those aren't really meaningful for us, and OpenCL only has
1693 // rint, so just treat them as equivalent.
1694 return DAG.getNode(ISD::FRINT, SDLoc(Op), Op.getValueType(), Op.getOperand(0));
16831695 }
16841696
16851697 SDValue AMDGPUTargetLowering::LowerFFLOOR(SDValue Op, SelectionDAG &DAG) const {
5353 SDValue LowerFCEIL(SDValue Op, SelectionDAG &DAG) const;
5454 SDValue LowerFTRUNC(SDValue Op, SelectionDAG &DAG) const;
5555 SDValue LowerFRINT(SDValue Op, SelectionDAG &DAG) const;
56 SDValue LowerFNEARBYINT(SDValue Op, SelectionDAG &DAG) const;
5657 SDValue LowerFFLOOR(SDValue Op, SelectionDAG &DAG) const;
5758
5859 SDValue LowerUINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
0 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s
1 ; RUN: llc -march=r600 -mcpu=bonaire -verify-machineinstrs < %s
2
3 ; This should have the exactly the same output as the test for rint,
4 ; so no need to check anything.
5
6 declare float @llvm.nearbyint.f32(float) #0
7 declare <2 x float> @llvm.nearbyint.v2f32(<2 x float>) #0
8 declare <4 x float> @llvm.nearbyint.v4f32(<4 x float>) #0
9 declare double @llvm.nearbyint.f64(double) #0
10 declare <2 x double> @llvm.nearbyint.v2f64(<2 x double>) #0
11 declare <4 x double> @llvm.nearbyint.v4f64(<4 x double>) #0
12
13
14 define void @fnearbyint_f32(float addrspace(1)* %out, float %in) #1 {
15 entry:
16 %0 = call float @llvm.nearbyint.f32(float %in)
17 store float %0, float addrspace(1)* %out
18 ret void
19 }
20
21 define void @fnearbyint_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %in) #1 {
22 entry:
23 %0 = call <2 x float> @llvm.nearbyint.v2f32(<2 x float> %in)
24 store <2 x float> %0, <2 x float> addrspace(1)* %out
25 ret void
26 }
27
28 define void @fnearbyint_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %in) #1 {
29 entry:
30 %0 = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %in)
31 store <4 x float> %0, <4 x float> addrspace(1)* %out
32 ret void
33 }
34
35 define void @nearbyint_f64(double addrspace(1)* %out, double %in) {
36 entry:
37 %0 = call double @llvm.nearbyint.f64(double %in)
38 store double %0, double addrspace(1)* %out
39 ret void
40 }
41 define void @nearbyint_v2f64(<2 x double> addrspace(1)* %out, <2 x double> %in) {
42 entry:
43 %0 = call <2 x double> @llvm.nearbyint.v2f64(<2 x double> %in)
44 store <2 x double> %0, <2 x double> addrspace(1)* %out
45 ret void
46 }
47
48 define void @nearbyint_v4f64(<4 x double> addrspace(1)* %out, <4 x double> %in) {
49 entry:
50 %0 = call <4 x double> @llvm.nearbyint.v4f64(<4 x double> %in)
51 store <4 x double> %0, <4 x double> addrspace(1)* %out
52 ret void
53 }
54
55 attributes #0 = { nounwind readonly }
56 attributes #1 = { nounwind }