summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/broadcast.ll
blob: d852e2970fc05de6e3ebb3a6af6d4656b9997ade (plain)
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -instcombine -S < %s | FileCheck %s

; CHECK-LABEL: good1
; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0
; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[INS]], <4 x float> undef, <4 x i32> zeroinitializer
; CHECK-NEXT: ret <4 x float> %[[BCAST]]
define <4 x float> @good1(float %arg) {
  %tmp = insertelement <4 x float> undef, float %arg, i32 0
  %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
  %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
  %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
  ret <4 x float> %tmp6
}

; CHECK-LABEL: good2
; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0
; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[INS]], <4 x float> undef, <4 x i32> zeroinitializer
; CHECK-NEXT: ret <4 x float> %[[BCAST]]
define <4 x float> @good2(float %arg) {
  %tmp = insertelement <4 x float> undef, float %arg, i32 1
  %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 2
  %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 0
  %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
  ret <4 x float> %tmp6
}

; CHECK-LABEL: good3
; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0
; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[INS]], <4 x float> undef, <4 x i32> zeroinitializer
; CHECK-NEXT: ret <4 x float> %[[BCAST]]
define <4 x float> @good3(float %arg) {
  %tmp = insertelement <4 x float> zeroinitializer, float %arg, i32 0
  %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
  %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
  %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
  ret <4 x float> %tmp6
}

; CHECK-LABEL: good4
; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0
; CHECK-NEXT: %[[ADD:.*]] = fadd <4 x float> %[[INS]], %[[INS]]
; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[ADD]], <4 x float> undef, <4 x i32> zeroinitializer
; CHECK-NEXT: ret <4 x float> %[[BCAST]]
define <4 x float> @good4(float %arg) {
  %tmp = insertelement <4 x float> zeroinitializer, float %arg, i32 0
  %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
  %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
  %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
  %tmp7 = fadd <4 x float> %tmp6, %tmp6
  ret <4 x float> %tmp7
}

; CHECK-LABEL: bad1
; CHECK-NOT: shufflevector
define <4 x float> @bad1(float %arg) {
  %tmp = insertelement <4 x float> undef, float %arg, i32 1
  %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
  %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
  %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
  ret <4 x float> %tmp6
}

; CHECK-LABEL: bad2
; CHECK-NOT: shufflevector
define <4 x float> @bad2(float %arg) {
  %tmp = insertelement <4 x float> undef, float %arg, i32 0
  %tmp5 = insertelement <4 x float> %tmp, float %arg, i32 2
  %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
  ret <4 x float> %tmp6
}

; CHECK-LABEL: bad3
; CHECK-NOT: shufflevector
define <4 x float> @bad3(float %arg, float %arg2) {
  %tmp = insertelement <4 x float> undef, float %arg, i32 0
  %tmp4 = insertelement <4 x float> %tmp, float %arg2, i32 1
  %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
  %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
  ret <4 x float> %tmp6
}

; CHECK-LABEL: bad4
; CHECK-NOT: shufflevector
define <1 x float> @bad4(float %arg) {
  %tmp = insertelement <1 x float> undef, float %arg, i32 0
  ret <1 x float> %tmp
}

; CHECK-LABEL: bad5
; CHECK-NOT: shufflevector
define <4 x float> @bad5(float %arg) {
  %tmp = insertelement <4 x float> undef, float %arg, i32 0
  %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
  %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2
  %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
  %tmp7 = fadd <4 x float> %tmp6, %tmp4
  ret <4 x float> %tmp7
}

; CHECK-LABEL: bad6
; CHECK-NOT: shufflevector
define <4 x float> @bad6(float %arg, i32 %k) {
  %tmp = insertelement <4 x float> undef, float %arg, i32 0
  %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1
  %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 %k
  %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3
  ret <4 x float> %tmp6
}
OpenPOWER on IntegriCloud