summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-24 20:01:41 +0000
committerChris Lattner <sabre@nondot.org>2010-01-24 20:01:41 +0000
commit10c4245103caa88e0b91b113bcdebc17f055585f (patch)
tree6a22bf4b20d45971bd14d52f05f8ae5190278993 /lib
parent4e4af5978c81073a18ef65e82454f6da0210e4c7 (diff)
downloadllvm-10c4245103caa88e0b91b113bcdebc17f055585f.tar.gz
llvm-10c4245103caa88e0b91b113bcdebc17f055585f.tar.bz2
llvm-10c4245103caa88e0b91b113bcdebc17f055585f.tar.xz
add a note.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/README.txt39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/Target/README.txt b/lib/Target/README.txt
index c68ae76a25..f4aa531ae0 100644
--- a/lib/Target/README.txt
+++ b/lib/Target/README.txt
@@ -156,6 +156,45 @@ void f () { /* this can be optimized to four additions... */
This requires reassociating to forms of expressions that are already available,
something that reassoc doesn't think about yet.
+
+//===---------------------------------------------------------------------===//
+
+This function: (derived from GCC PR19988)
+double foo(double x, double y) {
+ return ((x + 0.1234 * y) * (x + -0.1234 * y));
+}
+
+compiles to:
+_foo:
+ movapd %xmm1, %xmm2
+ mulsd LCPI1_1(%rip), %xmm1
+ mulsd LCPI1_0(%rip), %xmm2
+ addsd %xmm0, %xmm1
+ addsd %xmm0, %xmm2
+ movapd %xmm1, %xmm0
+ mulsd %xmm2, %xmm0
+ ret
+
+Instcombine should be able to turn it into:
+
+double foo(double x, double y) {
+ return ((x + 0.1234 * y) * (x - 0.1234 * y));
+}
+
+Which allows the multiply by constant to be CSE'd, producing:
+
+_foo:
+ mulsd LCPI1_0(%rip), %xmm1
+ movapd %xmm1, %xmm2
+ addsd %xmm0, %xmm2
+ subsd %xmm1, %xmm0
+ mulsd %xmm2, %xmm0
+ ret
+
+This doesn't need -ffast-math support at all. This is particularly bad because
+the llvm-gcc frontend is canonicalizing the later into the former, but clang
+doesn't have this problem.
+
//===---------------------------------------------------------------------===//
These two functions should generate the same code on big-endian systems: