[PATCH] D72464: GlobalISel: Don't assert on MoreElements creating vectors
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 10:14:20 PST 2020
arsenm created this revision.
arsenm added reviewers: paquette, aemerson, aditya_nandakumar, dsanders.
Herald added subscribers: Petar.Avramovic, volkan, hiraditya, rovka, wdng.
Herald added a project: LLVM.
If the original type was a scalar, it should be valid to add elements
to turn it into a vector.
Tests included with following legalization change.
https://reviews.llvm.org/D72464
Files:
llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
Index: llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
+++ llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
@@ -128,24 +128,26 @@
switch (Rule.getAction()) {
case FewerElements:
- case MoreElements: {
if (!OldTy.isVector())
return false;
-
+ LLVM_FALLTHROUGH;
+ case MoreElements: {
+ // MoreElements can go from scalar to vector.
+ const unsigned OldElts = OldTy.isVector() ? OldTy.getNumElements() : 1;
if (NewTy.isVector()) {
if (Rule.getAction() == FewerElements) {
// Make sure the element count really decreased.
- if (NewTy.getNumElements() >= OldTy.getNumElements())
+ if (NewTy.getNumElements() >= OldElts)
return false;
} else {
// Make sure the element count really increased.
- if (NewTy.getNumElements() <= OldTy.getNumElements())
+ if (NewTy.getNumElements() <= OldElts)
return false;
}
}
// Make sure the element type didn't change.
- return NewTy.getScalarType() == OldTy.getElementType();
+ return NewTy.getScalarType() == OldTy.getScalarType();
}
case NarrowScalar:
case WidenScalar: {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72464.237120.patch
Type: text/x-patch
Size: 1269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200109/ea1cd0b5/attachment.bin>
More information about the llvm-commits
mailing list