[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Jan 19 09:30:01 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.41 -> 1.42
---
Log message:

Know some simple identities.  This improves codegen for (1LL << N).


---
Diffs of the changes:  (+13 -0)

Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.41 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.42
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.41	Tue Jan 18 13:26:36 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Wed Jan 19 11:29:49 2005
@@ -615,6 +615,19 @@
         std::swap(N1, N2);
       }
     }
+
+    switch (Opcode) {
+    default: break;
+    case ISD::SHL:    // shl  0, X -> 0
+      if (N1C->isNullValue()) return N1;
+      break;
+    case ISD::SRL:    // srl  0, X -> 0
+      if (N1C->isNullValue()) return N1;
+      break;
+    case ISD::SRA:    // sra -1, X -> -1
+      if (N1C->isAllOnesValue()) return N1;
+      break;
+    }
   }
 
   if (N2C) {






More information about the llvm-commits mailing list