[PATCH] D56969: GlobalISel: Fix widenScalarToNextPow2 mutation for vectors

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 19 18:25:17 PST 2019


arsenm created this revision.
arsenm added reviewers: aemerson, qcolombet, aditya_nandakumar, dsanders, volkan.
Herald added subscribers: kristof.beyls, rovka, wdng.

The current set of mutations and predicates seems inconsistent in
whether the various scalar functions also apply to the vector
elements, and I'm not sure what the best direction to move the cleanup
is. Either the current set of functions should be changed to look at
scalar elements consistently, or there should be a separate set for
vectors.

      

The base WidenScalar LegalizeAction specifies it should apply to
widening vector element types. The rule sets seem to ignore
vectors (such as minScalar/maxScalar using the full vector sizez, and
clampScalar asserting).

     

f this is the correct direction, those all need to be fixed as well.


https://reviews.llvm.org/D56969

Files:
  lib/CodeGen/GlobalISel/LegalizeMutations.cpp


Index: lib/CodeGen/GlobalISel/LegalizeMutations.cpp
===================================================================
--- lib/CodeGen/GlobalISel/LegalizeMutations.cpp
+++ lib/CodeGen/GlobalISel/LegalizeMutations.cpp
@@ -30,10 +30,16 @@
 LegalizeMutation LegalizeMutations::widenScalarToNextPow2(unsigned TypeIdx,
                                                           unsigned Min) {
   return [=](const LegalityQuery &Query) {
-    unsigned NewSizeInBits =
-        1 << Log2_32_Ceil(Query.Types[TypeIdx].getSizeInBits());
+    LLT Ty = Query.Types[TypeIdx];
+    unsigned NewSizeInBits = 1 << Log2_32_Ceil(Ty.getScalarSizeInBits());
     if (NewSizeInBits < Min)
       NewSizeInBits = Min;
+
+    if (Ty.isVector()) {
+      return std::make_pair(TypeIdx,
+                            LLT::vector(Ty.getNumElements(), NewSizeInBits));
+    }
+
     return std::make_pair(TypeIdx, LLT::scalar(NewSizeInBits));
   };
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56969.182689.patch
Type: text/x-patch
Size: 927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190120/488ba567/attachment.bin>


More information about the llvm-commits mailing list