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
172 lines
5.2 KiB
LLVM
172 lines
5.2 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc --mtriple=aarch64 < %s | FileCheck %s
|
|
|
|
; Test late AArch64 folding of ordered FCMP+CSEL patterns to fmaxnm/fminnm.
|
|
; Pattern: max(mul, 0.0) then min(result, 1.0)
|
|
; First fcmp/fcsel folds to fmaxnm, outer one does NOT fold as operands cannot
|
|
; be proven as non-sNaN.
|
|
define float @max_after_fmul(float %a, float %b) {
|
|
; CHECK-LABEL: max_after_fmul:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: movi d2, #0000000000000000
|
|
; CHECK-NEXT: fmul s0, s0, s1
|
|
; CHECK-NEXT: fmov s1, #1.00000000
|
|
; CHECK-NEXT: fmaxnm s0, s0, s2
|
|
; CHECK-NEXT: fcmp s0, s1
|
|
; CHECK-NEXT: fcsel s0, s0, s1, mi
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%mul = fmul float %a, %b
|
|
%cmp1 = fcmp nsz ogt float %mul, 0.000000e+00
|
|
%max = select i1 %cmp1, float %mul, float 0.000000e+00
|
|
%cmp2 = fcmp nsz olt float %max, 1.000000e+00
|
|
%min = select i1 %cmp2, float %max, float 1.000000e+00
|
|
ret float %min
|
|
}
|
|
|
|
; fadd input
|
|
define float @max_after_fadd(float %a, float %b) {
|
|
; CHECK-LABEL: max_after_fadd:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: movi d2, #0000000000000000
|
|
; CHECK-NEXT: fadd s0, s0, s1
|
|
; CHECK-NEXT: fmaxnm s0, s0, s2
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%add = fadd float %a, %b
|
|
%cmp = fcmp nsz ogt float %add, 0.000000e+00
|
|
%max = select i1 %cmp, float %add, float 0.000000e+00
|
|
ret float %max
|
|
}
|
|
|
|
; Double precision
|
|
define double @max_after_fmul_f64(double %a, double %b) {
|
|
; CHECK-LABEL: max_after_fmul_f64:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: movi d2, #0000000000000000
|
|
; CHECK-NEXT: fmul d0, d0, d1
|
|
; CHECK-NEXT: fmaxnm d0, d0, d2
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%mul = fmul double %a, %b
|
|
%cmp = fcmp nsz ogt double %mul, 0.000000e+00
|
|
%max = select i1 %cmp, double %mul, double 0.000000e+00
|
|
ret double %max
|
|
}
|
|
|
|
; Function argument: isKnownNeverSNaN returns false, so the fold is skipped.
|
|
define float @max_arg(float %x) {
|
|
; CHECK-LABEL: max_arg:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: movi d1, #0000000000000000
|
|
; CHECK-NEXT: fcmp s0, #0.0
|
|
; CHECK-NEXT: fcsel s0, s0, s1, gt
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%cmp = fcmp nsz ogt float %x, 0.000000e+00
|
|
%max = select i1 %cmp, float %x, float 0.000000e+00
|
|
ret float %max
|
|
}
|
|
|
|
; fmin with arg: isKnownNeverSNaN returns false, so the fold is skipped.
|
|
define float @min_arg(float %x) {
|
|
; CHECK-LABEL: min_arg:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: fmov s1, #1.00000000
|
|
; CHECK-NEXT: fcmp s0, s1
|
|
; CHECK-NEXT: fcsel s0, s0, s1, mi
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%cmp = fcmp nsz olt float %x, 1.000000e+00
|
|
%min = select i1 %cmp, float %x, float 1.000000e+00
|
|
ret float %min
|
|
}
|
|
|
|
; fmin with arithmetic input
|
|
define float @min_after_fmul(float %a, float %b) {
|
|
; CHECK-LABEL: min_after_fmul:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: fmul s0, s0, s1
|
|
; CHECK-NEXT: fmov s1, #1.00000000
|
|
; CHECK-NEXT: fminnm s0, s0, s1
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%mul = fmul float %a, %b
|
|
%cmp = fcmp nsz olt float %mul, 1.000000e+00
|
|
%min = select i1 %cmp, float %mul, float 1.000000e+00
|
|
ret float %min
|
|
}
|
|
|
|
; Negative: no nsz flag - cannot transform (signed zero mismatch)
|
|
define float @no_nsz(float %x) {
|
|
; CHECK-LABEL: no_nsz:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: movi d1, #0000000000000000
|
|
; CHECK-NEXT: fcmp s0, #0.0
|
|
; CHECK-NEXT: fcsel s0, s0, s1, gt
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%cmp = fcmp ogt float %x, 0.000000e+00
|
|
%max = select i1 %cmp, float %x, float 0.000000e+00
|
|
ret float %max
|
|
}
|
|
|
|
; Negative: unordered comparison - fold is NOT correct, skip.
|
|
define float @unordered_cmp(float %x) {
|
|
; CHECK-LABEL: unordered_cmp:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: movi d1, #0000000000000000
|
|
; CHECK-NEXT: fcmp s0, #0.0
|
|
; CHECK-NEXT: fcsel s0, s0, s1, hi
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%cmp = fcmp nsz ugt float %x, 0.000000e+00
|
|
%max = select i1 %cmp, float %x, float 0.000000e+00
|
|
ret float %max
|
|
}
|
|
|
|
; nsz on the setcc only (not the select) - should still work
|
|
define float @nsz_on_setcc_only(float %a, float %b) {
|
|
; CHECK-LABEL: nsz_on_setcc_only:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: movi d2, #0000000000000000
|
|
; CHECK-NEXT: fmul s0, s0, s1
|
|
; CHECK-NEXT: fmaxnm s0, s0, s2
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%mul = fmul float %a, %b
|
|
%cmp = fcmp nsz ogt float %mul, 0.000000e+00
|
|
%max = select i1 %cmp, float %mul, float 0.000000e+00
|
|
ret float %max
|
|
}
|
|
|
|
; GE (>=) with arithmetic input: folds to fmaxnm (same semantics as GT with nsz)
|
|
define float @max_oge(float %a, float %b) {
|
|
; CHECK-LABEL: max_oge:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: movi d2, #0000000000000000
|
|
; CHECK-NEXT: fmul s0, s0, s1
|
|
; CHECK-NEXT: fmaxnm s0, s0, s2
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%mul = fmul float %a, %b
|
|
%cmp = fcmp nsz oge float %mul, 0.000000e+00
|
|
%max = select i1 %cmp, float %mul, float 0.000000e+00
|
|
ret float %max
|
|
}
|
|
|
|
; LE (<=) with arithmetic input: folds to fminnm (same semantics as MI with nsz)
|
|
define float @min_ole(float %a, float %b) {
|
|
; CHECK-LABEL: min_ole:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: fmul s0, s0, s1
|
|
; CHECK-NEXT: fmov s1, #1.00000000
|
|
; CHECK-NEXT: fminnm s0, s0, s1
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%mul = fmul float %a, %b
|
|
%cmp = fcmp nsz ole float %mul, 1.000000e+00
|
|
%min = select i1 %cmp, float %mul, float 1.000000e+00
|
|
ret float %min
|
|
}
|