[PATCH] D78568: [DAGCombine] Fix bug in load scalarization

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 21 09:10:18 PDT 2020


frasercrmck created this revision.
frasercrmck added reviewers: craig.topper, spatel.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

For vector element types of less than one byte in size, we would
generate incorrect scalar offsets and produce incorrect codegen.

This optimization could be supported in the future, e.g. by loading a
byte, then shifting and masking out the smaller vector element type.
However, without an upstream target to test against it's best to avoid
the bad codegen in the simplest possible way.

Related to this bug:

  https://bugs.llvm.org/show_bug.cgi?id=27600


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78568

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -17235,6 +17235,12 @@
 
   EVT ResultVT = EVE->getValueType(0);
   EVT VecEltVT = InVecVT.getVectorElementType();
+
+  // If the vector element type is narrower than a byte then we are unable to
+  // compute an address to load only the extracted element as a scalar.
+  if (VecEltVT.getSizeInBits() < 8)
+    return SDValue();
+
   unsigned Align = OriginalLoad->getAlignment();
   unsigned NewAlign = DAG.getDataLayout().getABITypeAlignment(
       VecEltVT.getTypeForEVT(*DAG.getContext()));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78568.259016.patch
Type: text/x-patch
Size: 719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200421/aa5504e3/attachment.bin>


More information about the llvm-commits mailing list