brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 8536512 Raw
70 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S                             | FileCheck %s --check-prefixes=ANY,NO-FLOAT-SHRINK3; RUN: opt < %s -passes=instcombine -enable-double-float-shrink -S | FileCheck %s --check-prefixes=ANY,DO-FLOAT-SHRINK4 5declare double @llvm.cos.f64(double)6declare float @llvm.cos.f32(float)7 8declare double @llvm.sin.f64(double)9declare float @llvm.sin.f32(float)10 11; cos -> cosf12 13define float @cos_no_fastmath(float %f) {14; NO-FLOAT-SHRINK-LABEL: @cos_no_fastmath(15; NO-FLOAT-SHRINK-NEXT:    [[D:%.*]] = fpext float [[F:%.*]] to double16; NO-FLOAT-SHRINK-NEXT:    [[RESULT:%.*]] = call double @llvm.cos.f64(double [[D]])17; NO-FLOAT-SHRINK-NEXT:    [[TRUNCATED_RESULT:%.*]] = fptrunc double [[RESULT]] to float18; NO-FLOAT-SHRINK-NEXT:    ret float [[TRUNCATED_RESULT]]19;20; DO-FLOAT-SHRINK-LABEL: @cos_no_fastmath(21; DO-FLOAT-SHRINK-NEXT:    [[TMP1:%.*]] = call float @llvm.cos.f32(float [[F:%.*]])22; DO-FLOAT-SHRINK-NEXT:    ret float [[TMP1]]23;24  %d = fpext float %f to double25  %result = call double @llvm.cos.f64(double %d)26  %truncated_result = fptrunc double %result to float27  ret float %truncated_result28}29 30define float @cos_fastmath(float %f) {31; ANY-LABEL: @cos_fastmath(32; ANY-NEXT:    [[TMP1:%.*]] = call fast float @llvm.cos.f32(float [[F:%.*]])33; ANY-NEXT:    ret float [[TMP1]]34;35  %d = fpext float %f to double36  %result = call fast double @llvm.cos.f64(double %d)37  %truncated_result = fptrunc double %result to float38  ret float %truncated_result39}40 41; sin -> sinf42 43define float @sin_no_fastmath(float %f) {44; NO-FLOAT-SHRINK-LABEL: @sin_no_fastmath(45; NO-FLOAT-SHRINK-NEXT:    [[D:%.*]] = fpext float [[F:%.*]] to double46; NO-FLOAT-SHRINK-NEXT:    [[RESULT:%.*]] = call double @llvm.sin.f64(double [[D]])47; NO-FLOAT-SHRINK-NEXT:    [[TRUNCATED_RESULT:%.*]] = fptrunc double [[RESULT]] to float48; NO-FLOAT-SHRINK-NEXT:    ret float [[TRUNCATED_RESULT]]49;50; DO-FLOAT-SHRINK-LABEL: @sin_no_fastmath(51; DO-FLOAT-SHRINK-NEXT:    [[TMP1:%.*]] = call float @llvm.sin.f32(float [[F:%.*]])52; DO-FLOAT-SHRINK-NEXT:    ret float [[TMP1]]53;54  %d = fpext float %f to double55  %result = call double @llvm.sin.f64(double %d)56  %truncated_result = fptrunc double %result to float57  ret float %truncated_result58}59 60define float @sin_fastmath(float %f) {61; ANY-LABEL: @sin_fastmath(62; ANY-NEXT:    [[TMP1:%.*]] = call fast float @llvm.sin.f32(float [[F:%.*]])63; ANY-NEXT:    ret float [[TMP1]]64;65  %d = fpext float %f to double66  %result = call fast double @llvm.sin.f64(double %d)67  %truncated_result = fptrunc double %result to float68  ret float %truncated_result69}70