From 99eb4685efada56574fc4a954038624be96457b8 Mon Sep 17 00:00:00 2001 From: Jingyue Wu Date: Tue, 11 Aug 2015 19:21:46 +0000 Subject: SelectionDAG: Prefer to combine multiplication with less uses for fma 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 --- llvm/test/CodeGen/NVPTX/fma-assoc.ll | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'llvm/test') diff --git a/llvm/test/CodeGen/NVPTX/fma-assoc.ll b/llvm/test/CodeGen/NVPTX/fma-assoc.ll index fc04c61dd69..80a08a86316 100644 --- a/llvm/test/CodeGen/NVPTX/fma-assoc.ll +++ b/llvm/test/CodeGen/NVPTX/fma-assoc.ll @@ -23,3 +23,16 @@ define ptx_device double @t1_f64(double %x, double %y, double %z, %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 +} + -- cgit v1.2.3