[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat May 14 22:39:25 PDT 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAG.cpp updated: 1.118 -> 1.119
---
Log message:
Add some simplifications for MULH[SU]. This allows us to compile this:
long %bar(long %X) {
%Y = mul long %X, 4294967297
ret long %Y
}
to this:
l1_bar:
mov %EAX, DWORD PTR [%ESP + 4]
mov %EDX, %EAX
add %EDX, DWORD PTR [%ESP + 8]
ret
instead of:
l1_bar:
mov %ECX, DWORD PTR [%ESP + 4]
mov %EDX, 1
mov %EAX, %ECX
mul %EDX
add %EDX, %ECX
add %EDX, DWORD PTR [%ESP + 8]
mov %EAX, %ECX
ret
---
Diffs of the changes: (+12 -0)
SelectionDAG.cpp | 12 ++++++++++++
1 files changed, 12 insertions(+)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.118 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.119
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.118 Sat May 14 02:45:46 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun May 15 00:39:08 2005
@@ -843,6 +843,8 @@
case ISD::XOR:
case ISD::UDIV:
case ISD::UREM:
+ case ISD::MULHU:
+ case ISD::MULHS:
assert(MVT::isInteger(VT) && "This operator does not apply to FP types!");
// fall through
case ISD::ADD:
@@ -941,6 +943,16 @@
}
break;
+ case ISD::MULHU:
+ case ISD::MULHS:
+ if (!C2) return N2; // mul X, 0 -> 0
+
+ if (C2 == 1) // 0X*01 -> 0X hi(0X) == 0
+ return getConstant(0, VT);
+
+ // Many others could be handled here, including -1, powers of 2, etc.
+ break;
+
case ISD::UDIV:
// FIXME: Move this to the DAG combiner when it exists.
if ((C2 & C2-1) == 0 && C2) {
More information about the llvm-commits
mailing list