[PATCH] Update InstCombine to transform aggregate loads into scalar loads.

Mehdi AMINI mehdi.amini at apple.com
Sun Apr 5 17:08:43 PDT 2015




================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:523
@@ +522,3 @@
+  if (!T->isAggregateType())
+    return nullptr;
+
----------------
deadalnix wrote:
> joker.eph wrote:
> > Is this check useful? It seems redundant with the next one.
> > What about doing an early exit instead of adding nesting level:
> > 
> > ```
> >   StructType *ST = dyn_cast<StructType>(T);
> >   // Only unpack structure with one element.
> >   if(!ST || ST->getNumElements() != 1) return nullptr;
> > 
> >   Ptr = IC.Builder->CreateStructGEP(Ptr, 0);
> >   LoadInst *NewLoad = combineLoadToNewValue(IC, LI, Ptr, T, ".unpack");
> > 
> >   Instruction *V = InsertValueInst::Create(UndefValue::get(T), NewLoad, 0, LI.getName());
> > 
> >   LI.replaceAllUsesWith(V);
> >   return V;
> > ```
> The code has it current structure because I intend to add support for arrays and multiple element structs. In this case, the early return do not make sense. The isAggregateType however, is indeed an early return in that case. I can update this if you feel strongly about it, but that would have to be undone is a subsequent diff.
OK, makes sense.

http://reviews.llvm.org/D8339

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






More information about the llvm-commits mailing list