[PATCH] merge consecutive stores of extracted vector elements (PR21711)

Sanjay Patel spatel at rotateright.com
Wed Jan 7 08:39:11 PST 2015


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:9791
@@ +9790,3 @@
+      // (in other words some of the stored values are constants or loads).
+      if (StoredVal.getOpcode() != ISD::EXTRACT_VECTOR_ELT)
+        return false;
----------------
hfinkel wrote:
> spatel wrote:
> > hfinkel wrote:
> > > How does this cause a crash if you remove this check?
> > > 
> > For code like the second test case, we merge the stores and later during legalization get an error like this for the vector load:
> > Operand not processed?
> > 0x5c4c770: v2i64,ch = load 0x5c4ac60, 0x5c4c660, 0x5c45850<LD16[%sunkaddr115](tbaa=<0x5b6c2a8>)> [ORD=61] [ID=1]
> > 
> > I haven't figured out exactly what happens to cause that.
> Is that load supposed to be dead? What did you do with users of the load's chain result (which I assume might include at least one of the stores you're merging).
> 
I didn't do anything with the load chain because I wasn't expecting any load-based sources in this code path. :)

Based on the later code (starting around line 9857) that handles sequences of loads, we need to replace the existing loads:

  // Replace one of the loads with the new load.
  LoadSDNode *Ld = cast<LoadSDNode>(LoadNodes[0].MemNode);
  DAG.ReplaceAllUsesOfValueWith(SDValue(Ld, 1),
                                SDValue(NewLoad.getNode(), 1));

  // Remove the rest of the load chains.

There are also a lot of other clauses down there that need to be met when replacing loads, so I was trying to handle only vector element extracts with this patch (this is similar to handling constant sources for the stores as in the clause above this one). 

If it's ok with you, I can make this clearer in the comment here and then take a shot at the mixed source case later. I'm guessing the mixed store source case (some vector element extracts and some loads) isn't too common.

http://reviews.llvm.org/D6850

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






More information about the llvm-commits mailing list