xref: /llvm-project/llvm/test/Transforms/EarlyCSE/math-2.ll (revision caa0e42ceb6e671d68b8b8e1d04f136696a4228b)
159f3b3d7SSanjay Patel; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2ac696ac4SBjorn Pettersson; RUN: opt -passes=early-cse -earlycse-debug-hash -S -o - %s | FileCheck %s
359f3b3d7SSanjay Patel
459f3b3d7SSanjay Pateldeclare double @atan2(double, double) #0
559f3b3d7SSanjay Pateldefine double @f_atan2() {
659f3b3d7SSanjay Patel; CHECK-LABEL: @f_atan2(
759f3b3d7SSanjay Patel; CHECK-NEXT:    ret double 0x3FDDAC6{{.+}}
859f3b3d7SSanjay Patel;
959f3b3d7SSanjay Patel  %res = tail call fast double @atan2(double 1.0, double 2.0)
1059f3b3d7SSanjay Patel  ret double %res
1159f3b3d7SSanjay Patel}
1259f3b3d7SSanjay Patel
1359f3b3d7SSanjay Pateldeclare float @fmodf(float, float) #0
1459f3b3d7SSanjay Pateldefine float @f_fmodf() {
1559f3b3d7SSanjay Patel; CHECK-LABEL: @f_fmodf(
1659f3b3d7SSanjay Patel; CHECK-NEXT:    ret float 1.000000e+00
1759f3b3d7SSanjay Patel;
1859f3b3d7SSanjay Patel  %res = tail call fast float @fmodf(float 1.0, float 2.0)
1959f3b3d7SSanjay Patel  ret float %res
2059f3b3d7SSanjay Patel}
2159f3b3d7SSanjay Patel
2259f3b3d7SSanjay Pateldeclare float @remainderf(float, float) #0
2359f3b3d7SSanjay Pateldefine float @f_remainderf_fold1() {
2459f3b3d7SSanjay Patel; CHECK-LABEL: @f_remainderf_fold1(
2559f3b3d7SSanjay Patel; CHECK-NEXT:    ret float 1.000000e+00
2659f3b3d7SSanjay Patel;
2759f3b3d7SSanjay Patel  %res = tail call fast float @remainderf(float 1.0, float 2.0)
2859f3b3d7SSanjay Patel  ret float %res
2959f3b3d7SSanjay Patel}
3059f3b3d7SSanjay Patel
3159f3b3d7SSanjay Pateldefine float @f_remainderf_fold2() {
3259f3b3d7SSanjay Patel; CHECK-LABEL: @f_remainderf_fold2(
3359f3b3d7SSanjay Patel; CHECK-NEXT:    ret float -5.000000e-01
3459f3b3d7SSanjay Patel;
3559f3b3d7SSanjay Patel  %res = tail call fast float @remainderf(float 1.5, float 1.0)
3659f3b3d7SSanjay Patel  ret float %res
3759f3b3d7SSanjay Patel}
3859f3b3d7SSanjay Patel
3959f3b3d7SSanjay Pateldefine float @f_remainderf_nofold() {
4059f3b3d7SSanjay Patel; CHECK-LABEL: @f_remainderf_nofold(
4159f3b3d7SSanjay Patel; CHECK-NEXT:    [[RES:%.*]] = tail call fast float @remainderf(float 1.000000e+00, float 0.000000e+00)
4259f3b3d7SSanjay Patel; CHECK-NEXT:    ret float [[RES]]
4359f3b3d7SSanjay Patel;
4459f3b3d7SSanjay Patel  %res = tail call fast float @remainderf(float 1.0, float 0.0)
4559f3b3d7SSanjay Patel  ret float %res
4659f3b3d7SSanjay Patel}
4759f3b3d7SSanjay Patel
4859f3b3d7SSanjay Pateldeclare double @remainder(double, double) #0
4959f3b3d7SSanjay Pateldefine double @f_remainder_fold1() {
5059f3b3d7SSanjay Patel; CHECK-LABEL: @f_remainder_fold1(
5159f3b3d7SSanjay Patel; CHECK-NEXT:    ret double 1.000000e+00
5259f3b3d7SSanjay Patel;
5359f3b3d7SSanjay Patel  %res = tail call fast double @remainder(double 1.0, double 2.0)
5459f3b3d7SSanjay Patel  ret double %res
5559f3b3d7SSanjay Patel}
5659f3b3d7SSanjay Patel
5759f3b3d7SSanjay Pateldefine double @f_remainder_fold2() {
5859f3b3d7SSanjay Patel; CHECK-LABEL: @f_remainder_fold2(
5959f3b3d7SSanjay Patel; CHECK-NEXT:    ret double -5.000000e-01
6059f3b3d7SSanjay Patel;
6159f3b3d7SSanjay Patel  %res = tail call fast double @remainder(double 1.5, double 1.0)
6259f3b3d7SSanjay Patel  ret double %res
6359f3b3d7SSanjay Patel}
6459f3b3d7SSanjay Patel
6559f3b3d7SSanjay Pateldefine double @f_remainder_nofold() {
6659f3b3d7SSanjay Patel; CHECK-LABEL: @f_remainder_nofold(
6759f3b3d7SSanjay Patel; CHECK-NEXT:    [[RES:%.*]] = tail call fast double @remainder(double 1.000000e+00, double 0.000000e+00)
6859f3b3d7SSanjay Patel; CHECK-NEXT:    ret double [[RES]]
6959f3b3d7SSanjay Patel;
7059f3b3d7SSanjay Patel  %res = tail call fast double @remainder(double 1.0, double 0.0)
7159f3b3d7SSanjay Patel  ret double %res
7259f3b3d7SSanjay Patel}
7359f3b3d7SSanjay Patel
7459f3b3d7SSanjay Pateldeclare double @pow(double, double) #0
7559f3b3d7SSanjay Pateldefine double @f_pow() {
7659f3b3d7SSanjay Patel; CHECK-LABEL: @f_pow(
7759f3b3d7SSanjay Patel; CHECK-NEXT:    ret double 1.000000e+00
7859f3b3d7SSanjay Patel;
7959f3b3d7SSanjay Patel  %res = tail call fast double @pow(double 1.0, double 2.0)
8059f3b3d7SSanjay Patel  ret double %res
8159f3b3d7SSanjay Patel}
8259f3b3d7SSanjay Patel
8359f3b3d7SSanjay Pateldeclare float @llvm.pow.f32(float, float)
8459f3b3d7SSanjay Pateldefine float @i_powf() {
8559f3b3d7SSanjay Patel; CHECK-LABEL: @i_powf(
8659f3b3d7SSanjay Patel; CHECK-NEXT:    ret float 1.000000e+00
8759f3b3d7SSanjay Patel;
8859f3b3d7SSanjay Patel  %res = tail call fast float @llvm.pow.f32(float 1.0, float 2.0)
8959f3b3d7SSanjay Patel  ret float %res
9059f3b3d7SSanjay Patel}
9159f3b3d7SSanjay Patel
9259f3b3d7SSanjay Pateldeclare double @llvm.powi.f64.i32(double, i32)
9359f3b3d7SSanjay Pateldefine double @i_powi() {
9459f3b3d7SSanjay Patel; CHECK-LABEL: @i_powi(
9559f3b3d7SSanjay Patel; CHECK-NEXT:    ret double 1.000000e+00
9659f3b3d7SSanjay Patel;
9759f3b3d7SSanjay Patel  %res = tail call fast double @llvm.powi.f64.i32(double 1.0, i32 2)
9859f3b3d7SSanjay Patel  ret double %res
9959f3b3d7SSanjay Patel}
10059f3b3d7SSanjay Patel
10134bfed63SYingwei Zheng; Make sure that the type is correct after constant folding
10234bfed63SYingwei Zheng
10334bfed63SYingwei Zhengdefine half @pr98665() {
10434bfed63SYingwei Zheng; CHECK-LABEL: @pr98665(
10534bfed63SYingwei Zheng; CHECK-NEXT:    ret half 0xH3C00
10634bfed63SYingwei Zheng;
10734bfed63SYingwei Zheng  %x = call half @llvm.powi.f16.i32(half 0xH3C00, i32 1)
10834bfed63SYingwei Zheng  ret half %x
10934bfed63SYingwei Zheng}
11034bfed63SYingwei Zheng
111*caa0e42cSYingwei Zhengdefine float @powi_f32() {
112*caa0e42cSYingwei Zheng; CHECK-LABEL: @powi_f32(
113*caa0e42cSYingwei Zheng; CHECK-NEXT:    ret float 0.000000e+00
114*caa0e42cSYingwei Zheng;
115*caa0e42cSYingwei Zheng  %y = call float @llvm.powi.f32.i32(float 0.0, i32 10)
116*caa0e42cSYingwei Zheng  ret float %y
117*caa0e42cSYingwei Zheng}
118*caa0e42cSYingwei Zheng
11959f3b3d7SSanjay Patelattributes #0 = { nofree nounwind willreturn }
120