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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes=instcombine < %s | FileCheck %s
define double @fmul_tan_cos(double %a) {
; CHECK-LABEL: define double @fmul_tan_cos(
; CHECK-SAME: double [[A:%.*]]) {
; CHECK-NEXT: [[TAN:%.*]] = call double @llvm.tan.f64(double [[A]])
; CHECK-NEXT: [[COS:%.*]] = call double @llvm.cos.f64(double [[A]])
; CHECK-NEXT: [[RES:%.*]] = fmul double [[TAN]], [[COS]]
; CHECK-NEXT: ret double [[RES]]
;
%tan = call double @llvm.tan.f64(double %a)
%cos = call double @llvm.cos.f64(double %a)
%res = fmul double %tan, %cos
ret double %res
}
define double @fmul_strict_tan_strict_cos_contract(double %a) {
; CHECK-LABEL: define double @fmul_strict_tan_strict_cos_contract(
; CHECK-SAME: double [[A:%.*]]) {
; CHECK-NEXT: [[TAN:%.*]] = call double @llvm.tan.f64(double [[A]])
; CHECK-NEXT: [[COS:%.*]] = call contract double @llvm.cos.f64(double [[A]])
; CHECK-NEXT: [[RES:%.*]] = fmul double [[TAN]], [[COS]]
; CHECK-NEXT: ret double [[RES]]
;
%tan = call double @llvm.tan.f64(double %a)
%cos = call contract double @llvm.cos.f64(double %a)
%res = fmul double %tan, %cos
ret double %res
}
define double @fmul_contract_tan_strict_cos_strict(double %a) {
; CHECK-LABEL: define double @fmul_contract_tan_strict_cos_strict(
; CHECK-SAME: double [[A:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call contract double @llvm.sin.f64(double [[A]])
; CHECK-NEXT: ret double [[RES]]
;
%tan = call double @llvm.tan.f64(double %a)
%cos = call double @llvm.cos.f64(double %a)
%res = fmul contract double %tan, %cos
ret double %res
}
define double @fmul_contract_tan_contract_cos_strict(double %a) {
; CHECK-LABEL: define double @fmul_contract_tan_contract_cos_strict(
; CHECK-SAME: double [[A:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call contract double @llvm.sin.f64(double [[A]])
; CHECK-NEXT: ret double [[RES]]
;
%tan = call contract double @llvm.tan.f64(double %a)
%cos = call double @llvm.cos.f64(double %a)
%res = fmul contract double %tan, %cos
ret double %res
}
define double @fmul_tan_cos_contract_multiple_uses(double %a) {
; CHECK-LABEL: define double @fmul_tan_cos_contract_multiple_uses(
; CHECK-SAME: double [[A:%.*]]) {
; CHECK-NEXT: [[TAN:%.*]] = call contract double @llvm.tan.f64(double [[A]])
; CHECK-NEXT: [[COS:%.*]] = call contract double @llvm.cos.f64(double [[A]])
; CHECK-NEXT: [[RES:%.*]] = fmul contract double [[TAN]], [[COS]]
; CHECK-NEXT: call void @use(double [[COS]])
; CHECK-NEXT: ret double [[RES]]
;
%tan = call contract double @llvm.tan.f64(double %a)
%cos = call contract double @llvm.cos.f64(double %a)
%res = fmul contract double %tan, %cos
call void @use(double %cos)
ret double %res
}
define double @fmul_tan_cos_contract(double %a) {
; CHECK-LABEL: define double @fmul_tan_cos_contract(
; CHECK-SAME: double [[A:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call contract double @llvm.sin.f64(double [[A]])
; CHECK-NEXT: ret double [[RES]]
;
%tan = call contract double @llvm.tan.f64(double %a)
%cos = call contract double @llvm.cos.f64(double %a)
%res = fmul contract double %tan, %cos
ret double %res
}
define float @fmul_tanf_cosf_contract(float %a) {
; CHECK-LABEL: define float @fmul_tanf_cosf_contract(
; CHECK-SAME: float [[A:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call contract float @llvm.sin.f32(float [[A]])
; CHECK-NEXT: ret float [[RES]]
;
%tan = call contract float @llvm.tan.f32(float %a)
%cos = call contract float @llvm.cos.f32(float %a)
%res = fmul contract float %tan, %cos
ret float %res
}
define fp128 @fmul_tanfp128_cosfp128_contract(fp128 %a) {
; CHECK-LABEL: define fp128 @fmul_tanfp128_cosfp128_contract(
; CHECK-SAME: fp128 [[A:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call contract fp128 @llvm.sin.f128(fp128 [[A]])
; CHECK-NEXT: ret fp128 [[RES]]
;
%tan = call contract fp128 @llvm.tan.fp128(fp128 %a)
%cos = call contract fp128 @llvm.cos.fp128(fp128 %a)
%res = fmul contract fp128 %tan, %cos
ret fp128 %res
}
define double @commutativity_cos_tan(double %a) {
; CHECK-LABEL: define double @commutativity_cos_tan(
; CHECK-SAME: double [[A:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call contract double @llvm.sin.f64(double [[A]])
; CHECK-NEXT: ret double [[RES]]
;
%cos = call contract double @llvm.cos.f64(double %a)
%tan = call contract double @llvm.tan.f64(double %a)
%res = fmul contract double %cos, %tan
ret double %res
}
define double @tan_cos_value_mismatch(double %a, double %b) {
; CHECK-LABEL: define double @tan_cos_value_mismatch(
; CHECK-SAME: double [[A:%.*]], double [[B:%.*]]) {
; CHECK-NEXT: [[TAN:%.*]] = call contract double @llvm.tan.f64(double [[A]])
; CHECK-NEXT: [[COS:%.*]] = call contract double @llvm.cos.f64(double [[B]])
; CHECK-NEXT: [[RES:%.*]] = fmul contract double [[TAN]], [[COS]]
; CHECK-NEXT: ret double [[RES]]
;
%tan = call contract double @llvm.tan.f64(double %a)
%cos = call contract double @llvm.cos.f64(double %b)
%res = fmul contract double %tan, %cos
ret double %res
}
define <2 x double> @fmul_tan_cos_vector(<2 x double> %a) {
; CHECK-LABEL: define <2 x double> @fmul_tan_cos_vector(
; CHECK-SAME: <2 x double> [[A:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call contract <2 x double> @llvm.sin.v2f64(<2 x double> [[A]])
; CHECK-NEXT: ret <2 x double> [[RES]]
;
%tan = call contract <2 x double> @llvm.tan.v2f64(<2 x double> %a)
%cos = call contract <2 x double> @llvm.cos.v2f64(<2 x double> %a)
%res = fmul contract <2 x double> %tan, %cos
ret <2 x double> %res
}
define double @fmul_tan_cos_nnan_preservation(double %a) {
; CHECK-LABEL: define double @fmul_tan_cos_nnan_preservation(
; CHECK-SAME: double [[A:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call nnan contract double @llvm.sin.f64(double [[A]])
; CHECK-NEXT: ret double [[RES]]
;
%tan = call contract double @llvm.tan.f64(double %a)
%cos = call contract double @llvm.cos.f64(double %a)
%res = fmul contract nnan double %tan, %cos
ret double %res
}
define double @fmul_tan_cos_fpmath_metadata_preservation(double %a) {
; CHECK-LABEL: define double @fmul_tan_cos_fpmath_metadata_preservation(
; CHECK-SAME: double [[A:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call contract double @llvm.sin.f64(double [[A]]), !fpmath [[META0:![0-9]+]]
; CHECK-NEXT: ret double [[RES]]
;
%tan = call contract double @llvm.tan.f64(double %a)
%cos = call contract double @llvm.cos.f64(double %a)
%res = fmul contract double %tan, %cos, !fpmath !0
ret double %res
}
declare void @use(double)
!0 = !{ float 2.5 }
;.
; CHECK: [[META0]] = !{float 2.500000e+00}
;.
|