[llvm-commits] [llvm] r55214 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Dan Gohman gohman at apple.com
Fri Aug 22 18:06:51 PDT 2008


Author: djg
Date: Fri Aug 22 20:06:51 2008
New Revision: 55214

URL: http://llvm.org/viewvc/llvm-project?rev=55214&view=rev
Log:
Avoid creating shift-by-zero SDNodes in the common case of
i8* getelementptr. DAGCombine eliminates these, but this is
a fairly common case.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=55214&r1=55213&r2=55214&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Aug 22 20:06:51 2008
@@ -2814,16 +2814,17 @@
 
       // If this is a multiply by a power of two, turn it into a shl
       // immediately.  This is a very common case.
-      if (isPowerOf2_64(ElementSize)) {
-        unsigned Amt = Log2_64(ElementSize);
-        IdxN = DAG.getNode(ISD::SHL, N.getValueType(), IdxN,
-                           DAG.getConstant(Amt, TLI.getShiftAmountTy()));
-        N = DAG.getNode(ISD::ADD, N.getValueType(), N, IdxN);
-        continue;
+      if (ElementSize != 1) {
+        if (isPowerOf2_64(ElementSize)) {
+          unsigned Amt = Log2_64(ElementSize);
+          IdxN = DAG.getNode(ISD::SHL, N.getValueType(), IdxN,
+                             DAG.getConstant(Amt, TLI.getShiftAmountTy()));
+        } else {
+          SDValue Scale = DAG.getIntPtrConstant(ElementSize);
+          IdxN = DAG.getNode(ISD::MUL, N.getValueType(), IdxN, Scale);
+        }
       }
-      
-      SDValue Scale = DAG.getIntPtrConstant(ElementSize);
-      IdxN = DAG.getNode(ISD::MUL, N.getValueType(), IdxN, Scale);
+
       N = DAG.getNode(ISD::ADD, N.getValueType(), N, IdxN);
     }
   }





More information about the llvm-commits mailing list