125 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=AARCH3 4define { i128, i8 } @muloti_test(i128 %l, i128 %r) unnamed_addr #0 {5; AARCH-LABEL: muloti_test:6; AARCH: // %bb.0: // %start7; AARCH-NEXT: orr x8, x1, x38; AARCH-NEXT: cbz x8, .LBB0_29; AARCH-NEXT: // %bb.1: // %overflow10; AARCH-NEXT: mul x9, x3, x011; AARCH-NEXT: cmp x1, #012; AARCH-NEXT: ccmp x3, #0, #4, ne13; AARCH-NEXT: umulh x10, x1, x214; AARCH-NEXT: umulh x8, x3, x015; AARCH-NEXT: madd x9, x1, x2, x916; AARCH-NEXT: ccmp xzr, x10, #0, eq17; AARCH-NEXT: umulh x11, x0, x218; AARCH-NEXT: ccmp xzr, x8, #0, eq19; AARCH-NEXT: mul x0, x0, x220; AARCH-NEXT: cset w8, ne21; AARCH-NEXT: adds x1, x11, x922; AARCH-NEXT: csinc w2, w8, wzr, lo23; AARCH-NEXT: ret24; AARCH-NEXT: .LBB0_2: // %overflow.no25; AARCH-NEXT: umulh x1, x0, x226; AARCH-NEXT: mul x0, x0, x227; AARCH-NEXT: mov w2, wzr28; AARCH-NEXT: ret29start:30 %0 = tail call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %l, i128 %r) #231 %1 = extractvalue { i128, i1 } %0, 032 %2 = extractvalue { i128, i1 } %0, 133 %3 = zext i1 %2 to i834 %4 = insertvalue { i128, i8 } undef, i128 %1, 035 %5 = insertvalue { i128, i8 } %4, i8 %3, 136 ret { i128, i8 } %537}38 39; PR5640340; We avoid lowering the intrinsic as a libcall because this function has the same name as41; the libcall we wanted to generate (that would create an infinite loop).42 43define i128 @__muloti4(i128 %0, i128 %1, ptr nocapture nonnull writeonly align 4 %2) #2 {44; AARCH-LABEL: __muloti4:45; AARCH: // %bb.0: // %Entry46; AARCH-NEXT: eor x8, x3, x2, asr #6347; AARCH-NEXT: eor x9, x1, x0, asr #6348; AARCH-NEXT: str wzr, [x4]49; AARCH-NEXT: orr x8, x9, x850; AARCH-NEXT: cbz x8, .LBB1_251; AARCH-NEXT: // %bb.1: // %overflow52; AARCH-NEXT: asr x9, x1, #6353; AARCH-NEXT: umulh x10, x0, x254; AARCH-NEXT: asr x13, x3, #6355; AARCH-NEXT: mul x11, x1, x256; AARCH-NEXT: umulh x8, x1, x257; AARCH-NEXT: mul x9, x9, x258; AARCH-NEXT: adds x10, x11, x1059; AARCH-NEXT: mul x14, x0, x360; AARCH-NEXT: umulh x12, x0, x361; AARCH-NEXT: adc x9, x8, x962; AARCH-NEXT: mul x13, x0, x1363; AARCH-NEXT: adds x8, x14, x1064; AARCH-NEXT: mul x15, x1, x365; AARCH-NEXT: smulh x10, x1, x366; AARCH-NEXT: adc x11, x12, x1367; AARCH-NEXT: asr x12, x9, #6368; AARCH-NEXT: asr x13, x11, #6369; AARCH-NEXT: adds x9, x9, x1170; AARCH-NEXT: asr x11, x8, #6371; AARCH-NEXT: mul x0, x0, x272; AARCH-NEXT: adc x12, x12, x1373; AARCH-NEXT: adds x9, x15, x974; AARCH-NEXT: adc x10, x10, x1275; AARCH-NEXT: cmp x9, x1176; AARCH-NEXT: ccmp x10, x11, #0, eq77; AARCH-NEXT: cset w9, ne78; AARCH-NEXT: tbnz x1, #63, .LBB1_379; AARCH-NEXT: b .LBB1_480; AARCH-NEXT: .LBB1_2: // %overflow.no81; AARCH-NEXT: smulh x8, x0, x282; AARCH-NEXT: mov w9, wzr83; AARCH-NEXT: mul x0, x0, x284; AARCH-NEXT: tbz x1, #63, .LBB1_485; AARCH-NEXT: .LBB1_3: // %overflow.res86; AARCH-NEXT: eor x10, x3, #0x800000000000000087; AARCH-NEXT: orr x10, x2, x1088; AARCH-NEXT: cbz x10, .LBB1_589; AARCH-NEXT: .LBB1_4: // %Else290; AARCH-NEXT: cbz w9, .LBB1_691; AARCH-NEXT: .LBB1_5: // %Then792; AARCH-NEXT: mov w9, #1 // =0x193; AARCH-NEXT: str w9, [x4]94; AARCH-NEXT: .LBB1_6: // %Block995; AARCH-NEXT: mov x1, x896; AARCH-NEXT: ret97Entry:98 store i32 0, ptr %2, align 499 %.fr = freeze i128 %1100 %mul = tail call { i128, i1 } @llvm.smul.with.overflow.i128(i128 %0, i128 %.fr)101 %3 = icmp slt i128 %0, 0102 %4 = icmp eq i128 %.fr, -170141183460469231731687303715884105728103 %5 = and i1 %3, %4104 br i1 %5, label %Then7, label %Else2105 106Else2: ; preds = %Entry107 %mul.ov = extractvalue { i128, i1 } %mul, 1108 br i1 %mul.ov, label %Then7, label %Block9109 110Then7: ; preds = %Else2, %Entry111 store i32 1, ptr %2, align 4112 br label %Block9113 114Block9: ; preds = %Else2, %Then7115 %mul.val = extractvalue { i128, i1 } %mul, 0116 ret i128 %mul.val117}118 119declare { i128, i1 } @llvm.umul.with.overflow.i128(i128, i128) #1120declare { i128, i1 } @llvm.smul.with.overflow.i128(i128, i128) #1121 122attributes #0 = { nounwind readnone uwtable }123attributes #1 = { nounwind readnone speculatable }124attributes #2 = { nounwind }125