[LLVMdev] Patch: Don't do unprofitable narrowing of loads.

JP Bonn jp at jpbonn.com
Thu Oct 7 12:39:08 PDT 2010


Our backend only does 32 bit loads.  I noticed some loads were narrowed 
to 8 bits and then had to be reverted back to 32 bit loads.  This patch 
prevents the initial lowering.  I've only tested this on my backend. Can 
someone review and apply this or should I submit a bug?

Index: CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- CodeGen/SelectionDAG/TargetLowering.cpp	(revision 115815)
+++ CodeGen/SelectionDAG/TargetLowering.cpp	(working copy)
@@ -1899,7 +1899,9 @@
                else
                  bestOffset = (uint64_t)offset * (width/8);
                bestMask = Mask.lshr(offset * (width/8) * 8);
-              bestWidth = width;
+              EVT NewVT = EVT::getIntegerVT(*DAG.getContext(), width);
+              if  (isNarrowingProfitable(Lod->getMemoryVT(), NewVT))
+                bestWidth = width;
                break;
              }
              newMask = newMask << width;



More information about the llvm-dev mailing list