Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/AArch64/i128_with_overflow.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

351 lines
12 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -mtriple=aarch64 -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-SD
; RUN: llc -mtriple=aarch64 -global-isel -global-isel-abort=2 -o - %s 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
; CHECK-GI: warning: Instruction selection used fallback path for test_umul_i128
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for test_smul_i128
define i128 @test_uadd_i128(i128 noundef %x, i128 noundef %y) {
; CHECK-SD-LABEL: test_uadd_i128:
; CHECK-SD: // %bb.0: // %entry
; CHECK-SD-NEXT: adds x0, x0, x2
; CHECK-SD-NEXT: adcs x1, x1, x3
; CHECK-SD-NEXT: b.lo .LBB0_2
; CHECK-SD-NEXT: // %bb.1: // %if.then
; CHECK-SD-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-SD-NEXT: .cfi_def_cfa_offset 16
; CHECK-SD-NEXT: .cfi_offset w30, -16
; CHECK-SD-NEXT: bl error
; CHECK-SD-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-SD-NEXT: sxtw x0, w0
; CHECK-SD-NEXT: asr x1, x0, #63
; CHECK-SD-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-SD-NEXT: .LBB0_2: // %cleanup
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: test_uadd_i128:
; CHECK-GI: // %bb.0: // %entry
; CHECK-GI-NEXT: adds x0, x0, x2
; CHECK-GI-NEXT: adcs x1, x1, x3
; CHECK-GI-NEXT: b.lo .LBB0_2
; CHECK-GI-NEXT: // %bb.1: // %if.then
; CHECK-GI-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-GI-NEXT: .cfi_def_cfa_offset 16
; CHECK-GI-NEXT: .cfi_offset w30, -16
; CHECK-GI-NEXT: bl error
; CHECK-GI-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-GI-NEXT: asr w1, w0, #31
; CHECK-GI-NEXT: bfi x0, x1, #32, #32
; CHECK-GI-NEXT: bfi x1, x1, #32, #32
; CHECK-GI-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-GI-NEXT: .LBB0_2: // %cleanup
; CHECK-GI-NEXT: ret
entry:
%0 = tail call { i128, i1 } @llvm.uadd.with.overflow.i128(i128 %x, i128 %y)
%1 = extractvalue { i128, i1 } %0, 1
br i1 %1, label %if.then, label %if.end
if.then:
%call = tail call i32 @error()
%conv1 = sext i32 %call to i128
br label %cleanup
if.end:
%2 = extractvalue { i128, i1 } %0, 0
br label %cleanup
cleanup:
%retval.0 = phi i128 [ %conv1, %if.then ], [ %2, %if.end ]
ret i128 %retval.0
}
define i128 @test_sadd_i128(i128 noundef %x, i128 noundef %y) {
; CHECK-SD-LABEL: test_sadd_i128:
; CHECK-SD: // %bb.0: // %entry
; CHECK-SD-NEXT: adds x0, x0, x2
; CHECK-SD-NEXT: adcs x1, x1, x3
; CHECK-SD-NEXT: b.vc .LBB1_2
; CHECK-SD-NEXT: // %bb.1: // %if.then
; CHECK-SD-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-SD-NEXT: .cfi_def_cfa_offset 16
; CHECK-SD-NEXT: .cfi_offset w30, -16
; CHECK-SD-NEXT: bl error
; CHECK-SD-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-SD-NEXT: sxtw x0, w0
; CHECK-SD-NEXT: asr x1, x0, #63
; CHECK-SD-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-SD-NEXT: .LBB1_2: // %cleanup
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: test_sadd_i128:
; CHECK-GI: // %bb.0: // %entry
; CHECK-GI-NEXT: adds x0, x0, x2
; CHECK-GI-NEXT: adcs x1, x1, x3
; CHECK-GI-NEXT: b.vc .LBB1_2
; CHECK-GI-NEXT: // %bb.1: // %if.then
; CHECK-GI-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-GI-NEXT: .cfi_def_cfa_offset 16
; CHECK-GI-NEXT: .cfi_offset w30, -16
; CHECK-GI-NEXT: bl error
; CHECK-GI-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-GI-NEXT: asr w1, w0, #31
; CHECK-GI-NEXT: bfi x0, x1, #32, #32
; CHECK-GI-NEXT: bfi x1, x1, #32, #32
; CHECK-GI-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-GI-NEXT: .LBB1_2: // %cleanup
; CHECK-GI-NEXT: ret
entry:
%0 = tail call { i128, i1 } @llvm.sadd.with.overflow.i128(i128 %x, i128 %y)
%1 = extractvalue { i128, i1 } %0, 1
br i1 %1, label %if.then, label %if.end
if.then:
%call = tail call i32 @error()
%conv1 = sext i32 %call to i128
br label %cleanup
if.end:
%2 = extractvalue { i128, i1 } %0, 0
br label %cleanup
cleanup:
%retval.0 = phi i128 [ %conv1, %if.then ], [ %2, %if.end ]
ret i128 %retval.0
}
define i128 @test_usub_i128(i128 noundef %x, i128 noundef %y) {
; CHECK-SD-LABEL: test_usub_i128:
; CHECK-SD: // %bb.0: // %entry
; CHECK-SD-NEXT: subs x0, x0, x2
; CHECK-SD-NEXT: sbcs x1, x1, x3
; CHECK-SD-NEXT: b.hs .LBB2_2
; CHECK-SD-NEXT: // %bb.1: // %if.then
; CHECK-SD-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-SD-NEXT: .cfi_def_cfa_offset 16
; CHECK-SD-NEXT: .cfi_offset w30, -16
; CHECK-SD-NEXT: bl error
; CHECK-SD-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-SD-NEXT: sxtw x0, w0
; CHECK-SD-NEXT: asr x1, x0, #63
; CHECK-SD-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-SD-NEXT: .LBB2_2: // %cleanup
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: test_usub_i128:
; CHECK-GI: // %bb.0: // %entry
; CHECK-GI-NEXT: subs x0, x0, x2
; CHECK-GI-NEXT: sbcs x1, x1, x3
; CHECK-GI-NEXT: b.hs .LBB2_2
; CHECK-GI-NEXT: // %bb.1: // %if.then
; CHECK-GI-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-GI-NEXT: .cfi_def_cfa_offset 16
; CHECK-GI-NEXT: .cfi_offset w30, -16
; CHECK-GI-NEXT: bl error
; CHECK-GI-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-GI-NEXT: asr w1, w0, #31
; CHECK-GI-NEXT: bfi x0, x1, #32, #32
; CHECK-GI-NEXT: bfi x1, x1, #32, #32
; CHECK-GI-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-GI-NEXT: .LBB2_2: // %cleanup
; CHECK-GI-NEXT: ret
entry:
%0 = tail call { i128, i1 } @llvm.usub.with.overflow.i128(i128 %x, i128 %y)
%1 = extractvalue { i128, i1 } %0, 1
br i1 %1, label %if.then, label %if.end
if.then:
%call = tail call i32 @error()
%conv1 = sext i32 %call to i128
br label %cleanup
if.end:
%2 = extractvalue { i128, i1 } %0, 0
br label %cleanup
cleanup:
%retval.0 = phi i128 [ %conv1, %if.then ], [ %2, %if.end ]
ret i128 %retval.0
}
define i128 @test_ssub_i128(i128 noundef %x, i128 noundef %y) {
; CHECK-SD-LABEL: test_ssub_i128:
; CHECK-SD: // %bb.0: // %entry
; CHECK-SD-NEXT: subs x0, x0, x2
; CHECK-SD-NEXT: sbcs x1, x1, x3
; CHECK-SD-NEXT: b.vc .LBB3_2
; CHECK-SD-NEXT: // %bb.1: // %if.then
; CHECK-SD-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-SD-NEXT: .cfi_def_cfa_offset 16
; CHECK-SD-NEXT: .cfi_offset w30, -16
; CHECK-SD-NEXT: bl error
; CHECK-SD-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-SD-NEXT: sxtw x0, w0
; CHECK-SD-NEXT: asr x1, x0, #63
; CHECK-SD-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-SD-NEXT: .LBB3_2: // %cleanup
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: test_ssub_i128:
; CHECK-GI: // %bb.0: // %entry
; CHECK-GI-NEXT: subs x0, x0, x2
; CHECK-GI-NEXT: sbcs x1, x1, x3
; CHECK-GI-NEXT: b.vc .LBB3_2
; CHECK-GI-NEXT: // %bb.1: // %if.then
; CHECK-GI-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-GI-NEXT: .cfi_def_cfa_offset 16
; CHECK-GI-NEXT: .cfi_offset w30, -16
; CHECK-GI-NEXT: bl error
; CHECK-GI-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-GI-NEXT: asr w1, w0, #31
; CHECK-GI-NEXT: bfi x0, x1, #32, #32
; CHECK-GI-NEXT: bfi x1, x1, #32, #32
; CHECK-GI-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-GI-NEXT: .LBB3_2: // %cleanup
; CHECK-GI-NEXT: ret
entry:
%0 = tail call { i128, i1 } @llvm.ssub.with.overflow.i128(i128 %x, i128 %y)
%1 = extractvalue { i128, i1 } %0, 1
br i1 %1, label %if.then, label %if.end
if.then:
%call = tail call i32 @error()
%conv1 = sext i32 %call to i128
br label %cleanup
if.end:
%2 = extractvalue { i128, i1 } %0, 0
br label %cleanup
cleanup:
%retval.0 = phi i128 [ %conv1, %if.then ], [ %2, %if.end ]
ret i128 %retval.0
}
define i128 @test_umul_i128(i128 noundef %x, i128 noundef %y) {
; CHECK-LABEL: test_umul_i128:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: orr x8, x1, x3
; CHECK-NEXT: cbz x8, .LBB4_2
; CHECK-NEXT: // %bb.1: // %overflow
; CHECK-NEXT: mul x9, x3, x0
; CHECK-NEXT: cmp x1, #0
; CHECK-NEXT: ccmp x3, #0, #4, ne
; CHECK-NEXT: umulh x10, x1, x2
; CHECK-NEXT: umulh x8, x3, x0
; CHECK-NEXT: madd x9, x1, x2, x9
; CHECK-NEXT: ccmp xzr, x10, #0, eq
; CHECK-NEXT: umulh x11, x0, x2
; CHECK-NEXT: ccmp xzr, x8, #0, eq
; CHECK-NEXT: mul x0, x0, x2
; CHECK-NEXT: cset w8, ne
; CHECK-NEXT: adds x1, x11, x9
; CHECK-NEXT: csinc w8, w8, wzr, lo
; CHECK-NEXT: cbnz w8, .LBB4_3
; CHECK-NEXT: b .LBB4_4
; CHECK-NEXT: .LBB4_2: // %overflow.no
; CHECK-NEXT: umulh x1, x0, x2
; CHECK-NEXT: mul x0, x0, x2
; CHECK-NEXT: cbz w8, .LBB4_4
; CHECK-NEXT: .LBB4_3: // %if.then
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: bl error
; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-NEXT: sxtw x0, w0
; CHECK-NEXT: asr x1, x0, #63
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT: .LBB4_4: // %cleanup
; CHECK-NEXT: ret
entry:
%0 = tail call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %x, i128 %y)
%1 = extractvalue { i128, i1 } %0, 1
br i1 %1, label %if.then, label %if.end
if.then:
%call = tail call i32 @error()
%conv1 = sext i32 %call to i128
br label %cleanup
if.end:
%2 = extractvalue { i128, i1 } %0, 0
br label %cleanup
cleanup:
%retval.0 = phi i128 [ %conv1, %if.then ], [ %2, %if.end ]
ret i128 %retval.0
}
define i128 @test_smul_i128(i128 noundef %x, i128 noundef %y) {
; CHECK-LABEL: test_smul_i128:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: eor x8, x3, x2, asr #63
; CHECK-NEXT: eor x9, x1, x0, asr #63
; CHECK-NEXT: orr x8, x9, x8
; CHECK-NEXT: cbz x8, .LBB5_4
; CHECK-NEXT: // %bb.1: // %overflow
; CHECK-NEXT: asr x9, x1, #63
; CHECK-NEXT: umulh x10, x0, x2
; CHECK-NEXT: asr x13, x3, #63
; CHECK-NEXT: mul x11, x1, x2
; CHECK-NEXT: umulh x8, x1, x2
; CHECK-NEXT: mul x9, x9, x2
; CHECK-NEXT: adds x10, x11, x10
; CHECK-NEXT: mul x14, x0, x3
; CHECK-NEXT: umulh x12, x0, x3
; CHECK-NEXT: adc x8, x8, x9
; CHECK-NEXT: mov x9, x1
; CHECK-NEXT: mul x13, x0, x13
; CHECK-NEXT: asr x11, x8, #63
; CHECK-NEXT: mul x15, x1, x3
; CHECK-NEXT: adds x1, x14, x10
; CHECK-NEXT: smulh x9, x9, x3
; CHECK-NEXT: adc x10, x12, x13
; CHECK-NEXT: asr x12, x10, #63
; CHECK-NEXT: adds x8, x8, x10
; CHECK-NEXT: asr x10, x1, #63
; CHECK-NEXT: mul x0, x0, x2
; CHECK-NEXT: adc x11, x11, x12
; CHECK-NEXT: adds x8, x15, x8
; CHECK-NEXT: adc x9, x9, x11
; CHECK-NEXT: cmp x8, x10
; CHECK-NEXT: ccmp x9, x10, #0, eq
; CHECK-NEXT: cset w8, ne
; CHECK-NEXT: cbz w8, .LBB5_3
; CHECK-NEXT: .LBB5_2: // %if.then
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: bl error
; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
; CHECK-NEXT: sxtw x0, w0
; CHECK-NEXT: asr x1, x0, #63
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT: .LBB5_3: // %cleanup
; CHECK-NEXT: ret
; CHECK-NEXT: .LBB5_4: // %overflow.no
; CHECK-NEXT: smulh x1, x0, x2
; CHECK-NEXT: mul x0, x0, x2
; CHECK-NEXT: cbnz w8, .LBB5_2
; CHECK-NEXT: b .LBB5_3
entry:
%0 = tail call { i128, i1 } @llvm.smul.with.overflow.i128(i128 %x, i128 %y)
%1 = extractvalue { i128, i1 } %0, 1
br i1 %1, label %if.then, label %if.end
if.then:
%call = tail call i32 @error()
%conv1 = sext i32 %call to i128
br label %cleanup
if.end:
%2 = extractvalue { i128, i1 } %0, 0
br label %cleanup
cleanup:
%retval.0 = phi i128 [ %conv1, %if.then ], [ %2, %if.end ]
ret i128 %retval.0
}
declare i32 @error()