[PATCH] [SelectionDAG] Combine extload/store/load sequence into extload.

Quentin Colombet qcolombet at apple.com
Thu Jan 22 11:32:25 PST 2015


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:8317
@@ +8316,3 @@
+  // v4i32 load %ptr1, zext from v4i8
+  if (!ISD::isNON_EXTLoad(N) && !LD->isVolatile() &&
+      ISD::isNON_TRUNCStore(Chain.getNode())) {
----------------
ab wrote:
> qcolombet wrote:
> > !ISD::isNON_EXTLoad(N) => ISD::isEXTLoad(N)
> > That may be less contrived.
> The name is misleading: isEXTLoad checks for "anyext-loads", not "any kind of extload"!
Right :).

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:8323
@@ +8322,3 @@
+    EVT MemVT = LD->getMemoryVT();
+    if (PrevST->getBasePtr() == Ptr &&
+        (ValVT.getStoreSize() == MemVT.getStoreSize() &&
----------------
ab wrote:
> Should we also check that the types are equivalent?  For instance, if you have 
> 
>    %v = load float %p1
>    store float %v, %p2
>    %v2 = i64 load %p2, zext from i32
> 
> would it be a problem? (I don't think so, but I'm having second thoughts.)
As long as we read the same number of bits, this is fine.
You already check for that :).

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:8329
@@ +8328,3 @@
+      if (LD->getAddressSpace() == PPrevLD->getAddressSpace() &&
+          LD->getAlignment() == PPrevLD->getAlignment()) {
+        SDValue NewLoad = DAG.getExtLoad(
----------------
ab wrote:
> I think we can remove this check: we don't really care that the alignment is the same, do we?  As long as the new load has the same alignment as the first (non-extending) one.
Indeed, we do not need to check that the alignment is the same.

> As long as the new load has the same alignment as the first (non-extending) one.

I do not think we need to check for that. Nevertheless, we should check that the alignment for the new load (derived from the load of %p1) is enough to be legal.

Does it make sense?

http://reviews.llvm.org/D6552

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list