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
96 lines
3.5 KiB
LLVM
96 lines
3.5 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
|
|
; RUN: opt -passes=instcombine -S %s | FileCheck %s
|
|
|
|
; Regression case: atomicrmw sub with variable is left unchanged
|
|
define i64 @fn_sub(ptr %a, i64 %n) {
|
|
; CHECK-LABEL: define i64 @fn_sub(
|
|
; CHECK-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) {
|
|
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw sub ptr [[A]], i64 [[N]] monotonic, align 8
|
|
; CHECK-NEXT: ret i64 [[TMP1]]
|
|
;
|
|
%1 = atomicrmw sub ptr %a, i64 %n monotonic
|
|
ret i64 %1
|
|
}
|
|
|
|
; Canonicalize atomicrmw add(ptr, neg(n)) -> atomicrmw sub(ptr, n)
|
|
define i64 @fn_add(ptr %a, i64 %n) {
|
|
; CHECK-LABEL: define i64 @fn_add(
|
|
; CHECK-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) {
|
|
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw sub ptr [[A]], i64 [[N]] monotonic, align 8
|
|
; CHECK-NEXT: ret i64 [[TMP1]]
|
|
;
|
|
%sub = sub i64 0, %n
|
|
%1 = atomicrmw add ptr %a, i64 %sub monotonic
|
|
ret i64 %1
|
|
}
|
|
|
|
; Canonicalize atomicrmw add(ptr, neg(n)) -> atomicrmw sub(ptr, n)
|
|
; even when the negation is nsw
|
|
define i64 @fn_adds(ptr %a, i64 %n) {
|
|
; CHECK-LABEL: define i64 @fn_adds(
|
|
; CHECK-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) {
|
|
; CHECK-NEXT: [[OLD:%.*]] = atomicrmw sub ptr [[A]], i64 [[N]] monotonic, align 8
|
|
; CHECK-NEXT: ret i64 [[OLD]]
|
|
;
|
|
%neg = sub nsw i64 0, %n
|
|
%old = atomicrmw add ptr %a, i64 %neg monotonic
|
|
ret i64 %old
|
|
}
|
|
|
|
; Canonicalize atomicrmw sub(ptr, neg(n)) -> atomicrmw add(ptr, n)
|
|
define i64 @fn_sub_neg(ptr %a, i64 %n) {
|
|
; CHECK-LABEL: define i64 @fn_sub_neg(
|
|
; CHECK-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) {
|
|
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[A]], i64 [[N]] monotonic, align 8
|
|
; CHECK-NEXT: ret i64 [[TMP1]]
|
|
;
|
|
%neg = sub i64 0, %n
|
|
%1 = atomicrmw sub ptr %a, i64 %neg monotonic
|
|
ret i64 %1
|
|
}
|
|
|
|
; Don't canonicalize if the negated value has multiple uses -- as that would add an extra instruction.
|
|
define i64 @fn_add_1_with_use(ptr %a, i64 %n) {
|
|
; CHECK-LABEL: define i64 @fn_add_1_with_use(
|
|
; CHECK-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) {
|
|
; CHECK-NEXT: [[ADD:%.*]] = add i64 [[N]], 1
|
|
; CHECK-NEXT: call void @use(i64 [[ADD]])
|
|
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[A]], i64 [[ADD]] monotonic, align 8
|
|
; CHECK-NEXT: ret i64 [[TMP1]]
|
|
;
|
|
%add = add i64 %n, 1
|
|
call void @use(i64 %add)
|
|
%1 = atomicrmw add ptr %a, i64 %add monotonic
|
|
ret i64 %1
|
|
}
|
|
|
|
; Don't canonicalize atomicrmw sub(ptr, sub(a, b)) -> atomicrmw add(ptr, sub(b, a)),
|
|
; as that would create an infinite loop by continuously swapping the sub operands.
|
|
define i64 @fn_sub_of_two_vars(ptr %p, i64 %a, i64 %b) {
|
|
; CHECK-LABEL: define i64 @fn_sub_of_two_vars(
|
|
; CHECK-SAME: ptr [[P:%.*]], i64 [[A:%.*]], i64 [[B:%.*]]) {
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[A]], [[B]]
|
|
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw sub ptr [[P]], i64 [[SUB]] monotonic, align 8
|
|
; CHECK-NEXT: ret i64 [[TMP1]]
|
|
;
|
|
%sub = sub i64 %a, %b
|
|
%1 = atomicrmw sub ptr %p, i64 %sub monotonic
|
|
ret i64 %1
|
|
}
|
|
|
|
; Don't canonicalize atomicrmw add(ptr, sub(a, b)) -> atomicrmw sub(ptr, sub(b, a)),
|
|
; as that would create an infinite loop by continuously swapping the sub operands.
|
|
define i64 @fn_add_of_two_vars(ptr %p, i64 %a, i64 %b) {
|
|
; CHECK-LABEL: define i64 @fn_add_of_two_vars(
|
|
; CHECK-SAME: ptr [[P:%.*]], i64 [[A:%.*]], i64 [[B:%.*]]) {
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[A]], [[B]]
|
|
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[P]], i64 [[SUB]] monotonic, align 8
|
|
; CHECK-NEXT: ret i64 [[TMP1]]
|
|
;
|
|
%sub = sub i64 %a, %b
|
|
%1 = atomicrmw add ptr %p, i64 %sub monotonic
|
|
ret i64 %1
|
|
}
|
|
|
|
declare void @use(i64)
|