1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 3; RUN: llc -mtriple=thumbv7em -mcpu=cortex-m4 -O3 %s -o - | FileCheck %s --check-prefix=CHECK-LLC 4; RUN: opt -S -mtriple=armv7-a -arm-parallel-dsp -dce %s -o - | FileCheck %s --check-prefix=CHECK-OPT 5 6define dso_local arm_aapcscc void @complex_dot_prod(i16* nocapture readonly %pSrcA, i16* nocapture readonly %pSrcB, i32* nocapture %realResult, i32* nocapture %imagResult) { 7; CHECK-LLC-LABEL: complex_dot_prod: 8; CHECK-LLC: @ %bb.0: @ %entry 9; CHECK-LLC-NEXT: push.w {r4, r5, r6, r7, r8, r9, r10, r11, lr} 10; CHECK-LLC-NEXT: ldr r5, [r0] 11; CHECK-LLC-NEXT: ldr r7, [r1] 12; CHECK-LLC-NEXT: ldr.w r10, [r0, #4] 13; CHECK-LLC-NEXT: ldr.w r8, [r0, #8] 14; CHECK-LLC-NEXT: ldr.w r12, [r0, #12] 15; CHECK-LLC-NEXT: ldr r4, [r1, #4] 16; CHECK-LLC-NEXT: ldr.w r9, [r1, #8] 17; CHECK-LLC-NEXT: ldr.w lr, [r1, #12] 18; CHECK-LLC-NEXT: movs r0, #0 19; CHECK-LLC-NEXT: movs r1, #0 20; CHECK-LLC-NEXT: smlaldx r0, r1, r5, r7 21; CHECK-LLC-NEXT: smulbb r6, r7, r5 22; CHECK-LLC-NEXT: smultt r5, r7, r5 23; CHECK-LLC-NEXT: asr.w r11, r6, #31 24; CHECK-LLC-NEXT: subs r6, r6, r5 25; CHECK-LLC-NEXT: sbc.w r5, r11, r5, asr #31 26; CHECK-LLC-NEXT: smlaldx r0, r1, r10, r4 27; CHECK-LLC-NEXT: smlalbb r6, r5, r4, r10 28; CHECK-LLC-NEXT: smultt r4, r4, r10 29; CHECK-LLC-NEXT: subs r6, r6, r4 30; CHECK-LLC-NEXT: sbc.w r4, r5, r4, asr #31 31; CHECK-LLC-NEXT: smlalbb r6, r4, r9, r8 32; CHECK-LLC-NEXT: smultt r5, r9, r8 33; CHECK-LLC-NEXT: subs r6, r6, r5 34; CHECK-LLC-NEXT: sbc.w r4, r4, r5, asr #31 35; CHECK-LLC-NEXT: smlaldx r0, r1, r8, r9 36; CHECK-LLC-NEXT: smlalbb r6, r4, lr, r12 37; CHECK-LLC-NEXT: smultt r7, lr, r12 38; CHECK-LLC-NEXT: smlaldx r0, r1, r12, lr 39; CHECK-LLC-NEXT: subs r6, r6, r7 40; CHECK-LLC-NEXT: sbc.w r7, r4, r7, asr #31 41; CHECK-LLC-NEXT: lsrs r6, r6, #6 42; CHECK-LLC-NEXT: lsrs r0, r0, #6 43; CHECK-LLC-NEXT: orr.w r7, r6, r7, lsl #26 44; CHECK-LLC-NEXT: orr.w r0, r0, r1, lsl #26 45; CHECK-LLC-NEXT: str r7, [r2] 46; CHECK-LLC-NEXT: str r0, [r3] 47; CHECK-LLC-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r10, r11, pc} 48; CHECK-LCC: pop.w {r4, r5, r6, r7, r8, r9, r10, pc} 49; 50; CHECK-OPT-LABEL: @complex_dot_prod( 51; CHECK-OPT-NEXT: entry: 52; CHECK-OPT-NEXT: [[TMP0:%.*]] = bitcast i16* [[PSRCA:%.*]] to i32* 53; CHECK-OPT-NEXT: [[TMP1:%.*]] = load i32, i32* [[TMP0]], align 2 54; CHECK-OPT-NEXT: [[TMP2:%.*]] = trunc i32 [[TMP1]] to i16 55; CHECK-OPT-NEXT: [[TMP3:%.*]] = sext i16 [[TMP2]] to i32 56; CHECK-OPT-NEXT: [[TMP4:%.*]] = lshr i32 [[TMP1]], 16 57; CHECK-OPT-NEXT: [[TMP5:%.*]] = trunc i32 [[TMP4]] to i16 58; CHECK-OPT-NEXT: [[TMP6:%.*]] = sext i16 [[TMP5]] to i32 59; CHECK-OPT-NEXT: [[INCDEC_PTR1:%.*]] = getelementptr inbounds i16, i16* [[PSRCA]], i32 2 60; CHECK-OPT-NEXT: [[TMP7:%.*]] = bitcast i16* [[PSRCB:%.*]] to i32* 61; CHECK-OPT-NEXT: [[TMP8:%.*]] = load i32, i32* [[TMP7]], align 2 62; CHECK-OPT-NEXT: [[TMP9:%.*]] = trunc i32 [[TMP8]] to i16 63; CHECK-OPT-NEXT: [[TMP10:%.*]] = call i64 @llvm.arm.smlaldx(i32 [[TMP1]], i32 [[TMP8]], i64 0) 64; CHECK-OPT-NEXT: [[TMP11:%.*]] = sext i16 [[TMP9]] to i32 65; CHECK-OPT-NEXT: [[TMP12:%.*]] = lshr i32 [[TMP8]], 16 66; CHECK-OPT-NEXT: [[TMP13:%.*]] = trunc i32 [[TMP12]] to i16 67; CHECK-OPT-NEXT: [[TMP14:%.*]] = sext i16 [[TMP13]] to i32 68; CHECK-OPT-NEXT: [[INCDEC_PTR3:%.*]] = getelementptr inbounds i16, i16* [[PSRCB]], i32 2 69; CHECK-OPT-NEXT: [[MUL:%.*]] = mul nsw i32 [[TMP11]], [[TMP3]] 70; CHECK-OPT-NEXT: [[CONV5:%.*]] = sext i32 [[MUL]] to i64 71; CHECK-OPT-NEXT: [[MUL13:%.*]] = mul nsw i32 [[TMP14]], [[TMP6]] 72; CHECK-OPT-NEXT: [[CONV14:%.*]] = sext i32 [[MUL13]] to i64 73; CHECK-OPT-NEXT: [[SUB:%.*]] = sub nsw i64 [[CONV5]], [[CONV14]] 74; CHECK-OPT-NEXT: [[TMP15:%.*]] = bitcast i16* [[INCDEC_PTR1]] to i32* 75; CHECK-OPT-NEXT: [[TMP16:%.*]] = load i32, i32* [[TMP15]], align 2 76; CHECK-OPT-NEXT: [[TMP17:%.*]] = trunc i32 [[TMP16]] to i16 77; CHECK-OPT-NEXT: [[TMP18:%.*]] = sext i16 [[TMP17]] to i32 78; CHECK-OPT-NEXT: [[TMP19:%.*]] = lshr i32 [[TMP16]], 16 79; CHECK-OPT-NEXT: [[TMP20:%.*]] = trunc i32 [[TMP19]] to i16 80; CHECK-OPT-NEXT: [[TMP21:%.*]] = sext i16 [[TMP20]] to i32 81; CHECK-OPT-NEXT: [[INCDEC_PTR21:%.*]] = getelementptr inbounds i16, i16* [[PSRCA]], i32 4 82; CHECK-OPT-NEXT: [[TMP22:%.*]] = bitcast i16* [[INCDEC_PTR3]] to i32* 83; CHECK-OPT-NEXT: [[TMP23:%.*]] = load i32, i32* [[TMP22]], align 2 84; CHECK-OPT-NEXT: [[TMP24:%.*]] = trunc i32 [[TMP23]] to i16 85; CHECK-OPT-NEXT: [[TMP25:%.*]] = call i64 @llvm.arm.smlaldx(i32 [[TMP16]], i32 [[TMP23]], i64 [[TMP10]]) 86; CHECK-OPT-NEXT: [[TMP26:%.*]] = sext i16 [[TMP24]] to i32 87; CHECK-OPT-NEXT: [[TMP27:%.*]] = lshr i32 [[TMP23]], 16 88; CHECK-OPT-NEXT: [[TMP28:%.*]] = trunc i32 [[TMP27]] to i16 89; CHECK-OPT-NEXT: [[TMP29:%.*]] = sext i16 [[TMP28]] to i32 90; CHECK-OPT-NEXT: [[INCDEC_PTR23:%.*]] = getelementptr inbounds i16, i16* [[PSRCB]], i32 4 91; CHECK-OPT-NEXT: [[MUL26:%.*]] = mul nsw i32 [[TMP26]], [[TMP18]] 92; CHECK-OPT-NEXT: [[CONV27:%.*]] = sext i32 [[MUL26]] to i64 93; CHECK-OPT-NEXT: [[ADD28:%.*]] = add nsw i64 [[SUB]], [[CONV27]] 94; CHECK-OPT-NEXT: [[MUL36:%.*]] = mul nsw i32 [[TMP29]], [[TMP21]] 95; CHECK-OPT-NEXT: [[CONV37:%.*]] = sext i32 [[MUL36]] to i64 96; CHECK-OPT-NEXT: [[SUB38:%.*]] = sub nsw i64 [[ADD28]], [[CONV37]] 97; CHECK-OPT-NEXT: [[TMP30:%.*]] = bitcast i16* [[INCDEC_PTR21]] to i32* 98; CHECK-OPT-NEXT: [[TMP31:%.*]] = load i32, i32* [[TMP30]], align 2 99; CHECK-OPT-NEXT: [[TMP32:%.*]] = trunc i32 [[TMP31]] to i16 100; CHECK-OPT-NEXT: [[TMP33:%.*]] = sext i16 [[TMP32]] to i32 101; CHECK-OPT-NEXT: [[TMP34:%.*]] = lshr i32 [[TMP31]], 16 102; CHECK-OPT-NEXT: [[TMP35:%.*]] = trunc i32 [[TMP34]] to i16 103; CHECK-OPT-NEXT: [[TMP36:%.*]] = sext i16 [[TMP35]] to i32 104; CHECK-OPT-NEXT: [[INCDEC_PTR45:%.*]] = getelementptr inbounds i16, i16* [[PSRCA]], i32 6 105; CHECK-OPT-NEXT: [[TMP37:%.*]] = bitcast i16* [[INCDEC_PTR23]] to i32* 106; CHECK-OPT-NEXT: [[TMP38:%.*]] = load i32, i32* [[TMP37]], align 2 107; CHECK-OPT-NEXT: [[TMP39:%.*]] = trunc i32 [[TMP38]] to i16 108; CHECK-OPT-NEXT: [[TMP40:%.*]] = call i64 @llvm.arm.smlaldx(i32 [[TMP31]], i32 [[TMP38]], i64 [[TMP25]]) 109; CHECK-OPT-NEXT: [[TMP41:%.*]] = sext i16 [[TMP39]] to i32 110; CHECK-OPT-NEXT: [[TMP42:%.*]] = lshr i32 [[TMP38]], 16 111; CHECK-OPT-NEXT: [[TMP43:%.*]] = trunc i32 [[TMP42]] to i16 112; CHECK-OPT-NEXT: [[TMP44:%.*]] = sext i16 [[TMP43]] to i32 113; CHECK-OPT-NEXT: [[INCDEC_PTR47:%.*]] = getelementptr inbounds i16, i16* [[PSRCB]], i32 6 114; CHECK-OPT-NEXT: [[MUL50:%.*]] = mul nsw i32 [[TMP41]], [[TMP33]] 115; CHECK-OPT-NEXT: [[CONV51:%.*]] = sext i32 [[MUL50]] to i64 116; CHECK-OPT-NEXT: [[ADD52:%.*]] = add nsw i64 [[SUB38]], [[CONV51]] 117; CHECK-OPT-NEXT: [[MUL60:%.*]] = mul nsw i32 [[TMP44]], [[TMP36]] 118; CHECK-OPT-NEXT: [[CONV61:%.*]] = sext i32 [[MUL60]] to i64 119; CHECK-OPT-NEXT: [[SUB62:%.*]] = sub nsw i64 [[ADD52]], [[CONV61]] 120; CHECK-OPT-NEXT: [[TMP45:%.*]] = bitcast i16* [[INCDEC_PTR45]] to i32* 121; CHECK-OPT-NEXT: [[TMP46:%.*]] = load i32, i32* [[TMP45]], align 2 122; CHECK-OPT-NEXT: [[TMP47:%.*]] = trunc i32 [[TMP46]] to i16 123; CHECK-OPT-NEXT: [[TMP48:%.*]] = sext i16 [[TMP47]] to i32 124; CHECK-OPT-NEXT: [[TMP49:%.*]] = lshr i32 [[TMP46]], 16 125; CHECK-OPT-NEXT: [[TMP50:%.*]] = trunc i32 [[TMP49]] to i16 126; CHECK-OPT-NEXT: [[TMP51:%.*]] = sext i16 [[TMP50]] to i32 127; CHECK-OPT-NEXT: [[TMP52:%.*]] = bitcast i16* [[INCDEC_PTR47]] to i32* 128; CHECK-OPT-NEXT: [[TMP53:%.*]] = load i32, i32* [[TMP52]], align 2 129; CHECK-OPT-NEXT: [[TMP54:%.*]] = trunc i32 [[TMP53]] to i16 130; CHECK-OPT-NEXT: [[TMP55:%.*]] = call i64 @llvm.arm.smlaldx(i32 [[TMP46]], i32 [[TMP53]], i64 [[TMP40]]) 131; CHECK-OPT-NEXT: [[TMP56:%.*]] = sext i16 [[TMP54]] to i32 132; CHECK-OPT-NEXT: [[TMP57:%.*]] = lshr i32 [[TMP53]], 16 133; CHECK-OPT-NEXT: [[TMP58:%.*]] = trunc i32 [[TMP57]] to i16 134; CHECK-OPT-NEXT: [[TMP59:%.*]] = sext i16 [[TMP58]] to i32 135; CHECK-OPT-NEXT: [[MUL74:%.*]] = mul nsw i32 [[TMP56]], [[TMP48]] 136; CHECK-OPT-NEXT: [[CONV75:%.*]] = sext i32 [[MUL74]] to i64 137; CHECK-OPT-NEXT: [[ADD76:%.*]] = add nsw i64 [[SUB62]], [[CONV75]] 138; CHECK-OPT-NEXT: [[MUL84:%.*]] = mul nsw i32 [[TMP59]], [[TMP51]] 139; CHECK-OPT-NEXT: [[CONV85:%.*]] = sext i32 [[MUL84]] to i64 140; CHECK-OPT-NEXT: [[SUB86:%.*]] = sub nsw i64 [[ADD76]], [[CONV85]] 141; CHECK-OPT-NEXT: [[TMP60:%.*]] = lshr i64 [[SUB86]], 6 142; CHECK-OPT-NEXT: [[CONV92:%.*]] = trunc i64 [[TMP60]] to i32 143; CHECK-OPT-NEXT: store i32 [[CONV92]], i32* [[REALRESULT:%.*]], align 4 144; CHECK-OPT-NEXT: [[TMP61:%.*]] = lshr i64 [[TMP55]], 6 145; CHECK-OPT-NEXT: [[CONV94:%.*]] = trunc i64 [[TMP61]] to i32 146; CHECK-OPT-NEXT: store i32 [[CONV94]], i32* [[IMAGRESULT:%.*]], align 4 147; CHECK-OPT-NEXT: ret void 148entry: 149 %incdec.ptr = getelementptr inbounds i16, i16* %pSrcA, i32 1 150 %0 = load i16, i16* %pSrcA, align 2 151 %incdec.ptr1 = getelementptr inbounds i16, i16* %pSrcA, i32 2 152 %1 = load i16, i16* %incdec.ptr, align 2 153 %incdec.ptr2 = getelementptr inbounds i16, i16* %pSrcB, i32 1 154 %2 = load i16, i16* %pSrcB, align 2 155 %incdec.ptr3 = getelementptr inbounds i16, i16* %pSrcB, i32 2 156 %3 = load i16, i16* %incdec.ptr2, align 2 157 %conv = sext i16 %0 to i32 158 %conv4 = sext i16 %2 to i32 159 %mul = mul nsw i32 %conv4, %conv 160 %conv5 = sext i32 %mul to i64 161 %conv7 = sext i16 %3 to i32 162 %mul8 = mul nsw i32 %conv7, %conv 163 %conv9 = sext i32 %mul8 to i64 164 %conv11 = sext i16 %1 to i32 165 %mul13 = mul nsw i32 %conv7, %conv11 166 %conv14 = sext i32 %mul13 to i64 167 %sub = sub nsw i64 %conv5, %conv14 168 %mul17 = mul nsw i32 %conv4, %conv11 169 %conv18 = sext i32 %mul17 to i64 170 %add19 = add nsw i64 %conv9, %conv18 171 %incdec.ptr20 = getelementptr inbounds i16, i16* %pSrcA, i32 3 172 %4 = load i16, i16* %incdec.ptr1, align 2 173 %incdec.ptr21 = getelementptr inbounds i16, i16* %pSrcA, i32 4 174 %5 = load i16, i16* %incdec.ptr20, align 2 175 %incdec.ptr22 = getelementptr inbounds i16, i16* %pSrcB, i32 3 176 %6 = load i16, i16* %incdec.ptr3, align 2 177 %incdec.ptr23 = getelementptr inbounds i16, i16* %pSrcB, i32 4 178 %7 = load i16, i16* %incdec.ptr22, align 2 179 %conv24 = sext i16 %4 to i32 180 %conv25 = sext i16 %6 to i32 181 %mul26 = mul nsw i32 %conv25, %conv24 182 %conv27 = sext i32 %mul26 to i64 183 %add28 = add nsw i64 %sub, %conv27 184 %conv30 = sext i16 %7 to i32 185 %mul31 = mul nsw i32 %conv30, %conv24 186 %conv32 = sext i32 %mul31 to i64 187 %conv34 = sext i16 %5 to i32 188 %mul36 = mul nsw i32 %conv30, %conv34 189 %conv37 = sext i32 %mul36 to i64 190 %sub38 = sub nsw i64 %add28, %conv37 191 %mul41 = mul nsw i32 %conv25, %conv34 192 %conv42 = sext i32 %mul41 to i64 193 %add33 = add nsw i64 %add19, %conv42 194 %add43 = add nsw i64 %add33, %conv32 195 %incdec.ptr44 = getelementptr inbounds i16, i16* %pSrcA, i32 5 196 %8 = load i16, i16* %incdec.ptr21, align 2 197 %incdec.ptr45 = getelementptr inbounds i16, i16* %pSrcA, i32 6 198 %9 = load i16, i16* %incdec.ptr44, align 2 199 %incdec.ptr46 = getelementptr inbounds i16, i16* %pSrcB, i32 5 200 %10 = load i16, i16* %incdec.ptr23, align 2 201 %incdec.ptr47 = getelementptr inbounds i16, i16* %pSrcB, i32 6 202 %11 = load i16, i16* %incdec.ptr46, align 2 203 %conv48 = sext i16 %8 to i32 204 %conv49 = sext i16 %10 to i32 205 %mul50 = mul nsw i32 %conv49, %conv48 206 %conv51 = sext i32 %mul50 to i64 207 %add52 = add nsw i64 %sub38, %conv51 208 %conv54 = sext i16 %11 to i32 209 %mul55 = mul nsw i32 %conv54, %conv48 210 %conv56 = sext i32 %mul55 to i64 211 %conv58 = sext i16 %9 to i32 212 %mul60 = mul nsw i32 %conv54, %conv58 213 %conv61 = sext i32 %mul60 to i64 214 %sub62 = sub nsw i64 %add52, %conv61 215 %mul65 = mul nsw i32 %conv49, %conv58 216 %conv66 = sext i32 %mul65 to i64 217 %add57 = add nsw i64 %add43, %conv66 218 %add67 = add nsw i64 %add57, %conv56 219 %incdec.ptr68 = getelementptr inbounds i16, i16* %pSrcA, i32 7 220 %12 = load i16, i16* %incdec.ptr45, align 2 221 %13 = load i16, i16* %incdec.ptr68, align 2 222 %incdec.ptr70 = getelementptr inbounds i16, i16* %pSrcB, i32 7 223 %14 = load i16, i16* %incdec.ptr47, align 2 224 %15 = load i16, i16* %incdec.ptr70, align 2 225 %conv72 = sext i16 %12 to i32 226 %conv73 = sext i16 %14 to i32 227 %mul74 = mul nsw i32 %conv73, %conv72 228 %conv75 = sext i32 %mul74 to i64 229 %add76 = add nsw i64 %sub62, %conv75 230 %conv78 = sext i16 %15 to i32 231 %mul79 = mul nsw i32 %conv78, %conv72 232 %conv80 = sext i32 %mul79 to i64 233 %conv82 = sext i16 %13 to i32 234 %mul84 = mul nsw i32 %conv78, %conv82 235 %conv85 = sext i32 %mul84 to i64 236 %sub86 = sub nsw i64 %add76, %conv85 237 %mul89 = mul nsw i32 %conv73, %conv82 238 %conv90 = sext i32 %mul89 to i64 239 %add81 = add nsw i64 %add67, %conv90 240 %add91 = add nsw i64 %add81, %conv80 241 %16 = lshr i64 %sub86, 6 242 %conv92 = trunc i64 %16 to i32 243 store i32 %conv92, i32* %realResult, align 4 244 %17 = lshr i64 %add91, 6 245 %conv94 = trunc i64 %17 to i32 246 store i32 %conv94, i32* %imagResult, align 4 247 ret void 248} 249