File: simd-extending-convert.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (149 lines) | stat: -rw-r--r-- 6,210 bytes parent folder | download | duplicates (2)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mattr=+simd128 | FileCheck %s

; TODO: These tests should check that floating point conversions select
; extending instructions where possible

target triple = "wasm32-unknown-unknown"

define <4 x float> @extend_to_float_low_i16x8_u(<8 x i16> %x) {
; CHECK-LABEL: extend_to_float_low_i16x8_u:
; CHECK:         .functype extend_to_float_low_i16x8_u (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32x4.extend_low_i16x8_u
; CHECK-NEXT:    f32x4.convert_i32x4_u
; CHECK-NEXT:    # fallthrough-return
  %low = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %extended = uitofp <4 x i16> %low to <4 x float>
  ret <4 x float> %extended
}

define <4 x float> @extend_to_float_high_i16x8_u(<8 x i16> %x) {
; CHECK-LABEL: extend_to_float_high_i16x8_u:
; CHECK:         .functype extend_to_float_high_i16x8_u (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32x4.extend_high_i16x8_u
; CHECK-NEXT:    f32x4.convert_i32x4_u
; CHECK-NEXT:    # fallthrough-return
  %high = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
  %extended = uitofp <4 x i16> %high to <4 x float>
  ret <4 x float> %extended
}

define <4 x float> @extend_to_float_low_i8x16_u(<8 x i8> %x) {
; CHECK-LABEL: extend_to_float_low_i8x16_u:
; CHECK:         .functype extend_to_float_low_i8x16_u (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    v128.const 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i8x16.shuffle 16, 1, 2, 3, 17, 5, 6, 7, 18, 9, 10, 11, 19, 13, 14, 15
; CHECK-NEXT:    f32x4.convert_i32x4_u
; CHECK-NEXT:    # fallthrough-return
  %low = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %extended = uitofp <4 x i8> %low to <4 x float>
  ret <4 x float> %extended
}

define <4 x float> @extend_to_float_high_i8x16_u(<8 x i8> %x) {
; CHECK-LABEL: extend_to_float_high_i8x16_u:
; CHECK:         .functype extend_to_float_high_i8x16_u (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    v128.const 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
; CHECK-NEXT:    i8x16.shuffle 4, 17, 18, 19, 5, 21, 22, 23, 6, 25, 26, 27, 7, 29, 30, 31
; CHECK-NEXT:    f32x4.convert_i32x4_u
; CHECK-NEXT:    # fallthrough-return
  %high = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
  %extended = uitofp <4 x i8> %high to <4 x float>
  ret <4 x float> %extended
}

define <4 x float> @extend_to_float_low_i16x8_s(<8 x i16> %x) {
; CHECK-LABEL: extend_to_float_low_i16x8_s:
; CHECK:         .functype extend_to_float_low_i16x8_s (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32x4.extend_low_i16x8_s
; CHECK-NEXT:    f32x4.convert_i32x4_s
; CHECK-NEXT:    # fallthrough-return
  %low = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %extended = sitofp <4 x i16> %low to <4 x float>
  ret <4 x float> %extended
}

define <4 x float> @extend_to_float_high_i16x8_s(<8 x i16> %x) {
; CHECK-LABEL: extend_to_float_high_i16x8_s:
; CHECK:         .functype extend_to_float_high_i16x8_s (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i32x4.extend_high_i16x8_s
; CHECK-NEXT:    f32x4.convert_i32x4_s
; CHECK-NEXT:    # fallthrough-return
  %high = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
  %extended = sitofp <4 x i16> %high to <4 x float>
  ret <4 x float> %extended
}

define <4 x float> @extend_to_float_low_i8x16_s(<8 x i8> %x) {
; CHECK-LABEL: extend_to_float_low_i8x16_s:
; CHECK:         .functype extend_to_float_low_i8x16_s (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i8x16.shuffle 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0
; CHECK-NEXT:    i32.const 24
; CHECK-NEXT:    i32x4.shl
; CHECK-NEXT:    i32.const 24
; CHECK-NEXT:    i32x4.shr_s
; CHECK-NEXT:    f32x4.convert_i32x4_s
; CHECK-NEXT:    # fallthrough-return
  %low = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %extended = sitofp <4 x i8> %low to <4 x float>
  ret <4 x float> %extended
}

define <4 x float> @extend_to_float_high_i8x16_s(<8 x i8> %x) {
; CHECK-LABEL: extend_to_float_high_i8x16_s:
; CHECK:         .functype extend_to_float_high_i8x16_s (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i8x16.shuffle 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0
; CHECK-NEXT:    i32.const 24
; CHECK-NEXT:    i32x4.shl
; CHECK-NEXT:    i32.const 24
; CHECK-NEXT:    i32x4.shr_s
; CHECK-NEXT:    f32x4.convert_i32x4_s
; CHECK-NEXT:    # fallthrough-return
  %high = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
  %extended = sitofp <4 x i8> %high to <4 x float>
  ret <4 x float> %extended
}

define <2 x double> @extend_to_double_low_i32x4_u(<4 x i32> %x) {
; CHECK-LABEL: extend_to_double_low_i32x4_u:
; CHECK:         .functype extend_to_double_low_i32x4_u (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    f64x2.convert_low_i32x4_u
; CHECK-NEXT:    # fallthrough-return
  %low = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> <i32 0, i32 1>
  %extended = uitofp <2 x i32> %low to <2 x double>
  ret <2 x double> %extended
}

define <2 x double> @extend_to_double_low_i16x4_u(<4 x i16> %x) {
; CHECK-LABEL: extend_to_double_low_i16x4_u:
; CHECK:         .functype extend_to_double_low_i16x4_u (v128) -> (v128)
; CHECK-NEXT:  # %bb.0:
; CHECK-NEXT:    v128.const 0, 0, 0, 0, 0, 0, 0, 0
; CHECK-NEXT:    local.get 0
; CHECK-NEXT:    i8x16.shuffle 16, 17, 2, 3, 18, 19, 6, 7, 20, 21, 10, 11, 22, 23, 14, 15
; CHECK-NEXT:    f64x2.convert_low_i32x4_u
; CHECK-NEXT:    # fallthrough-return
  %low = shufflevector <4 x i16> %x, <4 x i16> undef, <2 x i32> <i32 0, i32 1>
  %extended = uitofp <2 x i16> %low to <2 x double>
  ret <2 x double> %extended
}