Changes in directory llvm/lib/Target/X86:
README.txt updated: 1.167 -> 1.168 --- Log message: add some notes --- Diffs of the changes: (+28 -0) README.txt | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+) Index: llvm/lib/Target/X86/README.txt diff -u llvm/lib/Target/X86/README.txt:1.167 llvm/lib/Target/X86/README.txt:1.168 --- llvm/lib/Target/X86/README.txt:1.167 Sat May 5 17:10:24 2007 +++ llvm/lib/Target/X86/README.txt Wed May 9 19:08:04 2007 @@ -1094,5 +1094,33 @@ 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 _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits