mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
41c8aefa76
Summary: For example: s6 = s0*s5; s2 = s6*s6 + s6; ... s4 = s6*s3; We notice that it is possible for s2 is folded to fma (s0, s5, fmul (s6 s6)). This only happens when Aggressive is true, otherwise hasOneUse() check already prevents from folding the multiplication with more uses. Test Plan: test/CodeGen/NVPTX/fma-assoc.ll Patch by Xuetian Weng Reviewers: hfinkel, apazos, jingyue, ohsallen, arsenm Subscribers: arsenm, jholewinski, llvm-commits Differential Revision: http://reviews.llvm.org/D11855 llvm-svn: 244649
39 lines
1.1 KiB
LLVM
39 lines
1.1 KiB
LLVM
; RUN: llc < %s -march=nvptx -mcpu=sm_20 -fp-contract=fast | FileCheck %s
|
|
|
|
define ptx_device float @t1_f32(float %x, float %y, float %z,
|
|
float %u, float %v) {
|
|
; CHECK: fma.rn.f32 %f{{[0-9]+}}, %f{{[0-9]+}}, %f{{[0-9]+}}, %f{{[0-9]+}};
|
|
; CHECK: fma.rn.f32 %f{{[0-9]+}}, %f{{[0-9]+}}, %f{{[0-9]+}}, %f{{[0-9]+}};
|
|
; CHECK: ret;
|
|
%a = fmul float %x, %y
|
|
%b = fmul float %u, %v
|
|
%c = fadd float %a, %b
|
|
%d = fadd float %c, %z
|
|
ret float %d
|
|
}
|
|
|
|
define ptx_device double @t1_f64(double %x, double %y, double %z,
|
|
double %u, double %v) {
|
|
; CHECK: fma.rn.f64 %fd{{[0-9]+}}, %fd{{[0-9]+}}, %fd{{[0-9]+}}, %fd{{[0-9]+}};
|
|
; CHECK: fma.rn.f64 %fd{{[0-9]+}}, %fd{{[0-9]+}}, %fd{{[0-9]+}}, %fd{{[0-9]+}};
|
|
; CHECK: ret;
|
|
%a = fmul double %x, %y
|
|
%b = fmul double %u, %v
|
|
%c = fadd double %a, %b
|
|
%d = fadd double %c, %z
|
|
ret double %d
|
|
}
|
|
|
|
define double @two_choices(double %val1, double %val2) {
|
|
; CHECK-LABEL: two_choices(
|
|
; CHECK: mul.f64
|
|
; CHECK-NOT: mul.f64
|
|
; CHECK: fma.rn.f64
|
|
%1 = fmul double %val1, %val2
|
|
%2 = fmul double %1, %1
|
|
%3 = fadd double %1, %2
|
|
|
|
ret double %3
|
|
}
|
|
|