brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 4c8cf7a Raw
51 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 42; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4declare double @erf(double)5declare double @cos(double)6declare double @fabs(double)7 8declare void @use(double) nounwind9 10; Check odd parity: -erf(-x) == erf(x)11define double @test_erf(double %x) {12; CHECK-LABEL: define double @test_erf(13; CHECK-SAME: double [[X:%.*]]) {14; CHECK-NEXT:    [[RES:%.*]] = tail call reassoc double @erf(double [[X]])15; CHECK-NEXT:    ret double [[RES]]16;17  %neg_x = fneg double %x18  %res = tail call reassoc double @erf(double %neg_x)19  %neg_res = fneg double %res20  ret double %neg_res21}22 23; Check even parity: cos(fabs(x)) == cos(x)24define double @test_cos_fabs(double %x) {25; CHECK-LABEL: define double @test_cos_fabs(26; CHECK-SAME: double [[X:%.*]]) {27; CHECK-NEXT:    [[RES:%.*]] = tail call reassoc double @cos(double [[X]])28; CHECK-NEXT:    ret double [[RES]]29;30  %fabs_res = call double @fabs(double %x)31  %res = tail call reassoc double @cos(double %fabs_res)32  ret double %res33}34 35; Do nothing in case of multi-use36define double @test_erf_multi_use(double %x) {37; CHECK-LABEL: define double @test_erf_multi_use(38; CHECK-SAME: double [[X:%.*]]) {39; CHECK-NEXT:    [[NEG_X:%.*]] = fneg double [[X]]40; CHECK-NEXT:    call void @use(double [[NEG_X]])41; CHECK-NEXT:    [[RES:%.*]] = call double @erf(double [[NEG_X]])42; CHECK-NEXT:    [[NEG_RES:%.*]] = fneg double [[RES]]43; CHECK-NEXT:    ret double [[NEG_RES]]44;45  %neg_x = fneg double %x46  call void @use(double %neg_x)47  %res = call double @erf(double %neg_x)48  %neg_res = fneg double %res49  ret double %neg_res50}51