1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instcombine -S | FileCheck %s --check-prefixes=ANY,NO-FLOAT-SHRINK
; RUN: opt < %s -passes=instcombine -enable-double-float-shrink -S | FileCheck %s --check-prefixes=ANY,DO-FLOAT-SHRINK
declare double @llvm.cos.f64(double)
declare float @llvm.cos.f32(float)
declare double @llvm.sin.f64(double)
declare float @llvm.sin.f32(float)
; cos -> cosf
define float @cos_no_fastmath(float %f) {
; NO-FLOAT-SHRINK-LABEL: @cos_no_fastmath(
; NO-FLOAT-SHRINK-NEXT: [[D:%.*]] = fpext float [[F:%.*]] to double
; NO-FLOAT-SHRINK-NEXT: [[RESULT:%.*]] = call double @llvm.cos.f64(double [[D]])
; NO-FLOAT-SHRINK-NEXT: [[TRUNCATED_RESULT:%.*]] = fptrunc double [[RESULT]] to float
; NO-FLOAT-SHRINK-NEXT: ret float [[TRUNCATED_RESULT]]
;
; DO-FLOAT-SHRINK-LABEL: @cos_no_fastmath(
; DO-FLOAT-SHRINK-NEXT: [[TMP1:%.*]] = call float @llvm.cos.f32(float [[F:%.*]])
; DO-FLOAT-SHRINK-NEXT: ret float [[TMP1]]
;
%d = fpext float %f to double
%result = call double @llvm.cos.f64(double %d)
%truncated_result = fptrunc double %result to float
ret float %truncated_result
}
define float @cos_fastmath(float %f) {
; ANY-LABEL: @cos_fastmath(
; ANY-NEXT: [[TMP1:%.*]] = call fast float @llvm.cos.f32(float [[F:%.*]])
; ANY-NEXT: ret float [[TMP1]]
;
%d = fpext float %f to double
%result = call fast double @llvm.cos.f64(double %d)
%truncated_result = fptrunc double %result to float
ret float %truncated_result
}
; sin -> sinf
define float @sin_no_fastmath(float %f) {
; NO-FLOAT-SHRINK-LABEL: @sin_no_fastmath(
; NO-FLOAT-SHRINK-NEXT: [[D:%.*]] = fpext float [[F:%.*]] to double
; NO-FLOAT-SHRINK-NEXT: [[RESULT:%.*]] = call double @llvm.sin.f64(double [[D]])
; NO-FLOAT-SHRINK-NEXT: [[TRUNCATED_RESULT:%.*]] = fptrunc double [[RESULT]] to float
; NO-FLOAT-SHRINK-NEXT: ret float [[TRUNCATED_RESULT]]
;
; DO-FLOAT-SHRINK-LABEL: @sin_no_fastmath(
; DO-FLOAT-SHRINK-NEXT: [[TMP1:%.*]] = call float @llvm.sin.f32(float [[F:%.*]])
; DO-FLOAT-SHRINK-NEXT: ret float [[TMP1]]
;
%d = fpext float %f to double
%result = call double @llvm.sin.f64(double %d)
%truncated_result = fptrunc double %result to float
ret float %truncated_result
}
define float @sin_fastmath(float %f) {
; ANY-LABEL: @sin_fastmath(
; ANY-NEXT: [[TMP1:%.*]] = call fast float @llvm.sin.f32(float [[F:%.*]])
; ANY-NEXT: ret float [[TMP1]]
;
%d = fpext float %f to double
%result = call fast double @llvm.sin.f64(double %d)
%truncated_result = fptrunc double %result to float
ret float %truncated_result
}
|