File: exedepsfix-broadcast.ll

package info (click to toggle)
llvm-toolchain-3.7 1%3A3.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 345,556 kB
  • ctags: 362,199
  • sloc: cpp: 2,156,381; ansic: 458,339; objc: 91,547; python: 89,988; asm: 86,305; sh: 21,479; makefile: 6,853; perl: 5,601; ml: 5,458; pascal: 3,933; lisp: 2,429; xml: 686; cs: 239; php: 202; csh: 117
file content (129 lines) | stat: -rw-r--r-- 5,363 bytes parent folder | download | duplicates (3)
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
; RUN: llc -O3 -mtriple=x86_64-apple-macosx -o - < %s -mattr=+avx2 -enable-unsafe-fp-math -mcpu=core2 | FileCheck %s
; Check that the ExeDepsFix pass correctly fixes the domain for broadcast instructions.
; <rdar://problem/16354675>

; CHECK-LABEL: ExeDepsFix_broadcastss
; CHECK: broadcastss
; CHECK: vandps
; CHECK: vmaxps
; CHECK: ret
define <4 x float> @ExeDepsFix_broadcastss(<4 x float> %arg, <4 x float> %arg2) {
  %bitcast = bitcast <4 x float> %arg to <4 x i32>
  %and = and <4 x i32> %bitcast, <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>
  %floatcast = bitcast <4 x i32> %and to <4 x float>
  %max_is_x = fcmp oge <4 x float> %floatcast, %arg2
  %max = select <4 x i1> %max_is_x, <4 x float> %floatcast, <4 x float> %arg2
  ret <4 x float> %max
}

; CHECK-LABEL: ExeDepsFix_broadcastss256
; CHECK: broadcastss
; CHECK: vandps
; CHECK: vmaxps
; CHECK: ret
define <8 x float> @ExeDepsFix_broadcastss256(<8 x float> %arg, <8 x float> %arg2) {
  %bitcast = bitcast <8 x float> %arg to <8 x i32>
  %and = and <8 x i32> %bitcast, <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>
  %floatcast = bitcast <8 x i32> %and to <8 x float>
  %max_is_x = fcmp oge <8 x float> %floatcast, %arg2
  %max = select <8 x i1> %max_is_x, <8 x float> %floatcast, <8 x float> %arg2
  ret <8 x float> %max
}


; CHECK-LABEL: ExeDepsFix_broadcastss_inreg
; CHECK: broadcastss
; CHECK: vandps
; CHECK: vmaxps
; CHECK: ret
define <4 x float> @ExeDepsFix_broadcastss_inreg(<4 x float> %arg, <4 x float> %arg2, i32 %broadcastvalue) {
  %bitcast = bitcast <4 x float> %arg to <4 x i32>
  %in = insertelement <4 x i32> undef, i32 %broadcastvalue, i32 0
  %mask = shufflevector <4 x i32> %in, <4 x i32> undef, <4 x i32> zeroinitializer
  %and = and <4 x i32> %bitcast, %mask
  %floatcast = bitcast <4 x i32> %and to <4 x float>
  %max_is_x = fcmp oge <4 x float> %floatcast, %arg2
  %max = select <4 x i1> %max_is_x, <4 x float> %floatcast, <4 x float> %arg2
  ret <4 x float> %max
}

; CHECK-LABEL: ExeDepsFix_broadcastss256_inreg
; CHECK: broadcastss
; CHECK: vandps
; CHECK: vmaxps
; CHECK: ret
define <8 x float> @ExeDepsFix_broadcastss256_inreg(<8 x float> %arg, <8 x float> %arg2, i32 %broadcastvalue) {
  %bitcast = bitcast <8 x float> %arg to <8 x i32>
  %in = insertelement <8 x i32> undef, i32 %broadcastvalue, i32 0
  %mask = shufflevector <8 x i32> %in, <8 x i32> undef, <8 x i32> zeroinitializer
  %and = and <8 x i32> %bitcast, %mask
  %floatcast = bitcast <8 x i32> %and to <8 x float>
  %max_is_x = fcmp oge <8 x float> %floatcast, %arg2
  %max = select <8 x i1> %max_is_x, <8 x float> %floatcast, <8 x float> %arg2
  ret <8 x float> %max
}

