File: vcvt_combine.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (72 lines) | stat: -rw-r--r-- 2,285 bytes parent folder | download | duplicates (29)
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
; RUN: llc < %s -mtriple=armv7-apple-ios | FileCheck %s

; Test signed conversion.
; CHECK-LABEL: @t0
; CHECK: vcvt.s32.f32 d{{[0-9]+}}, d{{[0-9]+}}, #2
; CHECK: bx lr
define <2 x i32> @t0(<2 x float> %in) {
  %mul.i = fmul <2 x float> %in, <float 4.0, float 4.0>
  %vcvt.i = fptosi <2 x float> %mul.i to <2 x i32>
  ret <2 x i32> %vcvt.i
}

; Test unsigned conversion.
; CHECK-LABEL: @t1
; CHECK: vcvt.u32.f32 d{{[0-9]+}}, d{{[0-9]+}}, #3
; CHECK: bx lr
define <2 x i32> @t1(<2 x float> %in) {
  %mul.i = fmul <2 x float> %in, <float 8.0, float 8.0>
  %vcvt.i = fptoui <2 x float> %mul.i to <2 x i32>
  ret <2 x i32> %vcvt.i
}

; Test which should not fold due to non-power of 2.
; CHECK-LABEL: @t2
; CHECK: vmul
; CHECK: vcvt.s32.f32 d{{[0-9]+}}, d{{[0-9]+}}
; CHECK: bx lr
define <2 x i32> @t2(<2 x float> %in) {
entry:
  %mul.i = fmul <2 x float> %in, <float 0x401B333340000000, float 0x401B333340000000>
  %vcvt.i = fptosi <2 x float> %mul.i to <2 x i32>
  ret <2 x i32> %vcvt.i
}

; Test which should not fold due to power of 2 out of range.
; CHECK-LABEL: @t3
; CHECK: vmul
; CHECK: vcvt.s32.f32 d{{[0-9]+}}, d{{[0-9]+}}
; CHECK: bx lr
define <2 x i32> @t3(<2 x float> %in) {
  %mul.i = fmul <2 x float> %in, <float 0x4200000000000000, float 0x4200000000000000>
  %vcvt.i = fptosi <2 x float> %mul.i to <2 x i32>
  ret <2 x i32> %vcvt.i
}

; Test which case where const is max power of 2 (i.e., 2^32).
; CHECK-LABEL: @t4
; CHECK: vcvt.s32.f32 d{{[0-9]+}}, d{{[0-9]+}}, #32
; CHECK: bx lr
define <2 x i32> @t4(<2 x float> %in) {
  %mul.i = fmul <2 x float> %in, <float 0x41F0000000000000, float 0x41F0000000000000>
  %vcvt.i = fptosi <2 x float> %mul.i to <2 x i32>
  ret <2 x i32> %vcvt.i
}

; Test quadword.
; CHECK-LABEL: @t5
; CHECK: vcvt.s32.f32 q{{[0-9]+}}, q{{[0-9]+}}, #3
; CHECK: bx lr
define <4 x i32> @t5(<4 x float> %in) {
  %mul.i = fmul <4 x float> %in, <float 8.0, float 8.0, float 8.0, float 8.0>
  %vcvt.i = fptosi <4 x float> %mul.i to <4 x i32>
  ret <4 x i32> %vcvt.i
}

; CHECK-LABEL: test_illegal_fp_to_int:
; CHECK: vcvt.s32.f32 {{q[0-9]+}}, {{q[0-9]+}}, #2
define <3 x i32> @test_illegal_fp_to_int(<3 x float> %in) {
  %scale = fmul <3 x float> %in, <float 4.0, float 4.0, float 4.0>
  %val = fptosi <3 x float> %scale to <3 x i32>
  ret <3 x i32> %val
}