File: fdiv_combine.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (126 lines) | stat: -rw-r--r-- 3,908 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=aarch64-linux-gnu -aarch64-neon-syntax=apple -verify-machineinstrs -o - %s | FileCheck %s

; Test signed conversion.
define <2 x float> @test1(<2 x i32> %in) {
; CHECK-LABEL: test1:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    scvtf.2s v0, v0, #4
; CHECK-NEXT:    ret
entry:
  %vcvt.i = sitofp <2 x i32> %in to <2 x float>
  %div.i = fdiv <2 x float> %vcvt.i, <float 16.0, float 16.0>
  ret <2 x float> %div.i
}

; Test unsigned conversion.
define <2 x float> @test2(<2 x i32> %in) {
; CHECK-LABEL: test2:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    ucvtf.2s v0, v0, #3
; CHECK-NEXT:    ret
entry:
  %vcvt.i = uitofp <2 x i32> %in to <2 x float>
  %div.i = fdiv <2 x float> %vcvt.i, <float 8.0, float 8.0>
  ret <2 x float> %div.i
}

; Test which should not fold due to non-power of 2.
define <2 x float> @test3(<2 x i32> %in) {
; CHECK-LABEL: test3:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    fmov.2s v1, #9.00000000
; CHECK-NEXT:    scvtf.2s v0, v0
; CHECK-NEXT:    fdiv.2s v0, v0, v1
; CHECK-NEXT:    ret
entry:
  %vcvt.i = sitofp <2 x i32> %in to <2 x float>
  %div.i = fdiv <2 x float> %vcvt.i, <float 9.0, float 9.0>
  ret <2 x float> %div.i
}

; Test which should not fold due to power of 2 out of range.
define <2 x float> @test4(<2 x i32> %in) {
; CHECK-LABEL: test4:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    movi.2s v1, #80, lsl #24
; CHECK-NEXT:    scvtf.2s v0, v0
; CHECK-NEXT:    fdiv.2s v0, v0, v1
; CHECK-NEXT:    ret
entry:
  %vcvt.i = sitofp <2 x i32> %in to <2 x float>
  %div.i = fdiv <2 x float> %vcvt.i, <float 0x4200000000000000, float 0x4200000000000000>
  ret <2 x float> %div.i
}

; Test case where const is max power of 2 (i.e., 2^32).
define <2 x float> @test5(<2 x i32> %in) {
; CHECK-LABEL: test5:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    scvtf.2s v0, v0, #32
; CHECK-NEXT:    ret
entry:
  %vcvt.i = sitofp <2 x i32> %in to <2 x float>
  %div.i = fdiv <2 x float> %vcvt.i, <float 0x41F0000000000000, float 0x41F0000000000000>
  ret <2 x float> %div.i
}

; Test quadword.
define <4 x float> @test6(<4 x i32> %in) {
; CHECK-LABEL: test6:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    scvtf.4s v0, v0, #2
; CHECK-NEXT:    ret
entry:
  %vcvt.i = sitofp <4 x i32> %in to <4 x float>
  %div.i = fdiv <4 x float> %vcvt.i, <float 4.0, float 4.0, float 4.0, float 4.0>
  ret <4 x float> %div.i
}

; Test unsigned i16 to float
define <4 x float> @test7(<4 x i16> %in) {
; CHECK-LABEL: test7:
; CHECK:       // %bb.0:
; CHECK-NEXT:    ushll.4s v0, v0, #0
; CHECK-NEXT:    ucvtf.4s v0, v0, #1
; CHECK-NEXT:    ret
  %conv = uitofp <4 x i16> %in to <4 x float>
  %shift = fdiv <4 x float> %conv, <float 2.0, float 2.0, float 2.0, float 2.0>
  ret <4 x float> %shift
}

; Test signed i16 to float
define <4 x float> @test8(<4 x i16> %in) {
; CHECK-LABEL: test8:
; CHECK:       // %bb.0:
; CHECK-NEXT:    sshll.4s v0, v0, #0
; CHECK-NEXT:    scvtf.4s v0, v0, #2
; CHECK-NEXT:    ret
  %conv = sitofp <4 x i16> %in to <4 x float>
  %shift = fdiv <4 x float> %conv, <float 4.0, float 4.0, float 4.0, float 4.0>
  ret <4 x float> %shift
}

; Can't convert i64 to float.
define <2 x float> @test9(<2 x i64> %in) {
; CHECK-LABEL: test9:
; CHECK:       // %bb.0:
; CHECK-NEXT:    ucvtf.2d v0, v0
; CHECK-NEXT:    movi.2s v1, #64, lsl #24
; CHECK-NEXT:    fcvtn v0.2s, v0.2d
; CHECK-NEXT:    fdiv.2s v0, v0, v1
; CHECK-NEXT:    ret
  %conv = uitofp <2 x i64> %in to <2 x float>
  %shift = fdiv <2 x float> %conv, <float 2.0, float 2.0>
  ret <2 x float> %shift
}

define <2 x double> @test10(<2 x i64> %in) {
; CHECK-LABEL: test10:
; CHECK:       // %bb.0:
; CHECK-NEXT:    ucvtf.2d v0, v0, #1
; CHECK-NEXT:    ret
  %conv = uitofp <2 x i64> %in to <2 x double>
  %shift = fdiv <2 x double> %conv, <double 2.0, double 2.0>
  ret <2 x double> %shift
}