Sam Parker | 28e46e5 | 2019-03-12 11:01:11 +0000 | [diff] [blame] | 1 | ; RUN: opt -mtriple=arm-arm-eabi -mcpu=cortex-m33 < %s -arm-parallel-dsp -S | FileCheck %s |
Sam Parker | 9e73020 | 2019-03-15 10:19:32 +0000 | [diff] [blame] | 2 | ; RUN: opt -mtriple=armeb-arm-eabi -mcpu=cortex-m0 < %s -arm-parallel-dsp -S | FileCheck %s --check-prefix=CHECK-UNSUPPORTED |
Sam Parker | 28e46e5 | 2019-03-12 11:01:11 +0000 | [diff] [blame] | 3 | ; |
| 4 | ; The Cortex-M0 does not support unaligned accesses: |
| 5 | ; RUN: opt -mtriple=arm-arm-eabi -mcpu=cortex-m0 < %s -arm-parallel-dsp -S | FileCheck %s --check-prefix=CHECK-UNSUPPORTED |
| 6 | ; |
| 7 | ; Check DSP extension: |
| 8 | ; RUN: opt -mtriple=arm-arm-eabi -mcpu=cortex-m33 -mattr=-dsp < %s -arm-parallel-dsp -S | FileCheck %s --check-prefix=CHECK-UNSUPPORTED |
| 9 | |
| 10 | define dso_local i32 @OneReduction(i32 %arg, i32* nocapture readnone %arg1, i16* nocapture readonly %arg2, i16* nocapture readonly %arg3) { |
| 11 | ; |
| 12 | ; CHECK-LABEL: @OneReduction |
| 13 | ; CHECK: %mac1{{\.}}026 = phi i32 [ [[V8:%[0-9]+]], %for.body ], [ 0, %for.body.preheader ] |
Sam Parker | a33e311 | 2019-05-13 09:23:32 +0000 | [diff] [blame] | 14 | ; CHECK: [[V4:%[0-9]+]] = bitcast i16* %arrayidx to i32* |
Sam Parker | 28e46e5 | 2019-03-12 11:01:11 +0000 | [diff] [blame] | 15 | ; CHECK: [[V5:%[0-9]+]] = load i32, i32* [[V4]], align 2 |
Sam Parker | a33e311 | 2019-05-13 09:23:32 +0000 | [diff] [blame] | 16 | ; CHECK: [[V6:%[0-9]+]] = bitcast i16* %arrayidx3 to i32* |
Sam Parker | 28e46e5 | 2019-03-12 11:01:11 +0000 | [diff] [blame] | 17 | ; CHECK: [[V7:%[0-9]+]] = load i32, i32* [[V6]], align 2 |
Sam Parker | a33e311 | 2019-05-13 09:23:32 +0000 | [diff] [blame] | 18 | ; CHECK: [[V8]] = call i32 @llvm.arm.smlad(i32 [[V7]], i32 [[V5]], i32 %mac1{{\.}}026) |
Sam Parker | 28e46e5 | 2019-03-12 11:01:11 +0000 | [diff] [blame] | 19 | ; CHECK-NOT: call i32 @llvm.arm.smlad |
| 20 | ; |
| 21 | ; CHECK-UNSUPPORTED-NOT: call i32 @llvm.arm.smlad |
| 22 | ; |
| 23 | entry: |
| 24 | %cmp24 = icmp sgt i32 %arg, 0 |
| 25 | br i1 %cmp24, label %for.body.preheader, label %for.cond.cleanup |
| 26 | |
| 27 | for.body.preheader: |
| 28 | %.pre = load i16, i16* %arg3, align 2 |
| 29 | %.pre27 = load i16, i16* %arg2, align 2 |
| 30 | br label %for.body |
| 31 | |
| 32 | for.cond.cleanup: |
| 33 | %mac1.0.lcssa = phi i32 [ 0, %entry ], [ %add11, %for.body ] |
| 34 | ret i32 %mac1.0.lcssa |
| 35 | |
| 36 | for.body: |
| 37 | ; One reduction statement here: |
| 38 | %mac1.026 = phi i32 [ %add11, %for.body ], [ 0, %for.body.preheader ] |
| 39 | |
| 40 | %i.025 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ] |
| 41 | %arrayidx = getelementptr inbounds i16, i16* %arg3, i32 %i.025 |
| 42 | %0 = load i16, i16* %arrayidx, align 2 |
| 43 | %add = add nuw nsw i32 %i.025, 1 |
| 44 | %arrayidx1 = getelementptr inbounds i16, i16* %arg3, i32 %add |
| 45 | %1 = load i16, i16* %arrayidx1, align 2 |
| 46 | %arrayidx3 = getelementptr inbounds i16, i16* %arg2, i32 %i.025 |
| 47 | %2 = load i16, i16* %arrayidx3, align 2 |
| 48 | %conv = sext i16 %2 to i32 |
| 49 | %conv4 = sext i16 %0 to i32 |
| 50 | %mul = mul nsw i32 %conv, %conv4 |
| 51 | %arrayidx6 = getelementptr inbounds i16, i16* %arg2, i32 %add |
| 52 | %3 = load i16, i16* %arrayidx6, align 2 |
| 53 | %conv7 = sext i16 %3 to i32 |
| 54 | %conv8 = sext i16 %1 to i32 |
| 55 | %mul9 = mul nsw i32 %conv7, %conv8 |
| 56 | %add10 = add i32 %mul, %mac1.026 |
| 57 | |
| 58 | ; Here the Mul is the LHS, and the Add the RHS. |
| 59 | %add11 = add i32 %mul9, %add10 |
| 60 | |
| 61 | %exitcond = icmp ne i32 %add, %arg |
| 62 | br i1 %exitcond, label %for.body, label %for.cond.cleanup |
| 63 | } |
| 64 | |
| 65 | define dso_local arm_aapcs_vfpcc i32 @TwoReductions(i32 %arg, i32* nocapture readnone %arg1, i16* nocapture readonly %arg2, i16* nocapture readonly %arg3) { |
| 66 | ; |
| 67 | ; CHECK-LABEL: @TwoReductions |
| 68 | ; |
| 69 | ; CHECK: %mac1{{\.}}058 = phi i32 [ [[V10:%[0-9]+]], %for.body ], [ 0, %for.body.preheader ] |
| 70 | ; CHECK: %mac2{{\.}}057 = phi i32 [ [[V17:%[0-9]+]], %for.body ], [ 0, %for.body.preheader ] |
| 71 | ; CHECK: [[V10]] = call i32 @llvm.arm.smlad(i32 %{{.*}}, i32 %{{.*}}, i32 %mac1{{\.}}058) |
| 72 | ; CHECK: [[V17]] = call i32 @llvm.arm.smlad(i32 %{{.*}}, i32 %{{.*}}, i32 %mac2{{\.}}057) |
| 73 | ; CHECK-NOT: call i32 @llvm.arm.smlad |
| 74 | ; |
| 75 | entry: |
| 76 | %cmp55 = icmp sgt i32 %arg, 0 |
| 77 | br i1 %cmp55, label %for.body.preheader, label %for.cond.cleanup |
| 78 | |
| 79 | for.cond.cleanup: |
| 80 | %mac2.0.lcssa = phi i32 [ 0, %entry ], [ %add28, %for.body ] |
| 81 | %mac1.0.lcssa = phi i32 [ 0, %entry ], [ %add16, %for.body ] |
| 82 | %add30 = add nsw i32 %mac1.0.lcssa, %mac2.0.lcssa |
| 83 | ret i32 %add30 |
| 84 | |
| 85 | for.body.preheader: |
| 86 | br label %for.body |
| 87 | |
| 88 | for.body: |
| 89 | ; And two reduction statements here: |
| 90 | %mac1.058 = phi i32 [ %add16, %for.body ], [ 0, %for.body.preheader ] |
| 91 | %mac2.057 = phi i32 [ %add28, %for.body ], [ 0, %for.body.preheader ] |
| 92 | |
| 93 | %i.056 = phi i32 [ %add29, %for.body ], [ 0, %for.body.preheader ] |
| 94 | %arrayidx = getelementptr inbounds i16, i16* %arg3, i32 %i.056 |
| 95 | %0 = load i16, i16* %arrayidx, align 2 |
| 96 | %add1 = or i32 %i.056, 1 |
| 97 | %arrayidx2 = getelementptr inbounds i16, i16* %arg3, i32 %add1 |
| 98 | %1 = load i16, i16* %arrayidx2, align 2 |
| 99 | %add3 = or i32 %i.056, 2 |
| 100 | %arrayidx4 = getelementptr inbounds i16, i16* %arg3, i32 %add3 |
| 101 | %2 = load i16, i16* %arrayidx4, align 2 |
| 102 | |
| 103 | %add5 = or i32 %i.056, 3 |
| 104 | %arrayidx6 = getelementptr inbounds i16, i16* %arg3, i32 %add5 |
| 105 | %3 = load i16, i16* %arrayidx6, align 2 |
| 106 | %arrayidx8 = getelementptr inbounds i16, i16* %arg2, i32 %i.056 |
| 107 | %4 = load i16, i16* %arrayidx8, align 2 |
| 108 | %conv = sext i16 %4 to i32 |
| 109 | %conv9 = sext i16 %0 to i32 |
| 110 | %mul = mul nsw i32 %conv, %conv9 |
| 111 | %arrayidx11 = getelementptr inbounds i16, i16* %arg2, i32 %add1 |
| 112 | %5 = load i16, i16* %arrayidx11, align 2 |
| 113 | %conv12 = sext i16 %5 to i32 |
| 114 | %conv13 = sext i16 %1 to i32 |
| 115 | %mul14 = mul nsw i32 %conv12, %conv13 |
| 116 | %add15 = add i32 %mul, %mac1.058 |
| 117 | %add16 = add i32 %add15, %mul14 |
| 118 | %arrayidx18 = getelementptr inbounds i16, i16* %arg2, i32 %add3 |
| 119 | %6 = load i16, i16* %arrayidx18, align 2 |
| 120 | %conv19 = sext i16 %6 to i32 |
| 121 | %conv20 = sext i16 %2 to i32 |
| 122 | %mul21 = mul nsw i32 %conv19, %conv20 |
| 123 | %arrayidx23 = getelementptr inbounds i16, i16* %arg2, i32 %add5 |
| 124 | %7 = load i16, i16* %arrayidx23, align 2 |
| 125 | %conv24 = sext i16 %7 to i32 |
| 126 | %conv25 = sext i16 %3 to i32 |
| 127 | %mul26 = mul nsw i32 %conv24, %conv25 |
| 128 | %add27 = add i32 %mul21, %mac2.057 |
| 129 | %add28 = add i32 %add27, %mul26 |
| 130 | %add29 = add nuw nsw i32 %i.056, 4 |
| 131 | %cmp = icmp slt i32 %add29, %arg |
| 132 | br i1 %cmp, label %for.body, label %for.cond.cleanup |
| 133 | } |
| 134 | |
| 135 | define i32 @one_zext(i32 %arg, i32* nocapture readnone %arg1, i16* nocapture readonly %arg2, i16* nocapture readonly %arg3) { |
| 136 | ; CHECK-LABEL: @one_zext |
| 137 | ; CHECK-NOT: call i32 @llvm.arm.smlad |
| 138 | entry: |
| 139 | %cmp24 = icmp sgt i32 %arg, 0 |
| 140 | br i1 %cmp24, label %for.body.preheader, label %for.cond.cleanup |
| 141 | |
| 142 | for.body.preheader: |
| 143 | %.pre = load i16, i16* %arg3, align 2 |
| 144 | %.pre27 = load i16, i16* %arg2, align 2 |
| 145 | br label %for.body |
| 146 | |
| 147 | for.cond.cleanup: |
| 148 | %mac1.0.lcssa = phi i32 [ 0, %entry ], [ %add11, %for.body ] |
| 149 | ret i32 %mac1.0.lcssa |
| 150 | |
| 151 | for.body: |
| 152 | %mac1.026 = phi i32 [ %add11, %for.body ], [ 0, %for.body.preheader ] |
| 153 | %i.025 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ] |
| 154 | %arrayidx = getelementptr inbounds i16, i16* %arg3, i32 %i.025 |
| 155 | %0 = load i16, i16* %arrayidx, align 2 |
| 156 | %add = add nuw nsw i32 %i.025, 1 |
| 157 | %arrayidx1 = getelementptr inbounds i16, i16* %arg3, i32 %add |
| 158 | %1 = load i16, i16* %arrayidx1, align 2 |
| 159 | %arrayidx3 = getelementptr inbounds i16, i16* %arg2, i32 %i.025 |
| 160 | %2 = load i16, i16* %arrayidx3, align 2 |
| 161 | %conv = sext i16 %2 to i32 |
| 162 | %conv4 = zext i16 %0 to i32 |
| 163 | %mul = mul nsw i32 %conv, %conv4 |
| 164 | %arrayidx6 = getelementptr inbounds i16, i16* %arg2, i32 %add |
| 165 | %3 = load i16, i16* %arrayidx6, align 2 |
| 166 | %conv7 = sext i16 %3 to i32 |
| 167 | %conv8 = zext i16 %1 to i32 |
| 168 | %mul9 = mul nsw i32 %conv7, %conv8 |
| 169 | %add10 = add i32 %mul, %mac1.026 |
| 170 | %add11 = add i32 %mul9, %add10 |
| 171 | %exitcond = icmp ne i32 %add, %arg |
| 172 | br i1 %exitcond, label %for.body, label %for.cond.cleanup |
| 173 | } |
| 174 | |
| 175 | define i32 @two_zext(i32 %arg, i32* nocapture readnone %arg1, i16* nocapture readonly %arg2, i16* nocapture readonly %arg3) { |
| 176 | ; CHECK-LABEL: @two_zext |
| 177 | ; CHECK-NOT: call i32 @llvm.arm.smlad |
| 178 | entry: |
| 179 | %cmp24 = icmp sgt i32 %arg, 0 |
| 180 | br i1 %cmp24, label %for.body.preheader, label %for.cond.cleanup |
| 181 | |
| 182 | for.body.preheader: |
| 183 | %.pre = load i16, i16* %arg3, align 2 |
| 184 | %.pre27 = load i16, i16* %arg2, align 2 |
| 185 | br label %for.body |
| 186 | |
| 187 | for.cond.cleanup: |
| 188 | %mac1.0.lcssa = phi i32 [ 0, %entry ], [ %add11, %for.body ] |
| 189 | ret i32 %mac1.0.lcssa |
| 190 | |
| 191 | for.body: |
| 192 | %mac1.026 = phi i32 [ %add11, %for.body ], [ 0, %for.body.preheader ] |
| 193 | %i.025 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ] |
| 194 | %arrayidx = getelementptr inbounds i16, i16* %arg3, i32 %i.025 |
| 195 | %0 = load i16, i16* %arrayidx, align 2 |
| 196 | %add = add nuw nsw i32 %i.025, 1 |
| 197 | %arrayidx1 = getelementptr inbounds i16, i16* %arg3, i32 %add |
| 198 | %1 = load i16, i16* %arrayidx1, align 2 |
| 199 | %arrayidx3 = getelementptr inbounds i16, i16* %arg2, i32 %i.025 |
| 200 | %2 = load i16, i16* %arrayidx3, align 2 |
| 201 | %conv = zext i16 %2 to i32 |
| 202 | %conv4 = zext i16 %0 to i32 |
| 203 | %mul = mul nsw i32 %conv, %conv4 |
| 204 | %arrayidx6 = getelementptr inbounds i16, i16* %arg2, i32 %add |
| 205 | %3 = load i16, i16* %arrayidx6, align 2 |
| 206 | %conv7 = zext i16 %3 to i32 |
| 207 | %conv8 = zext i16 %1 to i32 |
| 208 | %mul9 = mul nsw i32 %conv7, %conv8 |
| 209 | %add10 = add i32 %mul, %mac1.026 |
| 210 | %add11 = add i32 %mul9, %add10 |
| 211 | %exitcond = icmp ne i32 %add, %arg |
| 212 | br i1 %exitcond, label %for.body, label %for.cond.cleanup |
| 213 | } |
Sam Parker | 4c4ff13 | 2019-03-14 11:14:13 +0000 | [diff] [blame] | 214 | |