[NFC] Precommit tests for D109954

This commit is contained in:
Dávid Bolvanský 2021-09-17 21:58:57 +02:00
parent c533b88a6d
commit d01e0c8c66
1 changed files with 182 additions and 0 deletions

View File

@ -2,8 +2,10 @@
; RUN: opt -instcombine -S < %s | FileCheck %s ; RUN: opt -instcombine -S < %s | FileCheck %s
declare double @llvm.powi.f64.i32(double, i32) declare double @llvm.powi.f64.i32(double, i32)
declare double @llvm.powi.f64.i64(double, i64)
declare double @llvm.fabs.f64(double) declare double @llvm.fabs.f64(double)
declare double @llvm.copysign.f64(double, double) declare double @llvm.copysign.f64(double, double)
declare void @use(double)
define double @powi_fneg_even_int(double %x) { define double @powi_fneg_even_int(double %x) {
; CHECK-LABEL: @powi_fneg_even_int( ; CHECK-LABEL: @powi_fneg_even_int(
@ -79,3 +81,183 @@ entry:
%r = tail call double @llvm.powi.f64.i32(double %cs, i32 5) %r = tail call double @llvm.powi.f64.i32(double %cs, i32 5)
ret double %r ret double %r
} }
define double @powi_fmul_arg0_no_reassoc(double %x, i32 %i) {
; CHECK-LABEL: @powi_fmul_arg0_no_reassoc(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[POW:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[I:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul double [[POW]], [[X]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%pow = tail call double @llvm.powi.f64.i32(double %x, i32 %i)
%mul = fmul double %pow, %x
ret double %mul
}
define double @powi_fmul_arg0(double %x, i32 %i) {
; CHECK-LABEL: @powi_fmul_arg0(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[POW:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[I:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[POW]], [[X]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%pow = tail call double @llvm.powi.f64.i32(double %x, i32 %i)
%mul = fmul reassoc double %pow, %x
ret double %mul
}
define double @powi_fmul_arg0_use(double %x, i32 %i) {
; CHECK-LABEL: @powi_fmul_arg0_use(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[POW:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[I:%.*]])
; CHECK-NEXT: tail call void @use(double [[POW]])
; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[POW]], [[X]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%pow = tail call double @llvm.powi.f64.i32(double %x, i32 %i)
tail call void @use(double %pow)
%mul = fmul reassoc double %pow, %x
ret double %mul
}
define double @powi_fmul_powi_no_reassoc(double %x, i32 %y, i32 %z) {
; CHECK-LABEL: @powi_fmul_powi_no_reassoc(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P1:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[Y:%.*]])
; CHECK-NEXT: [[P2:%.*]] = tail call double @llvm.powi.f64.i32(double [[X]], i32 [[Z:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul double [[P2]], [[P1]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%p1 = tail call double @llvm.powi.f64.i32(double %x, i32 %y)
%p2 = tail call double @llvm.powi.f64.i32(double %x, i32 %z)
%mul = fmul double %p2, %p1
ret double %mul
}
define double @powi_fmul_powi(double %x, i32 %y, i32 %z) {
; CHECK-LABEL: @powi_fmul_powi(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P1:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[Y:%.*]])
; CHECK-NEXT: [[P2:%.*]] = tail call double @llvm.powi.f64.i32(double [[X]], i32 [[Z:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[P2]], [[P1]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%p1 = tail call double @llvm.powi.f64.i32(double %x, i32 %y)
%p2 = tail call double @llvm.powi.f64.i32(double %x, i32 %z)
%mul = fmul reassoc double %p2, %p1
ret double %mul
}
define double @powi_fmul_powi_fast_on_fmul(double %x, i32 %y, i32 %z) {
; CHECK-LABEL: @powi_fmul_powi_fast_on_fmul(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P1:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[Y:%.*]])
; CHECK-NEXT: [[P2:%.*]] = tail call double @llvm.powi.f64.i32(double [[X]], i32 [[Z:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul fast double [[P2]], [[P1]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%p1 = tail call double @llvm.powi.f64.i32(double %x, i32 %y)
%p2 = tail call double @llvm.powi.f64.i32(double %x, i32 %z)
%mul = fmul fast double %p2, %p1
ret double %mul
}
define double @powi_fmul_powi_fast_on_powi(double %x, i32 %y, i32 %z) {
; CHECK-LABEL: @powi_fmul_powi_fast_on_powi(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P1:%.*]] = tail call fast double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[Y:%.*]])
; CHECK-NEXT: [[P2:%.*]] = tail call fast double @llvm.powi.f64.i32(double [[X]], i32 [[Z:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul double [[P2]], [[P1]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%p1 = tail call fast double @llvm.powi.f64.i32(double %x, i32 %y)
%p2 = tail call fast double @llvm.powi.f64.i32(double %x, i32 %z)
%mul = fmul double %p2, %p1
ret double %mul
}
define double @powi_fmul_powi_same_power(double %x, i32 %y, i32 %z) {
; CHECK-LABEL: @powi_fmul_powi_same_power(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P1:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[Y:%.*]])
; CHECK-NEXT: [[P2:%.*]] = tail call double @llvm.powi.f64.i32(double [[X]], i32 [[Y]])
; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[P2]], [[P1]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%p1 = tail call double @llvm.powi.f64.i32(double %x, i32 %y)
%p2 = tail call double @llvm.powi.f64.i32(double %x, i32 %y)
%mul = fmul reassoc double %p2, %p1
ret double %mul
}
define double @powi_fmul_powi_use_first(double %x, i32 %y, i32 %z) {
; CHECK-LABEL: @powi_fmul_powi_use_first(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P1:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[Y:%.*]])
; CHECK-NEXT: tail call void @use(double [[P1]])
; CHECK-NEXT: [[P2:%.*]] = tail call double @llvm.powi.f64.i32(double [[X]], i32 [[Z:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[P2]], [[P1]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%p1 = tail call double @llvm.powi.f64.i32(double %x, i32 %y)
tail call void @use(double %p1)
%p2 = tail call double @llvm.powi.f64.i32(double %x, i32 %z)
%mul = fmul reassoc double %p2, %p1
ret double %mul
}
define double @powi_fmul_powi_use_second(double %x, i32 %y, i32 %z) {
; CHECK-LABEL: @powi_fmul_powi_use_second(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P1:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[Z:%.*]])
; CHECK-NEXT: tail call void @use(double [[P1]])
; CHECK-NEXT: [[P2:%.*]] = tail call double @llvm.powi.f64.i32(double [[X]], i32 [[Y:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[P2]], [[P1]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%p1 = tail call double @llvm.powi.f64.i32(double %x, i32 %z)
tail call void @use(double %p1)
%p2 = tail call double @llvm.powi.f64.i32(double %x, i32 %y)
%mul = fmul reassoc double %p2, %p1
ret double %mul
}
define double @powi_fmul_different_base(double %x, double %m, i32 %y, i32 %z) {
; CHECK-LABEL: @powi_fmul_different_base(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P1:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[Y:%.*]])
; CHECK-NEXT: [[P2:%.*]] = tail call double @llvm.powi.f64.i32(double [[M:%.*]], i32 [[Z:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[P2]], [[P1]]
; CHECK-NEXT: ret double [[MUL]]
;
entry:
%p1 = tail call double @llvm.powi.f64.i32(double %x, i32 %y)
%p2 = tail call double @llvm.powi.f64.i32(double %m, i32 %z)
%mul = fmul reassoc double %p2, %p1
ret double %mul
}
define double @different_types_powi(double %x, i32 %y, i64 %z) {
; CHECK-LABEL: @different_types_powi(
; CHECK-NEXT: [[P1:%.*]] = tail call double @llvm.powi.f64.i32(double [[X:%.*]], i32 [[Y:%.*]])
; CHECK-NEXT: [[P2:%.*]] = tail call double @llvm.powi.f64.i64(double [[X]], i64 [[Z:%.*]])
; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[P2]], [[P1]]
; CHECK-NEXT: ret double [[MUL]]
;
%p1 = tail call double @llvm.powi.f64.i32(double %x, i32 %y)
%p2 = tail call double @llvm.powi.f64.i64(double %x, i64 %z)
%mul = fmul reassoc double %p2, %p1
ret double %mul
}