From 174aa30c8252d57ab6ea299c9ef55ba0cd876661 Mon Sep 17 00:00:00 2001 From: Dmitry Venikov Date: Wed, 30 Jan 2019 09:49:25 +0000 Subject: [PATCH] Commit tests for changes in revision D41342 llvm-svn: 352613 --- llvm/test/Transforms/InstCombine/fmul-exp.ll | 89 +++++++++++++++++++++++++++ llvm/test/Transforms/InstCombine/fmul-exp2.ll | 89 +++++++++++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 llvm/test/Transforms/InstCombine/fmul-exp.ll create mode 100644 llvm/test/Transforms/InstCombine/fmul-exp2.ll diff --git a/llvm/test/Transforms/InstCombine/fmul-exp.ll b/llvm/test/Transforms/InstCombine/fmul-exp.ll new file mode 100644 index 0000000..50f9245 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/fmul-exp.ll @@ -0,0 +1,89 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -S -instcombine < %s | FileCheck %s + +declare double @llvm.exp.f64(double) nounwind readnone speculatable +declare void @use(double) + +; exp(a) * exp(b) no reassoc flags +define double @exp_a_exp_b(double %a, double %b) { +; CHECK-LABEL: @exp_a_exp_b( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP]], [[TMP1]] +; CHECK-NEXT: ret double [[MUL]] +; + %tmp = call double @llvm.exp.f64(double %a) + %tmp1 = call double @llvm.exp.f64(double %b) + %mul = fmul double %tmp, %tmp1 + ret double %mul +} + +; exp(a) * exp(b) reassoc, multiple uses +define double @exp_a_exp_b_multiple_uses(double %a, double %b) { +; CHECK-LABEL: @exp_a_exp_b_multiple_uses( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP]], [[TMP1]] +; CHECK-NEXT: call void @use(double [[TMP1]]) +; CHECK-NEXT: ret double [[MUL]] +; + %tmp = call double @llvm.exp.f64(double %a) + %tmp1 = call double @llvm.exp.f64(double %b) + %mul = fmul reassoc double %tmp, %tmp1 + call void @use(double %tmp1) + ret double %mul +} + +; exp(a) * exp(b) reassoc, both with multiple uses +define double @exp_a_exp_b_multiple_uses_both(double %a, double %b) { +; CHECK-LABEL: @exp_a_exp_b_multiple_uses_both( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP]], [[TMP1]] +; CHECK-NEXT: call void @use(double [[TMP]]) +; CHECK-NEXT: call void @use(double [[TMP1]]) +; CHECK-NEXT: ret double [[MUL]] +; + %tmp = call double @llvm.exp.f64(double %a) + %tmp1 = call double @llvm.exp.f64(double %b) + %mul = fmul reassoc double %tmp, %tmp1 + call void @use(double %tmp) + call void @use(double %tmp1) + ret double %mul +} + +; exp(a) * exp(b) => exp(a+b) with reassoc +define double @exp_a_exp_b_reassoc(double %a, double %b) { +; CHECK-LABEL: @exp_a_exp_b_reassoc( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP]], [[TMP1]] +; CHECK-NEXT: ret double [[MUL]] +; + %tmp = call double @llvm.exp.f64(double %a) + %tmp1 = call double @llvm.exp.f64(double %b) + %mul = fmul reassoc double %tmp, %tmp1 + ret double %mul +} + +; exp(a) * exp(b) * exp(c) * exp(d) => exp(a+b+c+d) with reassoc +define double @exp_a_exp_b_exp_c_exp_d_fast(double %a, double %b, double %c, double %d) { +; CHECK-LABEL: @exp_a_exp_b_exp_c_exp_d_fast( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP]], [[TMP1]] +; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp.f64(double [[C:%.*]]) +; CHECK-NEXT: [[MUL1:%.*]] = fmul reassoc double [[MUL]], [[TMP2]] +; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.exp.f64(double [[D:%.*]]) +; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc double [[MUL1]], [[TMP3]] +; CHECK-NEXT: ret double [[MUL2]] +; + %tmp = call double @llvm.exp.f64(double %a) + %tmp1 = call double @llvm.exp.f64(double %b) + %mul = fmul reassoc double %tmp, %tmp1 + %tmp2 = call double @llvm.exp.f64(double %c) + %mul1 = fmul reassoc double %mul, %tmp2 + %tmp3 = call double @llvm.exp.f64(double %d) + %mul2 = fmul reassoc double %mul1, %tmp3 + ret double %mul2 +} diff --git a/llvm/test/Transforms/InstCombine/fmul-exp2.ll b/llvm/test/Transforms/InstCombine/fmul-exp2.ll new file mode 100644 index 0000000..d65c32e --- /dev/null +++ b/llvm/test/Transforms/InstCombine/fmul-exp2.ll @@ -0,0 +1,89 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -S -instcombine < %s | FileCheck %s + +declare double @llvm.exp2.f64(double) nounwind readnone speculatable +declare void @use(double) + +; exp2(a) * exp2(b) no reassoc flags +define double @exp2_a_exp2_b(double %a, double %b) { +; CHECK-LABEL: @exp2_a_exp2_b( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP]], [[TMP1]] +; CHECK-NEXT: ret double [[MUL]] +; + %tmp = call double @llvm.exp2.f64(double %a) + %tmp1 = call double @llvm.exp2.f64(double %b) + %mul = fmul double %tmp, %tmp1 + ret double %mul +} + +; exp2(a) * exp2(b) reassoc, multiple uses +define double @exp2_a_exp2_b_multiple_uses(double %a, double %b) { +; CHECK-LABEL: @exp2_a_exp2_b_multiple_uses( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP]], [[TMP1]] +; CHECK-NEXT: call void @use(double [[TMP1]]) +; CHECK-NEXT: ret double [[MUL]] +; + %tmp = call double @llvm.exp2.f64(double %a) + %tmp1 = call double @llvm.exp2.f64(double %b) + %mul = fmul reassoc double %tmp, %tmp1 + call void @use(double %tmp1) + ret double %mul +} + +; exp2(a) * exp2(b) reassoc, both with multiple uses +define double @exp2_a_exp2_b_multiple_uses_both(double %a, double %b) { +; CHECK-LABEL: @exp2_a_exp2_b_multiple_uses_both( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP]], [[TMP1]] +; CHECK-NEXT: call void @use(double [[TMP]]) +; CHECK-NEXT: call void @use(double [[TMP1]]) +; CHECK-NEXT: ret double [[MUL]] +; + %tmp = call double @llvm.exp2.f64(double %a) + %tmp1 = call double @llvm.exp2.f64(double %b) + %mul = fmul reassoc double %tmp, %tmp1 + call void @use(double %tmp) + call void @use(double %tmp1) + ret double %mul +} + +; exp2(a) * exp2(b) => exp2(a+b) with reassoc +define double @exp2_a_exp2_b_reassoc(double %a, double %b) { +; CHECK-LABEL: @exp2_a_exp2_b_reassoc( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP]], [[TMP1]] +; CHECK-NEXT: ret double [[MUL]] +; + %tmp = call double @llvm.exp2.f64(double %a) + %tmp1 = call double @llvm.exp2.f64(double %b) + %mul = fmul reassoc double %tmp, %tmp1 + ret double %mul +} + +; exp2(a) * exp2(b) * exp2(c) * exp2(d) => exp2(a+b+c+d) with reassoc +define double @exp2_a_exp2_b_exp2_c_exp2_d(double %a, double %b, double %c, double %d) { +; CHECK-LABEL: @exp2_a_exp2_b_exp2_c_exp2_d( +; CHECK-NEXT: [[TMP:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[B:%.*]]) +; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[TMP]], [[TMP1]] +; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp2.f64(double [[C:%.*]]) +; CHECK-NEXT: [[MUL1:%.*]] = fmul reassoc double [[MUL]], [[TMP2]] +; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.exp2.f64(double [[D:%.*]]) +; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc double [[MUL1]], [[TMP3]] +; CHECK-NEXT: ret double [[MUL2]] +; + %tmp = call double @llvm.exp2.f64(double %a) + %tmp1 = call double @llvm.exp2.f64(double %b) + %mul = fmul reassoc double %tmp, %tmp1 + %tmp2 = call double @llvm.exp2.f64(double %c) + %mul1 = fmul reassoc double %mul, %tmp2 + %tmp3 = call double @llvm.exp2.f64(double %d) + %mul2 = fmul reassoc double %mul1, %tmp3 + ret double %mul2 +} -- 2.7.4