aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-10 00:08:04 +0000
committerChris Lattner <sabre@nondot.org>2007-05-10 00:08:04 +0000
commit0f1621bb4c597e9e857bd00927a903d9d36c9b9c (patch)
treeef6177af18a2a91f35c68d277fef38210a7e6482
parent7de291aa8c3b099bf5f4bbdfa65bc54f37b6a9a1 (diff)
add some notes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36965 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/README.txt28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt
index 9ab17dc3ee..477838d0e5 100644
--- a/lib/Target/X86/README.txt
+++ b/lib/Target/X86/README.txt
@@ -1094,5 +1094,33 @@ it should compile to a move from the stack slot directly into eax. DAGCombine
has this xform, but it is currently disabled until the alignment fields of
the load/store nodes are trustworthy.
+//===---------------------------------------------------------------------===//
+
+Sometimes it is better to codegen subtractions from a constant (e.g. 7-x) with
+a neg instead of a sub instruction. Consider:
+
+int test(char X) { return 7-X; }
+
+we currently produce:
+_test:
+ movl $7, %eax
+ movsbl 4(%esp), %ecx
+ subl %ecx, %eax
+ ret
+We would use one fewer register if codegen'd as:
+
+ movsbl 4(%esp), %eax
+ neg %eax
+ add $7, %eax
+ ret
+
+Note that this isn't beneficial if the load can be folded into the sub. In
+this case, we want a sub:
+
+int test(int X) { return 7-X; }
+_test:
+ movl $7, %eax
+ subl 4(%esp), %eax
+ ret