1 ; RUN: llc -mtriple=arm-eabi -mcpu=generic %s -o /dev/null
2 ; RUN: llc -mtriple=arm-eabi -mcpu=cortex-a8 %s -o - | FileCheck %s
3 ; RUN: llc -mtriple=thumb--none-eabi -mcpu=cortex-a8 %s -o - | FileCheck %s
5 @x = weak global i16 0 ; <i16*> [#uses=1]
6 @y = weak global i16 0 ; <i16*> [#uses=0]
8 define i32 @f1(i32 %y) {
11 %tmp = load i16, i16* @x ; <i16> [#uses=1]
12 %tmp1 = add i16 %tmp, 2 ; <i16> [#uses=1]
13 %tmp2 = sext i16 %tmp1 to i32 ; <i32> [#uses=1]
14 %tmp3 = ashr i32 %y, 16 ; <i32> [#uses=1]
15 %tmp4 = mul i32 %tmp2, %tmp3 ; <i32> [#uses=1]
19 define i32 @f2(i32 %x, i32 %y) {
22 %tmp1 = ashr i32 %x, 16 ; <i32> [#uses=1]
23 %tmp3 = ashr i32 %y, 16 ; <i32> [#uses=1]
24 %tmp4 = mul i32 %tmp3, %tmp1 ; <i32> [#uses=1]
28 define i32 @f3(i32 %a, i16 %x, i32 %y) {
31 %tmp = sext i16 %x to i32 ; <i32> [#uses=1]
32 %tmp2 = ashr i32 %y, 16 ; <i32> [#uses=1]
33 %tmp3 = mul i32 %tmp2, %tmp ; <i32> [#uses=1]
34 %tmp5 = add i32 %tmp3, %a ; <i32> [#uses=1]
38 define i32 @f4(i32 %a, i32 %x, i32 %y) {
41 %tmp1 = ashr i32 %x, 16
42 %tmp3 = ashr i32 %y, 16
43 %tmp4 = mul i32 %tmp3, %tmp1
44 %tmp5 = add i32 %tmp4, %a
48 define i32 @f5(i32 %a, i16 %x, i16 %y) {
51 %tmp1 = sext i16 %x to i32
52 %tmp3 = sext i16 %y to i32
53 %tmp4 = mul i32 %tmp3, %tmp1
54 %tmp5 = add i32 %tmp4, %a
58 define i32 @f6(i32 %a, i16 %x, i32 %y) {
61 %tmp1 = sext i16 %x to i32
62 %tmp3 = ashr i32 %y, 16
63 %tmp4 = mul i32 %tmp3, %tmp1
64 %tmp5 = add i32 %tmp4, %a
68 define i32 @f7(i32 %a, i32 %b, i32 %c) {
72 %shr = ashr exact i32 %shl, 16
73 %conv = sext i32 %a to i64
74 %conv2 = sext i32 %shr to i64
75 %mul = mul nsw i64 %conv2, %conv
76 %shr49 = lshr i64 %mul, 16
77 %conv5 = trunc i64 %shr49 to i32
78 %add = add nsw i32 %conv5, %c
82 define i32 @f8(i32 %a, i16 signext %b, i32 %c) {
85 %conv = sext i32 %a to i64
86 %conv1 = sext i16 %b to i64
87 %mul = mul nsw i64 %conv1, %conv
88 %shr5 = lshr i64 %mul, 16
89 %conv2 = trunc i64 %shr5 to i32
90 %add = add nsw i32 %conv2, %c
94 define i32 @f9(i32 %a, i32 %b, i32 %c) {
97 %conv = sext i32 %a to i64
98 %shr = ashr i32 %b, 16
99 %conv1 = sext i32 %shr to i64
100 %mul = mul nsw i64 %conv1, %conv
101 %shr26 = lshr i64 %mul, 16
102 %conv3 = trunc i64 %shr26 to i32
103 %add = add nsw i32 %conv3, %c
107 define i32 @f10(i32 %a, i32 %b, i32 %c) {
110 %shl = shl i32 %b, 16
111 %shr = ashr exact i32 %shl, 16
112 %conv = sext i32 %a to i64
113 %conv2 = sext i32 %shr to i64
114 %mul = mul nsw i64 %conv2, %conv
115 %shr37 = lshr i64 %mul, 16
116 %conv4 = trunc i64 %shr37 to i32
120 define i32 @f11(i32 %a, i16 signext %b, i32 %c) {
123 %conv = sext i32 %a to i64
124 %conv1 = sext i16 %b to i64
125 %mul = mul nsw i64 %conv1, %conv
126 %shr4 = lshr i64 %mul, 16
127 %conv2 = trunc i64 %shr4 to i32
131 define i32 @f12(i32 %a, i32 %b, i32 %c) {
134 %conv = sext i32 %a to i64
135 %shr = ashr i32 %b, 16
136 %conv1 = sext i32 %shr to i64
137 %mul = mul nsw i64 %conv1, %conv
138 %shr25 = lshr i64 %mul, 16
139 %conv3 = trunc i64 %shr25 to i32