Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/InstCombine/log-to-intrinsic.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

356 lines
10 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes=instcombine < %s | FileCheck %s
define float @test_logf_pos(float %f) {
; CHECK-LABEL: define float @test_logf_pos(
; CHECK-SAME: float [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt float [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call float @llvm.log.f32(float [[F]])
; CHECK-NEXT: ret float [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret float 0.000000e+00
;
entry:
%isinf = fcmp ole float %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call float @logf(float %f)
ret float %call
return:
ret float 0.0
}
define double @test_log_pos(double %f) {
; CHECK-LABEL: define double @test_log_pos(
; CHECK-SAME: double [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt double [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call double @llvm.log.f64(double [[F]])
; CHECK-NEXT: ret double [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret double 0.000000e+00
;
entry:
%isinf = fcmp ole double %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call double @log(double %f)
ret double %call
return:
ret double 0.0
}
define fp128 @test_logl_pos(fp128 %f) {
; CHECK-LABEL: define fp128 @test_logl_pos(
; CHECK-SAME: fp128 [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt fp128 [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call fp128 @llvm.log.f128(fp128 [[F]])
; CHECK-NEXT: ret fp128 [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret fp128 0.000000e+00
;
entry:
%isinf = fcmp ole fp128 %f, 0xL00000000000000000000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call fp128 @logl(fp128 %f)
ret fp128 %call
return:
ret fp128 0xL00000000000000000000000000000000
}
define float @test_log10f_pos(float %f) {
; CHECK-LABEL: define float @test_log10f_pos(
; CHECK-SAME: float [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt float [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call float @llvm.log10.f32(float [[F]])
; CHECK-NEXT: ret float [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret float 0.000000e+00
;
entry:
%isinf = fcmp ole float %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call float @log10f(float %f)
ret float %call
return:
ret float 0.0
}
define double @test_log10_pos(double %f) {
; CHECK-LABEL: define double @test_log10_pos(
; CHECK-SAME: double [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt double [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call double @llvm.log10.f64(double [[F]])
; CHECK-NEXT: ret double [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret double 0.000000e+00
;
entry:
%isinf = fcmp ole double %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call double @log10(double %f)
ret double %call
return:
ret double 0.0
}
define fp128 @test_log10l_pos(fp128 %f) {
; CHECK-LABEL: define fp128 @test_log10l_pos(
; CHECK-SAME: fp128 [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt fp128 [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call fp128 @llvm.log10.f128(fp128 [[F]])
; CHECK-NEXT: ret fp128 [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret fp128 0.000000e+00
;
entry:
%isinf = fcmp ole fp128 %f, 0xL00000000000000000000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call fp128 @log10l(fp128 %f)
ret fp128 %call
return:
ret fp128 0xL00000000000000000000000000000000
}
define float @test_log2f_pos(float %f) {
; CHECK-LABEL: define float @test_log2f_pos(
; CHECK-SAME: float [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt float [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call float @llvm.log2.f32(float [[F]])
; CHECK-NEXT: ret float [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret float 0.000000e+00
;
entry:
%isinf = fcmp ole float %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call float @log2f(float %f)
ret float %call
return:
ret float 0.0
}
define double @test_log2_pos(double %f) {
; CHECK-LABEL: define double @test_log2_pos(
; CHECK-SAME: double [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt double [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call double @llvm.log2.f64(double [[F]])
; CHECK-NEXT: ret double [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret double 0.000000e+00
;
entry:
%isinf = fcmp ole double %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call double @log2(double %f)
ret double %call
return:
ret double 0.0
}
define fp128 @test_log2l_pos(fp128 %f) {
; CHECK-LABEL: define fp128 @test_log2l_pos(
; CHECK-SAME: fp128 [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt fp128 [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call fp128 @llvm.log2.f128(fp128 [[F]])
; CHECK-NEXT: ret fp128 [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret fp128 0.000000e+00
;
entry:
%isinf = fcmp ole fp128 %f, 0xL00000000000000000000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call fp128 @log2l(fp128 %f)
ret fp128 %call
return:
ret fp128 0xL00000000000000000000000000000000
}
define double @test_logb_pos(double %f) {
; CHECK-LABEL: define double @test_logb_pos(
; CHECK-SAME: double [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt double [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call double @logb(double [[F]])
; CHECK-NEXT: ret double [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret double 0.000000e+00
;
entry:
%isinf = fcmp ole double %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call double @logb(double %f)
ret double %call
return:
ret double 0.0
}
define double @test_log1p_pos(double %f) {
; CHECK-LABEL: define double @test_log1p_pos(
; CHECK-SAME: double [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt double [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call double @log1p(double [[F]])
; CHECK-NEXT: ret double [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret double 0.000000e+00
;
entry:
%isinf = fcmp ole double %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call double @log1p(double %f)
ret double %call
return:
ret double 0.0
}
define float @metadata(float %f) {
; CHECK-LABEL: define float @metadata(
; CHECK-SAME: float [[F:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt float [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call float @llvm.log.f32(float [[F]]), !fpmath [[META0:![0-9]+]]
; CHECK-NEXT: ret float [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret float 0.000000e+00
;
entry:
%isinf = fcmp ole float %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call float @logf(float %f), !fpmath !0
ret float %call
return:
ret float 0.0
}
!0 = !{ float 2.5 }
define float @test_logf_pos_denormalpreserve(float %f) denormal_fpenv(preservesign) {
; CHECK-LABEL: define float @test_logf_pos_denormalpreserve(
; CHECK-SAME: float [[F:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt float [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call float @logf(float [[F]])
; CHECK-NEXT: ret float [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret float 0.000000e+00
;
entry:
%isinf = fcmp ole float %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call float @logf(float %f)
ret float %call
return:
ret float 0.0
}
define float @test_logf_pos_denormaldynamic(float %f) denormal_fpenv(dynamic) {
; CHECK-LABEL: define float @test_logf_pos_denormaldynamic(
; CHECK-SAME: float [[F:%.*]]) #[[ATTR1:[0-9]+]] {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[ISINF:%.*]] = fcmp ugt float [[F]], 0.000000e+00
; CHECK-NEXT: br i1 [[ISINF]], label %[[IF_END:.*]], label %[[RETURN:.*]]
; CHECK: [[IF_END]]:
; CHECK-NEXT: [[CALL:%.*]] = tail call float @logf(float [[F]])
; CHECK-NEXT: ret float [[CALL]]
; CHECK: [[RETURN]]:
; CHECK-NEXT: ret float 0.000000e+00
;
entry:
%isinf = fcmp ole float %f, 0x0000000000000000
br i1 %isinf, label %return, label %if.end
if.end:
%call = tail call float @logf(float %f)
ret float %call
return:
ret float 0.0
}
declare double @log(double)
declare float @logf(float)
declare fp128 @logl(fp128)
declare double @log10(double)
declare float @log10f(float)
declare fp128 @log10l(fp128)
declare double @log2(double)
declare float @log2f(float)
declare fp128 @log2l(fp128)
declare double @logb(double)
declare double @log1p(double)
;.
; CHECK: [[META0]] = !{float 2.500000e+00}
;.