[PATCH] D31711: [GlobalISel] LegalizerInfo: Check if the vector element type is power of 2

Volkan Keles via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 08:00:26 PDT 2017


volkan created this revision.
Herald added subscribers: igorb, rovka, dberris.

Right now, it is not possible to legalize types like <3 x s32>. We should
check the element type if it is a vector.


https://reviews.llvm.org/D31711

Files:
  lib/CodeGen/GlobalISel/LegalizerInfo.cpp


Index: lib/CodeGen/GlobalISel/LegalizerInfo.cpp
===================================================================
--- lib/CodeGen/GlobalISel/LegalizerInfo.cpp
+++ lib/CodeGen/GlobalISel/LegalizerInfo.cpp
@@ -75,8 +75,11 @@
 
   // Nothing is going to go well with types that aren't a power of 2 yet, so
   // don't even try because we might make things worse.
-  if (!isPowerOf2_64(Aspect.Type.getSizeInBits()))
-      return std::make_pair(Unsupported, LLT());
+  LLT Ty = Aspect.Type;
+  unsigned SizeInBits =
+      Ty.isVector() ? Ty.getElementType().getSizeInBits() : Ty.getSizeInBits();
+  if (!isPowerOf2_64(SizeInBits))
+    return std::make_pair(Unsupported, LLT());
 
   // FIXME: the long-term plan calls for expansion in terms of load/store (if
   // they're not legal).
@@ -91,7 +94,6 @@
     return findLegalAction(Aspect, Action);
 
   unsigned Opcode = Aspect.Opcode;
-  LLT Ty = Aspect.Type;
   if (!Ty.isVector()) {
     auto DefaultAction = DefaultActions.find(Aspect.Opcode);
     if (DefaultAction != DefaultActions.end() && DefaultAction->second == Legal)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31711.94230.patch
Type: text/x-patch
Size: 1080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170405/5cadee3b/attachment.bin>


More information about the llvm-commits mailing list