[llvm] r289646 - Add a couple of assertions to the load combine code introduced by r289538

Artur Pilipenko via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 14 03:55:48 PST 2016


Author: apilipenko
Date: Wed Dec 14 05:55:47 2016
New Revision: 289646

URL: http://llvm.org/viewvc/llvm-project?rev=289646&view=rev
Log:
Add a couple of assertions to the load combine code introduced by r289538

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

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=289646&r1=289645&r2=289646&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Dec 14 05:55:47 2016
@@ -4561,7 +4561,10 @@ SDValue DAGCombiner::MatchLoadCombine(SD
       return SDValue();
 
     // Calculate the offset of the current byte from the base address
-    unsigned LoadByteWidth = L->getMemoryVT().getSizeInBits() / 8;
+    unsigned LoadBitWidth = L->getMemoryVT().getSizeInBits();
+    assert(LoadBitWidth % 8 == 0 &&
+           "can only analyze providers for individual bytes not bit");
+    unsigned LoadByteWidth = LoadBitWidth / 8;
     int64_t MemoryByteOffset =
         DAG.getDataLayout().isBigEndian()
             ? BigEndianByteAt(LoadByteWidth, Bytes[i].ByteOffset)
@@ -4576,6 +4579,7 @@ SDValue DAGCombiner::MatchLoadCombine(SD
     Loads.insert(L);
   }
   assert(Base && "must be set");
+  assert(Loads.size() > 0 && "must be at least one load");
 
   // Check if the bytes of the OR we are looking at match with either big or
   // little endian value load




More information about the llvm-commits mailing list