[llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri May 7 14:56:06 PDT 2004
Changes in directory llvm/lib/Target/X86:
InstSelectSimple.cpp updated: 1.245 -> 1.246
---
Log message:
Make comparisons against the null pointer as efficient as integer comparisons
against zero. In particular, don't emit:
mov %ESI, 0
cmp %ECX, %ESI
instead, emit:
test %ECX, %ECX
---
Diffs of the changes: (+8 -1)
Index: llvm/lib/Target/X86/InstSelectSimple.cpp
diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.245 llvm/lib/Target/X86/InstSelectSimple.cpp:1.246
--- llvm/lib/Target/X86/InstSelectSimple.cpp:1.245 Tue May 4 14:35:11 2004
+++ llvm/lib/Target/X86/InstSelectSimple.cpp Fri May 7 14:55:55 2004
@@ -829,7 +829,14 @@
unsigned Op0r = getReg(Op0, MBB, IP);
// Special case handling of: cmp R, i
- if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
+ if (isa<ConstantPointerNull>(Op1)) {
+ if (OpNum < 2) // seteq/setne -> test
+ BuildMI(*MBB, IP, X86::TEST32rr, 2).addReg(Op0r).addReg(Op0r);
+ else
+ BuildMI(*MBB, IP, X86::CMP32ri, 2).addReg(Op0r).addImm(0);
+ return OpNum;
+
+ } else if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
if (Class == cByte || Class == cShort || Class == cInt) {
unsigned Op1v = CI->getRawValue();
More information about the llvm-commits
mailing list