[llvm-bugs] [Bug 32939] New: [DAGCombine] Missed A + -2.0*B*C -> A - (B+B)*C
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 5 07:44:50 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32939
Bug ID: 32939
Summary: [DAGCombine] Missed A + -2.0*B*C -> A - (B+B)*C
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: mcrosier at codeaurora.org
CC: llvm-bugs at lists.llvm.org
Given the following C code
double test1(double a, double b, double c) {
return a + 2.0*b*c;
}
Clang removes a multiply by transforming '2.0*b' to 'b+b' during DAGCombine.
For example, we generate the following when targeting AArch64:
test1: // @test1
fadd d1, d1, d1
fmul d1, d1, d2
fadd d0, d1, d0
ret
Given the below code
double test2(double a, double b, double c) {
return a + -2.0*b*c;
}
we should be able to perform a similar transform if we can remove the negative
constant by converting the addition into subtraction.
Currently we generate the below when targeting AArch64:
test2: // @test2
fmov d3, #-2.00000000
fmul d1, d1, d3
fmul d1, d1, d2
fadd d0, d1, d0
ret
but I'd expect
test2: // @test2
fadd d1, d1, d1
fmul d1, d1, d2
fsub d0, d1, d0
ret
AFAIK, this doesn't require fast-math.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170505/34e7f582/attachment.html>
More information about the llvm-bugs
mailing list