Skip to content

Commit

Permalink
[InstCombine] add fmul tests with shared operand; NFC
Browse files Browse the repository at this point in the history
Baseline tests for:
D102698
  • Loading branch information
rotateright committed May 26, 2021
1 parent 9e43b1e commit 01120fe
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
26 changes: 26 additions & 0 deletions llvm/test/Transforms/InstCombine/fmul-exp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,32 @@ define double @exp_a_exp_b_reassoc(double %a, double %b) {
ret double %mul
}

; TODO: Multiple uses, but only 1 user.

define double @exp_a_a(double %a) {
; CHECK-LABEL: @exp_a_a(
; CHECK-NEXT: [[T:%.*]] = call double @llvm.exp.f64(double [[A:%.*]])
; CHECK-NEXT: [[M:%.*]] = fmul reassoc double [[T]], [[T]]
; CHECK-NEXT: ret double [[M]]
;
%t = call double @llvm.exp.f64(double %a)
%m = fmul reassoc double %t, %t
ret double %m
}

define double @exp_a_a_extra_use(double %a) {
; CHECK-LABEL: @exp_a_a_extra_use(
; CHECK-NEXT: [[T:%.*]] = call double @llvm.exp.f64(double [[A:%.*]])
; CHECK-NEXT: call void @use(double [[T]])
; CHECK-NEXT: [[M:%.*]] = fmul reassoc double [[T]], [[T]]
; CHECK-NEXT: ret double [[M]]
;
%t = call double @llvm.exp.f64(double %a)
call void @use(double %t)
%m = fmul reassoc double %t, %t
ret double %m
}

; 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(
Expand Down
13 changes: 13 additions & 0 deletions llvm/test/Transforms/InstCombine/fmul-exp2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ define double @exp2_a_exp2_b_multiple_uses(double %a, double %b) {
ret double %mul
}

; TODO: Multiple uses, but only 1 user.

define double @exp2_a_a(double %a) {
; CHECK-LABEL: @exp2_a_a(
; CHECK-NEXT: [[T:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]])
; CHECK-NEXT: [[M:%.*]] = fmul reassoc double [[T]], [[T]]
; CHECK-NEXT: ret double [[M]]
;
%t = call double @llvm.exp2.f64(double %a)
%m = fmul reassoc double %t, %t
ret double %m
}

; 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(
Expand Down

0 comments on commit 01120fe

Please sign in to comment.