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
192 lines
6.1 KiB
LLVM
192 lines
6.1 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
|
|
; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
|
|
;
|
|
; Verify that ADD(SBB(Y,0,flags),C) folds to SBB(Y,-C,flags).
|
|
; SBB(Y,0) = Y - CF; adding C gives Y - CF + C = Y - (-C) - CF = SBB(Y,-C).
|
|
;
|
|
|
|
; Fold should fire because all conditions are met
|
|
define i64 @g_i64(i64 %a, i64 %b) {
|
|
; CHECK-LABEL: g_i64:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: movq %rdi, %rax
|
|
; CHECK-NEXT: subq %rsi, %rax
|
|
; CHECK-NEXT: sbbq $-10, %rax
|
|
; CHECK-NEXT: retq
|
|
%ov = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
|
|
%val = extractvalue { i64, i1 } %ov, 0
|
|
%bit = extractvalue { i64, i1 } %ov, 1
|
|
%ext = sext i1 %bit to i64
|
|
%r = add i64 %val, %ext
|
|
%r2 = add i64 %r, 10
|
|
ret i64 %r2
|
|
}
|
|
|
|
; Fold should fire because all conditions are met
|
|
define i32 @g_i32(i32 %a, i32 %b) {
|
|
; CHECK-LABEL: g_i32:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: movl %edi, %eax
|
|
; CHECK-NEXT: subl %esi, %eax
|
|
; CHECK-NEXT: sbbl $-10, %eax
|
|
; CHECK-NEXT: retq
|
|
%ov = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
|
|
%val = extractvalue { i32, i1 } %ov, 0
|
|
%bit = extractvalue { i32, i1 } %ov, 1
|
|
%ext = sext i1 %bit to i32
|
|
%r = add i32 %val, %ext
|
|
%r2 = add i32 %r, 10
|
|
ret i32 %r2
|
|
}
|
|
|
|
; Non-constant addend, fold should still fire.
|
|
define i64 @g_nonconstant(i64 %a, i64 %b, i64 %c) {
|
|
; CHECK-LABEL: g_nonconstant:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: movq %rdi, %rax
|
|
; CHECK-NEXT: negq %rdx
|
|
; CHECK-NEXT: subq %rsi, %rax
|
|
; CHECK-NEXT: sbbq %rdx, %rax
|
|
; CHECK-NEXT: retq
|
|
%ov = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
|
|
%val = extractvalue { i64, i1 } %ov, 0
|
|
%bit = extractvalue { i64, i1 } %ov, 1
|
|
%ext = sext i1 %bit to i64
|
|
%r = add i64 %val, %ext
|
|
%r2 = add i64 %r, %c
|
|
ret i64 %r2
|
|
}
|
|
|
|
; Non-constant addend, fold should still fire.
|
|
define i32 @g_nonconstant_i32(i32 %a, i32 %b, i32 %c) {
|
|
; CHECK-LABEL: g_nonconstant_i32:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: movl %edi, %eax
|
|
; CHECK-NEXT: negl %edx
|
|
; CHECK-NEXT: subl %esi, %eax
|
|
; CHECK-NEXT: sbbl %edx, %eax
|
|
; CHECK-NEXT: retq
|
|
%ov = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
|
|
%val = extractvalue { i32, i1 } %ov, 0
|
|
%bit = extractvalue { i32, i1 } %ov, 1
|
|
%ext = sext i1 %bit to i32
|
|
%r = add i32 %val, %ext
|
|
%r2 = add i32 %r, %c
|
|
ret i32 %r2
|
|
}
|
|
|
|
; Non-constant addend in commuted form, fold should still fire.
|
|
define i64 @g_nonconstant_commuted(i64 %a, i64 %b, i64 %c) {
|
|
; CHECK-LABEL: g_nonconstant_commuted:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: movq %rdi, %rax
|
|
; CHECK-NEXT: negq %rdx
|
|
; CHECK-NEXT: subq %rsi, %rax
|
|
; CHECK-NEXT: sbbq %rdx, %rax
|
|
; CHECK-NEXT: retq
|
|
%ov = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
|
|
%val = extractvalue { i64, i1 } %ov, 0
|
|
%bit = extractvalue { i64, i1 } %ov, 1
|
|
%ext = sext i1 %bit to i64
|
|
%r = add i64 %val, %ext
|
|
%r2 = add i64 %c, %r
|
|
ret i64 %r2
|
|
}
|
|
|
|
; Non-constant addend in commuted form, fold should still fire.
|
|
define i32 @g_nonconstant_commuted_i32(i32 %a, i32 %b, i32 %c) {
|
|
; CHECK-LABEL: g_nonconstant_commuted_i32:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: movl %edi, %eax
|
|
; CHECK-NEXT: negl %edx
|
|
; CHECK-NEXT: subl %esi, %eax
|
|
; CHECK-NEXT: sbbl %edx, %eax
|
|
; CHECK-NEXT: retq
|
|
%ov = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
|
|
%val = extractvalue { i32, i1 } %ov, 0
|
|
%bit = extractvalue { i32, i1 } %ov, 1
|
|
%ext = sext i1 %bit to i32
|
|
%r = add i32 %val, %ext
|
|
%r2 = add i32 %c, %r
|
|
ret i32 %r2
|
|
}
|
|
|
|
; INT_MIN should fold correctly too.
|
|
define i32 @g_i32_int_min(i32 %a, i32 %b) {
|
|
; CHECK-LABEL: g_i32_int_min:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: movl %edi, %eax
|
|
; CHECK-NEXT: subl %esi, %eax
|
|
; CHECK-NEXT: sbbl $-2147483648, %eax # imm = 0x80000000
|
|
; CHECK-NEXT: retq
|
|
%ov = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
|
|
%val = extractvalue { i32, i1 } %ov, 0
|
|
%bit = extractvalue { i32, i1 } %ov, 1
|
|
%ext = sext i1 %bit to i32
|
|
%r = add i32 %val, %ext
|
|
%r2 = add i32 %r, -2147483648
|
|
ret i32 %r2
|
|
}
|
|
|
|
; Multiple uses of SBB result, fold should not fire
|
|
define i64 @g_multi_use(i64 %a, i64 %b, ptr %out) {
|
|
; CHECK-LABEL: g_multi_use:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: subq %rsi, %rdi
|
|
; CHECK-NEXT: sbbq $0, %rdi
|
|
; CHECK-NEXT: movq %rdi, (%rdx)
|
|
; CHECK-NEXT: leaq 10(%rdi), %rax
|
|
; CHECK-NEXT: retq
|
|
%ov = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
|
|
%val = extractvalue { i64, i1 } %ov, 0
|
|
%bit = extractvalue { i64, i1 } %ov, 1
|
|
%ext = sext i1 %bit to i64
|
|
%sbb = add i64 %val, %ext
|
|
store i64 %sbb, ptr %out
|
|
%r = add i64 %sbb, 10
|
|
ret i64 %r
|
|
}
|
|
|
|
; Multiple uses of SBB result, fold should not fire
|
|
define i32 @g_multi_use_i32(i32 %a, i32 %b, ptr %out) {
|
|
; CHECK-LABEL: g_multi_use_i32:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
|
|
; CHECK-NEXT: subl %esi, %edi
|
|
; CHECK-NEXT: sbbl $0, %edi
|
|
; CHECK-NEXT: movl %edi, (%rdx)
|
|
; CHECK-NEXT: leal 10(%rdi), %eax
|
|
; CHECK-NEXT: retq
|
|
%ov = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
|
|
%val = extractvalue { i32, i1 } %ov, 0
|
|
%bit = extractvalue { i32, i1 } %ov, 1
|
|
%ext = sext i1 %bit to i32
|
|
%sbb = add i32 %val, %ext
|
|
store i32 %sbb, ptr %out
|
|
%r = add i32 %sbb, 10
|
|
ret i32 %r
|
|
}
|
|
|
|
; Flags live across the low-limb constant add into the next SBB in the chain.
|
|
; Fold should not fire.
|
|
define {i64, i64} @g_flags_live(i64 %a_lo, i64 %a_hi, i64 %b_lo, i64 %b_hi) {
|
|
; CHECK-LABEL: g_flags_live:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: subq %rdx, %rdi
|
|
; CHECK-NEXT: leaq 10(%rdi), %rax
|
|
; CHECK-NEXT: sbbq %rcx, %rsi
|
|
; CHECK-NEXT: movq %rsi, %rdx
|
|
; CHECK-NEXT: retq
|
|
%lo = call { i8, i64 } @llvm.x86.subborrow.64(i8 0, i64 %a_lo, i64 %b_lo)
|
|
%lo_b = extractvalue { i8, i64 } %lo, 0
|
|
%lo_val = extractvalue { i8, i64 } %lo, 1
|
|
%lo_plus = add i64 %lo_val, 10
|
|
|
|
%hi = call { i8, i64 } @llvm.x86.subborrow.64(i8 %lo_b, i64 %a_hi, i64 %b_hi)
|
|
%hi_val = extractvalue { i8, i64 } %hi, 1
|
|
|
|
%ret = insertvalue {i64, i64} poison, i64 %lo_plus, 0
|
|
%ret2 = insertvalue {i64, i64} %ret, i64 %hi_val, 1
|
|
ret {i64, i64} %ret2
|
|
}
|