aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/Mips/dsp-patterns.ll
blob: 2e5a9edc480230d2f43e89828eb6a2ea01f4fc38 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
; RUN: llc -march=mips -mattr=dsp < %s | FileCheck %s -check-prefix=R1
; RUN: llc -march=mips -mattr=dspr2 < %s | FileCheck %s -check-prefix=R2

; R1: test_lbux:
; R1: lbux ${{[0-9]+}}

define zeroext i8 @test_lbux(i8* nocapture %b, i32 %i) {
entry:
  %add.ptr = getelementptr inbounds i8* %b, i32 %i
  %0 = load i8* %add.ptr, align 1
  ret i8 %0
}

; R1: test_lhx:
; R1: lhx ${{[0-9]+}}

define signext i16 @test_lhx(i16* nocapture %b, i32 %i) {
entry:
  %add.ptr = getelementptr inbounds i16* %b, i32 %i
  %0 = load i16* %add.ptr, align 2
  ret i16 %0
}

; R1: test_lwx:
; R1: lwx ${{[0-9]+}}

define i32 @test_lwx(i32* nocapture %b, i32 %i) {
entry:
  %add.ptr = getelementptr inbounds i32* %b, i32 %i
  %0 = load i32* %add.ptr, align 4
  ret i32 %0
}

; R1: test_add_v2q15_:
; R1: addq.ph ${{[0-9]+}}

define { i32 } @test_add_v2q15_(i32 %a.coerce, i32 %b.coerce) {
entry:
  %0 = bitcast i32 %a.coerce to <2 x i16>
  %1 = bitcast i32 %b.coerce to <2 x i16>
  %add = add <2 x i16> %0, %1
  %2 = bitcast <2 x i16> %add to i32
  %.fca.0.insert = insertvalue { i32 } undef, i32 %2, 0
  ret { i32 } %.fca.0.insert
}

; R1: test_sub_v2q15_:
; R1: subq.ph ${{[0-9]+}}

define { i32 } @test_sub_v2q15_(i32 %a.coerce, i32 %b.coerce) {
entry:
  %0 = bitcast i32 %a.coerce to <2 x i16>
  %1 = bitcast i32 %b.coerce to <2 x i16>
  %sub = sub <2 x i16> %0, %1
  %2 = bitcast <2 x i16> %sub to i32
  %.fca.0.insert = insertvalue { i32 } undef, i32 %2, 0
  ret { i32 } %.fca.0.insert
}

; R2: test_mul_v2q15_:
; R2: mul.ph ${{[0-9]+}}

; mul.ph is an R2 instruction. Check that multiply node gets expanded.
; R1: test_mul_v2q15_:
; R1: mul ${{[0-9]+}}
; R1: mul ${{[0-9]+}}

define { i32 } @test_mul_v2q15_(i32 %a.coerce, i32 %b.coerce) {
entry:
  %0 = bitcast i32 %a.coerce to <2 x i16>
  %1 = bitcast i32 %b.coerce to <2 x i16>
  %mul = mul <2 x i16> %0, %1
  %2 = bitcast <2 x i16> %mul to i32
  %.fca.0.insert = insertvalue { i32 } undef, i32 %2, 0
  ret { i32 } %.fca.0.insert
}

; R1: test_add_v4i8_:
; R1: addu.qb ${{[0-9]+}}

define { i32 } @test_add_v4i8_(i32 %a.coerce, i32 %b.coerce) {
entry:
  %0 = bitcast i32 %a.coerce to <4 x i8>
  %1 = bitcast i32 %b.coerce to <4 x i8>
  %add = add <4 x i8> %0, %1
  %2 = bitcast <4 x i8> %add to i32
  %.fca.0.insert = insertvalue { i32 } undef, i32 %2, 0
  ret { i32 } %.fca.0.insert
}

; R1: test_sub_v4i8_:
; R1: subu.qb ${{[0-9]+}}

define { i32 } @test_sub_v4i8_(i32 %a.coerce, i32 %b.coerce) {
entry:
  %0 = bitcast i32 %a.coerce to <4 x i8>
  %1 = bitcast i32 %b.coerce to <4 x i8>
  %sub = sub <4 x i8> %0, %1
  %2 = bitcast <4 x i8> %sub to i32
  %.fca.0.insert = insertvalue { i32 } undef, i32 %2, 0
  ret { i32 } %.fca.0.insert
}

; DSP-ASE doesn't have a v4i8 multiply instruction. Check that multiply node gets expanded.
; R2: test_mul_v4i8_:
; R2: mul ${{[0-9]+}}
; R2: mul ${{[0-9]+}}
; R2: mul ${{[0-9]+}}
; R2: mul ${{[0-9]+}}

define { i32 } @test_mul_v4i8_(i32 %a.coerce, i32 %b.coerce) {
entry:
  %0 = bitcast i32 %a.coerce to <4 x i8>
  %1 = bitcast i32 %b.coerce to <4 x i8>
  %mul = mul <4 x i8> %0, %1
  %2 = bitcast <4 x i8> %mul to i32
  %.fca.0.insert = insertvalue { i32 } undef, i32 %2, 0
  ret { i32 } %.fca.0.insert
}

; R1: test_addsc:
; R1: addsc ${{[0-9]+}}
; R1: addwc ${{[0-9]+}}

define i64 @test_addsc(i64 %a, i64 %b) #1 {
entry:
  %add = add nsw i64 %b, %a
  ret i64 %add
}