|
| 1 | +; RUN: opt -mtriple=arm-arm-eabi -mcpu=cortex-m33 < %s -arm-parallel-dsp -S | FileCheck %s |
| 2 | + |
| 3 | +; CHECK-LABEL: topbottom_mul |
| 4 | +define void @topbottom_mul(i32 %N, i32* noalias nocapture readnone %Out, i16* nocapture readonly %In1, i16* nocapture readonly %In2) { |
| 5 | +entry: |
| 6 | + br label %for.body |
| 7 | + |
| 8 | +; CHECK: for.body: |
| 9 | +; CHECK: [[Cast_PIn1_0:%[^ ]+]] = bitcast i16* %PIn1.0 to i32* |
| 10 | +; CHECK: [[PIn1_01:%[^ ]+]] = load i32, i32* [[Cast_PIn1_0]], align 2 |
| 11 | +; CHECK: [[PIn1_01_shl:%[^ ]+]] = shl i32 [[PIn1_01]], 16 |
| 12 | +; CHECK: [[PIn1_0:%[^ ]+]] = ashr i32 [[PIn1_01_shl]], 16 |
| 13 | +; CHECK: [[PIn1_1:%[^ ]+]] = ashr i32 [[PIn1_01]], 16 |
| 14 | + |
| 15 | +; CHECK: [[Cast_PIn2_0:%[^ ]+]] = bitcast i16* %PIn2.0 to i32* |
| 16 | +; CHECK: [[PIn2_01:%[^ ]+]] = load i32, i32* [[Cast_PIn2_0]], align 2 |
| 17 | +; CHECK: [[PIn2_01_shl:%[^ ]+]] = shl i32 [[PIn2_01]], 16 |
| 18 | +; CHECK: [[PIn2_0:%[^ ]+]] = ashr i32 [[PIn2_01_shl]], 16 |
| 19 | +; CHECK: [[PIn2_1:%[^ ]+]] = ashr i32 [[PIn2_01]], 16 |
| 20 | + |
| 21 | +; CHECK: mul nsw i32 [[PIn1_0]], [[PIn2_0]] |
| 22 | +; CHECK: mul nsw i32 [[PIn1_1]], [[PIn2_1]] |
| 23 | + |
| 24 | +; CHECK: [[Cast_PIn1_2:%[^ ]+]] = bitcast i16* %PIn1.2 to i32* |
| 25 | +; CHECK: [[PIn1_23:%[^ ]+]] = load i32, i32* [[Cast_PIn1_2]], align 2 |
| 26 | +; CHECK: [[PIn1_23_shl:%[^ ]+]] = shl i32 [[PIn1_23]], 16 |
| 27 | +; CHECK: [[PIn1_2:%[^ ]+]] = ashr i32 [[PIn1_23_shl]], 16 |
| 28 | +; CHECK: [[PIn1_3:%[^ ]+]] = ashr i32 [[PIn1_23]], 16 |
| 29 | + |
| 30 | +; CHECK: [[Cast_PIn2_2:%[^ ]+]] = bitcast i16* %PIn2.2 to i32* |
| 31 | +; CHECK: [[PIn2_23:%[^ ]+]] = load i32, i32* [[Cast_PIn2_2]], align 2 |
| 32 | +; CHECK: [[PIn2_23_shl:%[^ ]+]] = shl i32 [[PIn2_23]], 16 |
| 33 | +; CHECK: [[PIn2_2:%[^ ]+]] = ashr i32 [[PIn2_23_shl]], 16 |
| 34 | +; CHECK: [[PIn2_3:%[^ ]+]] = ashr i32 [[PIn2_23]], 16 |
| 35 | + |
| 36 | +; CHECK: mul nsw i32 [[PIn1_2]], [[PIn2_2]] |
| 37 | +; CHECK: mul nsw i32 [[PIn1_3]], [[PIn2_3]] |
| 38 | + |
| 39 | +for.body: |
| 40 | + %iv = phi i32 [ 0, %entry ], [ %iv.next, %for.body ] |
| 41 | + %count = phi i32 [ %N, %entry ], [ %count.next, %for.body ] |
| 42 | + %PIn1.0 = getelementptr inbounds i16, i16* %In1, i32 %iv |
| 43 | + %In1.0 = load i16, i16* %PIn1.0, align 2 |
| 44 | + %SIn1.0 = sext i16 %In1.0 to i32 |
| 45 | + %PIn2.0 = getelementptr inbounds i16, i16* %In2, i32 %iv |
| 46 | + %In2.0 = load i16, i16* %PIn2.0, align 2 |
| 47 | + %SIn2.0 = sext i16 %In2.0 to i32 |
| 48 | + %mul5.us.i.i = mul nsw i32 %SIn1.0, %SIn2.0 |
| 49 | + %Out.0 = getelementptr inbounds i32, i32* %Out, i32 %iv |
| 50 | + store i32 %mul5.us.i.i, i32* %Out.0, align 4 |
| 51 | + %iv.1 = or i32 %iv, 1 |
| 52 | + %PIn1.1 = getelementptr inbounds i16, i16* %In1, i32 %iv.1 |
| 53 | + %In1.1 = load i16, i16* %PIn1.1, align 2 |
| 54 | + %SIn1.1 = sext i16 %In1.1 to i32 |
| 55 | + %PIn2.1 = getelementptr inbounds i16, i16* %In2, i32 %iv.1 |
| 56 | + %In2.1 = load i16, i16* %PIn2.1, align 2 |
| 57 | + %SIn2.1 = sext i16 %In2.1 to i32 |
| 58 | + %mul5.us.i.1.i = mul nsw i32 %SIn1.1, %SIn2.1 |
| 59 | + %Out.1 = getelementptr inbounds i32, i32* %Out, i32 %iv.1 |
| 60 | + store i32 %mul5.us.i.1.i, i32* %Out.1, align 4 |
| 61 | + %iv.2 = or i32 %iv, 2 |
| 62 | + %PIn1.2 = getelementptr inbounds i16, i16* %In1, i32 %iv.2 |
| 63 | + %In1.2 = load i16, i16* %PIn1.2, align 2 |
| 64 | + %SIn1.2 = sext i16 %In1.2 to i32 |
| 65 | + %PIn2.2 = getelementptr inbounds i16, i16* %In2, i32 %iv.2 |
| 66 | + %In2.2 = load i16, i16* %PIn2.2, align 2 |
| 67 | + %SIn2.2 = sext i16 %In2.2 to i32 |
| 68 | + %mul5.us.i.2.i = mul nsw i32 %SIn1.2, %SIn2.2 |
| 69 | + %Out.2 = getelementptr inbounds i32, i32* %Out, i32 %iv.2 |
| 70 | + store i32 %mul5.us.i.2.i, i32* %Out.2, align 4 |
| 71 | + %iv.3 = or i32 %iv, 3 |
| 72 | + %PIn1.3 = getelementptr inbounds i16, i16* %In1, i32 %iv.3 |
| 73 | + %In1.3 = load i16, i16* %PIn1.3, align 2 |
| 74 | + %SIn1.3 = sext i16 %In1.3 to i32 |
| 75 | + %PIn2.3 = getelementptr inbounds i16, i16* %In2, i32 %iv.3 |
| 76 | + %In2.3 = load i16, i16* %PIn2.3, align 2 |
| 77 | + %SIn2.3 = sext i16 %In2.3 to i32 |
| 78 | + %mul5.us.i.3.i = mul nsw i32 %SIn1.3, %SIn2.3 |
| 79 | + %Out.3 = getelementptr inbounds i32, i32* %Out, i32 %iv.3 |
| 80 | + store i32 %mul5.us.i.3.i, i32* %Out.3, align 4 |
| 81 | + %iv.next = add i32 %iv, 4 |
| 82 | + %count.next = add i32 %count, -4 |
| 83 | + %niter375.ncmp.3.i = icmp eq i32 %count.next, 0 |
| 84 | + br i1 %niter375.ncmp.3.i, label %exit, label %for.body |
| 85 | + |
| 86 | +exit: |
| 87 | + ret void |
| 88 | +} |
| 89 | + |
| 90 | +; CHECK-LABEL: topbottom_mul_load_const |
| 91 | +define void @topbottom_mul_load_const(i32 %N, i32* noalias nocapture readnone %Out, i16* nocapture readonly %In, i16* %C) { |
| 92 | +entry: |
| 93 | + %const = load i16, i16* %C |
| 94 | + %conv4.i.i = sext i16 %const to i32 |
| 95 | + br label %for.body |
| 96 | + |
| 97 | +; CHECK: for.body: |
| 98 | +; CHECK: [[Cast_PIn_0:%[^ ]+]] = bitcast i16* %PIn.0 to i32* |
| 99 | +; CHECK: [[PIn_01:%[^ ]+]] = load i32, i32* [[Cast_PIn_0]], align 2 |
| 100 | +; CHECK: [[PIn_01_shl:%[^ ]+]] = shl i32 [[PIn_01]], 16 |
| 101 | +; CHECK: [[PIn_0:%[^ ]+]] = ashr i32 [[PIn_01_shl]], 16 |
| 102 | +; CHECK: [[PIn_1:%[^ ]+]] = ashr i32 [[PIn_01]], 16 |
| 103 | + |
| 104 | +; CHECK: mul nsw i32 [[PIn_0]], %conv4.i.i |
| 105 | +; CHECK: mul nsw i32 [[PIn_1]], %conv4.i.i |
| 106 | + |
| 107 | +; CHECK: [[Cast_PIn_2:%[^ ]+]] = bitcast i16* %PIn.2 to i32* |
| 108 | +; CHECK: [[PIn_23:%[^ ]+]] = load i32, i32* [[Cast_PIn_2]], align 2 |
| 109 | +; CHECK: [[PIn_23_shl:%[^ ]+]] = shl i32 [[PIn_23]], 16 |
| 110 | +; CHECK: [[PIn_2:%[^ ]+]] = ashr i32 [[PIn_23_shl]], 16 |
| 111 | +; CHECK: [[PIn_3:%[^ ]+]] = ashr i32 [[PIn_23]], 16 |
| 112 | + |
| 113 | +; CHECK: mul nsw i32 [[PIn_2]], %conv4.i.i |
| 114 | +; CHECK: mul nsw i32 [[PIn_3]], %conv4.i.i |
| 115 | + |
| 116 | +for.body: |
| 117 | + %iv = phi i32 [ 0, %entry ], [ %iv.next, %for.body ] |
| 118 | + %count = phi i32 [ %N, %entry ], [ %count.next, %for.body ] |
| 119 | + %PIn.0 = getelementptr inbounds i16, i16* %In, i32 %iv |
| 120 | + %In.0 = load i16, i16* %PIn.0, align 2 |
| 121 | + %conv.us.i144.i = sext i16 %In.0 to i32 |
| 122 | + %mul5.us.i.i = mul nsw i32 %conv.us.i144.i, %conv4.i.i |
| 123 | + %Out.0 = getelementptr inbounds i32, i32* %Out, i32 %iv |
| 124 | + store i32 %mul5.us.i.i, i32* %Out.0, align 4 |
| 125 | + %iv.1 = or i32 %iv, 1 |
| 126 | + %PIn.1 = getelementptr inbounds i16, i16* %In, i32 %iv.1 |
| 127 | + %In.1 = load i16, i16* %PIn.1, align 2 |
| 128 | + %conv.us.i144.1.i = sext i16 %In.1 to i32 |
| 129 | + %mul5.us.i.1.i = mul nsw i32 %conv.us.i144.1.i, %conv4.i.i |
| 130 | + %Out.1 = getelementptr inbounds i32, i32* %Out, i32 %iv.1 |
| 131 | + store i32 %mul5.us.i.1.i, i32* %Out.1, align 4 |
| 132 | + %iv.2 = or i32 %iv, 2 |
| 133 | + %PIn.2 = getelementptr inbounds i16, i16* %In, i32 %iv.2 |
| 134 | + %In.3 = load i16, i16* %PIn.2, align 2 |
| 135 | + %conv.us.i144.2.i = sext i16 %In.3 to i32 |
| 136 | + %mul5.us.i.2.i = mul nsw i32 %conv.us.i144.2.i, %conv4.i.i |
| 137 | + %Out.2 = getelementptr inbounds i32, i32* %Out, i32 %iv.2 |
| 138 | + store i32 %mul5.us.i.2.i, i32* %Out.2, align 4 |
| 139 | + %iv.3 = or i32 %iv, 3 |
| 140 | + %PIn.3 = getelementptr inbounds i16, i16* %In, i32 %iv.3 |
| 141 | + %In.4 = load i16, i16* %PIn.3, align 2 |
| 142 | + %conv.us.i144.3.i = sext i16 %In.4 to i32 |
| 143 | + %mul5.us.i.3.i = mul nsw i32 %conv.us.i144.3.i, %conv4.i.i |
| 144 | + %Out.3 = getelementptr inbounds i32, i32* %Out, i32 %iv.3 |
| 145 | + store i32 %mul5.us.i.3.i, i32* %Out.3, align 4 |
| 146 | + %iv.next = add i32 %iv, 4 |
| 147 | + %count.next = add i32 %count, -4 |
| 148 | + %niter375.ncmp.3.i = icmp eq i32 %count.next, 0 |
| 149 | + br i1 %niter375.ncmp.3.i, label %exit, label %for.body |
| 150 | + |
| 151 | +exit: |
| 152 | + ret void |
| 153 | +} |
| 154 | + |
| 155 | +; CHECK-LABEL: topbottom_mul_64 |
| 156 | +define void @topbottom_mul_64(i32 %N, i64* noalias nocapture readnone %Out, i16* nocapture readonly %In1, i16* nocapture readonly %In2) { |
| 157 | +entry: |
| 158 | + br label %for.body |
| 159 | + |
| 160 | +; CHECK: for.body: |
| 161 | +; CHECK: [[Cast_PIn1_0:%[^ ]+]] = bitcast i16* %PIn1.0 to i32* |
| 162 | +; CHECK: [[PIn1_01:%[^ ]+]] = load i32, i32* [[Cast_PIn1_0]], align 2 |
| 163 | +; CHECK: [[PIn1_01_shl:%[^ ]+]] = shl i32 [[PIn1_01]], 16 |
| 164 | +; CHECK: [[PIn1_0:%[^ ]+]] = ashr i32 [[PIn1_01_shl]], 16 |
| 165 | +; CHECK: [[PIn1_1:%[^ ]+]] = ashr i32 [[PIn1_01]], 16 |
| 166 | + |
| 167 | +; CHECK: [[Cast_PIn2_0:%[^ ]+]] = bitcast i16* %PIn2.0 to i32* |
| 168 | +; CHECK: [[PIn2_01:%[^ ]+]] = load i32, i32* [[Cast_PIn2_0]], align 2 |
| 169 | +; CHECK: [[PIn2_01_shl:%[^ ]+]] = shl i32 [[PIn2_01]], 16 |
| 170 | +; CHECK: [[PIn2_0:%[^ ]+]] = ashr i32 [[PIn2_01_shl]], 16 |
| 171 | +; CHECK: [[PIn2_1:%[^ ]+]] = ashr i32 [[PIn2_01]], 16 |
| 172 | + |
| 173 | +; CHECK: [[Mul0:%[^ ]+]] = mul nsw i32 [[PIn1_0]], [[PIn2_0]] |
| 174 | +; CHECK: [[SMul0:%[^ ]+]] = sext i32 [[Mul0]] to i64 |
| 175 | +; CHECK: [[Mul1:%[^ ]+]] = mul nsw i32 [[PIn1_1]], [[PIn2_1]] |
| 176 | +; CHECK: [[SMul1:%[^ ]+]] = sext i32 [[Mul1]] to i64 |
| 177 | +; CHECK: add i64 [[SMul0]], [[SMul1]] |
| 178 | + |
| 179 | +; CHECK: [[Cast_PIn1_2:%[^ ]+]] = bitcast i16* %PIn1.2 to i32* |
| 180 | +; CHECK: [[PIn1_23:%[^ ]+]] = load i32, i32* [[Cast_PIn1_2]], align 2 |
| 181 | +; CHECK: [[PIn1_23_shl:%[^ ]+]] = shl i32 [[PIn1_23]], 16 |
| 182 | +; CHECK: [[PIn1_2:%[^ ]+]] = ashr i32 [[PIn1_23_shl]], 16 |
| 183 | +; CHECK: [[PIn1_3:%[^ ]+]] = ashr i32 [[PIn1_23]], 16 |
| 184 | + |
| 185 | +; CHECK: [[Cast_PIn2_2:%[^ ]+]] = bitcast i16* %PIn2.2 to i32* |
| 186 | +; CHECK: [[PIn2_23:%[^ ]+]] = load i32, i32* [[Cast_PIn2_2]], align 2 |
| 187 | +; CHECK: [[PIn2_23_shl:%[^ ]+]] = shl i32 [[PIn2_23]], 16 |
| 188 | +; CHECK: [[PIn2_2:%[^ ]+]] = ashr i32 [[PIn2_23_shl]], 16 |
| 189 | +; CHECK: [[PIn2_3:%[^ ]+]] = ashr i32 [[PIn2_23]], 16 |
| 190 | + |
| 191 | +; CHECK: [[Mul2:%[^ ]+]] = mul nsw i32 [[PIn1_2]], [[PIn2_2]] |
| 192 | +; CHECK: [[SMul2:%[^ ]+]] = sext i32 [[Mul2]] to i64 |
| 193 | +; CHECK: [[Mul3:%[^ ]+]] = mul nsw i32 [[PIn1_3]], [[PIn2_3]] |
| 194 | +; CHECK: [[SMul3:%[^ ]+]] = sext i32 [[Mul3]] to i64 |
| 195 | +; CHECK: add i64 [[SMul2]], [[SMul3]] |
| 196 | + |
| 197 | +for.body: |
| 198 | + %iv = phi i32 [ 0, %entry ], [ %iv.next, %for.body ] |
| 199 | + %iv.out = phi i32 [ 0, %entry] , [ %iv.out.next, %for.body ] |
| 200 | + %count = phi i32 [ %N, %entry ], [ %count.next, %for.body ] |
| 201 | + %PIn1.0 = getelementptr inbounds i16, i16* %In1, i32 %iv |
| 202 | + %In1.0 = load i16, i16* %PIn1.0, align 2 |
| 203 | + %SIn1.0 = sext i16 %In1.0 to i32 |
| 204 | + %PIn2.0 = getelementptr inbounds i16, i16* %In2, i32 %iv |
| 205 | + %In2.0 = load i16, i16* %PIn2.0, align 2 |
| 206 | + %SIn2.0 = sext i16 %In2.0 to i32 |
| 207 | + %mul5.us.i.i = mul nsw i32 %SIn1.0, %SIn2.0 |
| 208 | + %sext.0 = sext i32 %mul5.us.i.i to i64 |
| 209 | + %iv.1 = or i32 %iv, 1 |
| 210 | + %PIn1.1 = getelementptr inbounds i16, i16* %In1, i32 %iv.1 |
| 211 | + %In1.1 = load i16, i16* %PIn1.1, align 2 |
| 212 | + %SIn1.1 = sext i16 %In1.1 to i32 |
| 213 | + %PIn2.1 = getelementptr inbounds i16, i16* %In2, i32 %iv.1 |
| 214 | + %In2.1 = load i16, i16* %PIn2.1, align 2 |
| 215 | + %SIn2.1 = sext i16 %In2.1 to i32 |
| 216 | + %mul5.us.i.1.i = mul nsw i32 %SIn1.1, %SIn2.1 |
| 217 | + %sext.1 = sext i32 %mul5.us.i.1.i to i64 |
| 218 | + %mac.0 = add i64 %sext.0, %sext.1 |
| 219 | + %Out.0 = getelementptr inbounds i64, i64* %Out, i32 %iv.out |
| 220 | + store i64 %mac.0, i64* %Out.0, align 4 |
| 221 | + %iv.2 = or i32 %iv, 2 |
| 222 | + %PIn1.2 = getelementptr inbounds i16, i16* %In1, i32 %iv.2 |
| 223 | + %In1.2 = load i16, i16* %PIn1.2, align 2 |
| 224 | + %SIn1.2 = sext i16 %In1.2 to i32 |
| 225 | + %PIn2.2 = getelementptr inbounds i16, i16* %In2, i32 %iv.2 |
| 226 | + %In2.2 = load i16, i16* %PIn2.2, align 2 |
| 227 | + %SIn2.2 = sext i16 %In2.2 to i32 |
| 228 | + %mul5.us.i.2.i = mul nsw i32 %SIn1.2, %SIn2.2 |
| 229 | + %sext.2 = sext i32 %mul5.us.i.2.i to i64 |
| 230 | + %iv.3 = or i32 %iv, 3 |
| 231 | + %PIn1.3 = getelementptr inbounds i16, i16* %In1, i32 %iv.3 |
| 232 | + %In1.3 = load i16, i16* %PIn1.3, align 2 |
| 233 | + %SIn1.3 = sext i16 %In1.3 to i32 |
| 234 | + %PIn2.3 = getelementptr inbounds i16, i16* %In2, i32 %iv.3 |
| 235 | + %In2.3 = load i16, i16* %PIn2.3, align 2 |
| 236 | + %SIn2.3 = sext i16 %In2.3 to i32 |
| 237 | + %mul5.us.i.3.i = mul nsw i32 %SIn1.3, %SIn2.3 |
| 238 | + %sext.3 = sext i32 %mul5.us.i.3.i to i64 |
| 239 | + %mac.1 = add i64 %sext.2, %sext.3 |
| 240 | + %iv.out.1 = or i32 %iv.out, 1 |
| 241 | + %Out.1 = getelementptr inbounds i64, i64* %Out, i32 %iv.out.1 |
| 242 | + store i64 %mac.1, i64* %Out.1, align 4 |
| 243 | + %iv.next = add i32 %iv, 4 |
| 244 | + %iv.out.next = add i32 %iv.out, 2 |
| 245 | + %count.next = add i32 %count, -4 |
| 246 | + %niter375.ncmp.3.i = icmp eq i32 %count.next, 0 |
| 247 | + br i1 %niter375.ncmp.3.i, label %exit, label %for.body |
| 248 | + |
| 249 | +exit: |
| 250 | + ret void |
| 251 | +} |
0 commit comments