[PATCH] D94204: GlobalISel: Handle G_BUILD_VECTOR in isKnownToBeAPowerOfTwo

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 6 16:28:45 PST 2021


arsenm created this revision.
arsenm added reviewers: paquette, aemerson, bogner, dsanders.
Herald added subscribers: hiraditya, rovka.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

https://reviews.llvm.org/D94204

Files:
  llvm/lib/CodeGen/GlobalISel/Utils.cpp


Index: llvm/lib/CodeGen/GlobalISel/Utils.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -588,6 +588,17 @@
 
     break;
   }
+  case TargetOpcode::G_BUILD_VECTOR:
+  case TargetOpcode::G_BUILD_VECTOR_TRUNC: {
+    // TODO: Probably should have a recursion depth guard since you could have
+    // bitcasted vector elements.
+    for (unsigned I = 1, E = MI.getNumOperands(); I != E; ++I) {
+      if (!isKnownToBeAPowerOfTwo(MI.getOperand(I).getReg(), MRI, KB))
+        return false;
+    }
+
+    return true;
+  }
   default:
     break;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94204.315020.patch
Type: text/x-patch
Size: 658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210107/07cc2994/attachment.bin>


More information about the llvm-commits mailing list