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
225 lines
5.1 KiB
LLVM
225 lines
5.1 KiB
LLVM
; Test negative integer absolute.
|
|
;
|
|
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
|
|
|
|
; Test i32->i32 negative absolute using slt.
|
|
define i32 @f1(i32 %val) {
|
|
; CHECK-LABEL: f1:
|
|
; CHECK: lnr %r2, %r2
|
|
; CHECK: br %r14
|
|
%cmp = icmp slt i32 %val, 0
|
|
%neg = sub i32 0, %val
|
|
%abs = select i1 %cmp, i32 %neg, i32 %val
|
|
%res = sub i32 0, %abs
|
|
ret i32 %res
|
|
}
|
|
|
|
; Test i32->i32 negative absolute using sle.
|
|
define i32 @f2(i32 %val) {
|
|
; CHECK-LABEL: f2:
|
|
; CHECK: lnr %r2, %r2
|
|
; CHECK: br %r14
|
|
%cmp = icmp sle i32 %val, 0
|
|
%neg = sub i32 0, %val
|
|
%abs = select i1 %cmp, i32 %neg, i32 %val
|
|
%res = sub i32 0, %abs
|
|
ret i32 %res
|
|
}
|
|
|
|
; Test i32->i32 negative absolute using sgt.
|
|
define i32 @f3(i32 %val) {
|
|
; CHECK-LABEL: f3:
|
|
; CHECK: lnr %r2, %r2
|
|
; CHECK: br %r14
|
|
%cmp = icmp sgt i32 %val, 0
|
|
%neg = sub i32 0, %val
|
|
%abs = select i1 %cmp, i32 %val, i32 %neg
|
|
%res = sub i32 0, %abs
|
|
ret i32 %res
|
|
}
|
|
|
|
; Test i32->i32 negative absolute using sge.
|
|
define i32 @f4(i32 %val) {
|
|
; CHECK-LABEL: f4:
|
|
; CHECK: lnr %r2, %r2
|
|
; CHECK: br %r14
|
|
%cmp = icmp sge i32 %val, 0
|
|
%neg = sub i32 0, %val
|
|
%abs = select i1 %cmp, i32 %val, i32 %neg
|
|
%res = sub i32 0, %abs
|
|
ret i32 %res
|
|
}
|
|
|
|
; Test i32->i64 negative absolute.
|
|
define i64 @f5(i32 %val) {
|
|
; CHECK-LABEL: f5:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%ext = sext i32 %val to i64
|
|
%cmp = icmp slt i64 %ext, 0
|
|
%neg = sub i64 0, %ext
|
|
%abs = select i1 %cmp, i64 %neg, i64 %ext
|
|
%res = sub i64 0, %abs
|
|
ret i64 %res
|
|
}
|
|
|
|
; Test i32->i64 negative absolute that uses an "in-register" form of
|
|
; sign extension.
|
|
define i64 @f6(i64 %val) {
|
|
; CHECK-LABEL: f6:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%trunc = trunc i64 %val to i32
|
|
%ext = sext i32 %trunc to i64
|
|
%cmp = icmp slt i64 %ext, 0
|
|
%neg = sub i64 0, %ext
|
|
%abs = select i1 %cmp, i64 %neg, i64 %ext
|
|
%res = sub i64 0, %abs
|
|
ret i64 %res
|
|
}
|
|
|
|
; Test i64 negative absolute.
|
|
define i64 @f7(i64 %val) {
|
|
; CHECK-LABEL: f7:
|
|
; CHECK: lngr %r2, %r2
|
|
; CHECK: br %r14
|
|
%cmp = icmp slt i64 %val, 0
|
|
%neg = sub i64 0, %val
|
|
%abs = select i1 %cmp, i64 %neg, i64 %val
|
|
%res = sub i64 0, %abs
|
|
ret i64 %res
|
|
}
|
|
|
|
; Test another form of f6, which is that produced by InstCombine.
|
|
define i64 @f8(i64 %val) {
|
|
; CHECK-LABEL: f8:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%shl = shl i64 %val, 32
|
|
%ashr = ashr i64 %shl, 32
|
|
%neg = sub i64 0, %ashr
|
|
%cmp = icmp slt i64 %shl, 0
|
|
%abs = select i1 %cmp, i64 %neg, i64 %ashr
|
|
%res = sub i64 0, %abs
|
|
ret i64 %res
|
|
}
|
|
|
|
; Try again with sle rather than slt.
|
|
define i64 @f9(i64 %val) {
|
|
; CHECK-LABEL: f9:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%shl = shl i64 %val, 32
|
|
%ashr = ashr i64 %shl, 32
|
|
%neg = sub i64 0, %ashr
|
|
%cmp = icmp sle i64 %shl, 0
|
|
%abs = select i1 %cmp, i64 %neg, i64 %ashr
|
|
%res = sub i64 0, %abs
|
|
ret i64 %res
|
|
}
|
|
|
|
; Repeat f8 with the operands reversed.
|
|
define i64 @f10(i64 %val) {
|
|
; CHECK-LABEL: f10:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%shl = shl i64 %val, 32
|
|
%ashr = ashr i64 %shl, 32
|
|
%neg = sub i64 0, %ashr
|
|
%cmp = icmp sgt i64 %shl, 0
|
|
%abs = select i1 %cmp, i64 %ashr, i64 %neg
|
|
%res = sub i64 0, %abs
|
|
ret i64 %res
|
|
}
|
|
|
|
; Try again with sge rather than sgt.
|
|
define i64 @f11(i64 %val) {
|
|
; CHECK-LABEL: f11:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%shl = shl i64 %val, 32
|
|
%ashr = ashr i64 %shl, 32
|
|
%neg = sub i64 0, %ashr
|
|
%cmp = icmp sge i64 %shl, 0
|
|
%abs = select i1 %cmp, i64 %ashr, i64 %neg
|
|
%res = sub i64 0, %abs
|
|
ret i64 %res
|
|
}
|
|
|
|
; Repeat f8 with the negation coming from swapped operands.
|
|
define i64 @f12(i64 %val) {
|
|
; CHECK-LABEL: f12:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%shl = shl i64 %val, 32
|
|
%ashr = ashr i64 %shl, 32
|
|
%neg = sub i64 0, %ashr
|
|
%cmp = icmp slt i64 %shl, 0
|
|
%negabs = select i1 %cmp, i64 %ashr, i64 %neg
|
|
ret i64 %negabs
|
|
}
|
|
|
|
; Likewise f9.
|
|
define i64 @f13(i64 %val) {
|
|
; CHECK-LABEL: f13:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%shl = shl i64 %val, 32
|
|
%ashr = ashr i64 %shl, 32
|
|
%neg = sub i64 0, %ashr
|
|
%cmp = icmp sle i64 %shl, 0
|
|
%negabs = select i1 %cmp, i64 %ashr, i64 %neg
|
|
ret i64 %negabs
|
|
}
|
|
|
|
; Likewise f10.
|
|
define i64 @f14(i64 %val) {
|
|
; CHECK-LABEL: f14:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%shl = shl i64 %val, 32
|
|
%ashr = ashr i64 %shl, 32
|
|
%neg = sub i64 0, %ashr
|
|
%cmp = icmp sgt i64 %shl, 0
|
|
%negabs = select i1 %cmp, i64 %neg, i64 %ashr
|
|
ret i64 %negabs
|
|
}
|
|
|
|
; Likewise f11.
|
|
define i64 @f15(i64 %val) {
|
|
; CHECK-LABEL: f15:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%shl = shl i64 %val, 32
|
|
%ashr = ashr i64 %shl, 32
|
|
%neg = sub i64 0, %ashr
|
|
%cmp = icmp sge i64 %shl, 0
|
|
%negabs = select i1 %cmp, i64 %neg, i64 %ashr
|
|
ret i64 %negabs
|
|
}
|
|
|
|
; Repeat f5 with the comparison on the unextended value.
|
|
define i64 @f16(i32 %val) {
|
|
; CHECK-LABEL: f16:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%ext = sext i32 %val to i64
|
|
%cmp = icmp slt i32 %val, 0
|
|
%neg = sub i64 0, %ext
|
|
%abs = select i1 %cmp, i64 %neg, i64 %ext
|
|
%res = sub i64 0, %abs
|
|
ret i64 %res
|
|
}
|
|
|
|
; And again with the negation coming from swapped operands.
|
|
define i64 @f17(i32 %val) {
|
|
; CHECK-LABEL: f17:
|
|
; CHECK: lngfr %r2, %r2
|
|
; CHECK: br %r14
|
|
%ext = sext i32 %val to i64
|
|
%cmp = icmp slt i32 %val, 0
|
|
%neg = sub i64 0, %ext
|
|
%abs = select i1 %cmp, i64 %ext, i64 %neg
|
|
ret i64 %abs
|
|
}
|