; CHECK-LABEL: ExeDepsFix_broadcastsd
; In that case the broadcast is directly folded into vandpd.
; CHECK: vandpd
; CHECK: vmaxpd
; CHECK:ret
define <2 x double> @ExeDepsFix_broadcastsd(<2 x double> %arg, <2 x double> %arg2) {
  %bitcast = bitcast <2 x double> %arg to <2 x i64>
  %and = and <2 x i64> %bitcast, <i64 2147483647, i64 2147483647>
  %floatcast = bitcast <2 x i64> %and to <2 x double>
  %max_is_x = fcmp oge <2 x double> %floatcast, %arg2
  %max = select <2 x i1> %max_is_x, <2 x double> %floatcast, <2 x double> %arg2
  ret <2 x double> %max
}

; CHECK-LABEL: ExeDepsFix_broadcastsd256
; CHECK: broadcastsd
; CHECK: vandpd
; CHECK: vmaxpd
; CHECK: ret
define <4 x double> @ExeDepsFix_broadcastsd256(<4 x double> %arg, <4 x double> %arg2) {
  %bitcast = bitcast <4 x double> %arg to <4 x i64>
  %and = and <4 x i64> %bitcast, <i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647>
  %floatcast = bitcast <4 x i64> %and to <4 x double>
  %max_is_x = fcmp oge <4 x double> %floatcast, %arg2
  %max = select <4 x i1> %max_is_x, <4 x double> %floatcast, <4 x double> %arg2
  ret <4 x double> %max
}


; CHECK-LABEL: ExeDepsFix_broadcastsd_inreg
; ExeDepsFix works top down, thus it coalesces vpunpcklqdq domain with
; vpand and there is nothing more you can do to match vmaxpd.
; CHECK: vmovq
; CHECK: vpbroadcastq
; CHECK: vpand
; CHECK: vmaxpd
; CHECK: ret
define <2 x double> @ExeDepsFix_broadcastsd_inreg(<2 x double> %arg, <2 x double> %arg2, i64 %broadcastvalue) {
  %bitcast = bitcast <2 x double> %arg to <2 x i64>
  %in = insertelement <2 x i64> undef, i64 %broadcastvalue, i32 0
  %mask = shufflevector <2 x i64> %in, <2 x i64> undef, <2 x i32> zeroinitializer
  %and = and <2 x i64> %bitcast, %mask
  %floatcast = bitcast <2 x i64> %and to <2 x double>
  %max_is_x = fcmp oge <2 x double> %floatcast, %arg2
  %max = select <2 x i1> %max_is_x, <2 x double> %floatcast, <2 x double> %arg2
  ret <2 x double> %max
}

; CHECK-LABEL: ExeDepsFix_broadcastsd256_inreg
; CHECK: broadcastsd
; CHECK: vandpd
; CHECK: vmaxpd
; CHECK: ret
define <4 x double> @ExeDepsFix_broadcastsd256_inreg(<4 x double> %arg, <4 x double> %arg2, i64 %broadcastvalue) {
  %bitcast = bitcast <4 x double> %arg to <4 x i64>
  %in = insertelement <4 x i64> undef, i64 %broadcastvalue, i32 0
  %mask = shufflevector <4 x i64> %in, <4 x i64> undef, <4 x i32> zeroinitializer
  %and = and <4 x i64> %bitcast, %mask
  %floatcast = bitcast <4 x i64> %and to <4 x double>
  %max_is_x = fcmp oge <4 x double> %floatcast, %arg2
  %max = select <4 x i1> %max_is_x, <4 x double> %floatcast, <4 x double> %arg2
  ret <4 x double> %max
}