[PATCH] D93083: [InstCombine] Remove scalable vector restriction in foldSelectOpOp
JunMa via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 10 19:37:36 PST 2020
junparser created this revision.
junparser added reviewers: efriedma, ctetreau, RKSimon, sdesmalen.
junparser added a project: LLVM.
Herald added a subscriber: hiraditya.
junparser requested review of this revision.
Herald added a subscriber: llvm-commits.
As title, this simple patch just fix the fixed vector type restriction.
TestPlan: check-llvm
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93083
Files:
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select.ll
Index: llvm/test/Transforms/InstCombine/select.ll
===================================================================
--- llvm/test/Transforms/InstCombine/select.ll
+++ llvm/test/Transforms/InstCombine/select.ll
@@ -68,6 +68,15 @@
ret <2 x i1> %R
}
+define <vscale x 2 x i1> @test8vvec(<vscale x 2 x i1> %C, <vscale x 2 x i1> %X) {
+; CHECK-LABEL: @test8vvec(
+; CHECK-NEXT: [[R:%.*]] = and <vscale x 2 x i1> [[C:%.*]], [[X:%.*]]
+; CHECK-NEXT: ret <vscale x 2 x i1> [[R]]
+;
+ %R = select <vscale x 2 x i1> %C, <vscale x 2 x i1> %X, <vscale x 2 x i1> zeroinitializer
+ ret <vscale x 2 x i1> %R
+}
+
define i1 @test9(i1 %C, i1 %X) {
; CHECK-LABEL: @test9(
; CHECK-NEXT: [[NOT_C:%.*]] = xor i1 [[C:%.*]], true
@@ -88,6 +97,16 @@
ret <2 x i1> %R
}
+define <vscale x 2 x i1> @test9vvec(<vscale x 2 x i1> %C, <vscale x 2 x i1> %X) {
+; CHECK-LABEL: @test9vvec(
+; CHECK-NEXT: [[NOT_C:%.*]] = xor <vscale x 2 x i1> [[C:%.*]], shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0), <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer)
+; CHECK-NEXT: [[R:%.*]] = and <vscale x 2 x i1> [[NOT_C]], [[X:%.*]]
+; CHECK-NEXT: ret <vscale x 2 x i1> [[R]]
+;
+ %R = select <vscale x 2 x i1> %C, <vscale x 2 x i1> zeroinitializer, <vscale x 2 x i1> %X
+ ret <vscale x 2 x i1> %R
+}
+
define i1 @test10(i1 %C, i1 %X) {
; CHECK-LABEL: @test10(
; CHECK-NEXT: [[NOT_C:%.*]] = xor i1 [[C:%.*]], true
Index: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -283,10 +283,9 @@
// The select condition may be a vector. We may only change the operand
// type if the vector width remains the same (and matches the condition).
if (auto *CondVTy = dyn_cast<VectorType>(CondTy)) {
- if (!FIOpndTy->isVectorTy())
- return nullptr;
- if (cast<FixedVectorType>(CondVTy)->getNumElements() !=
- cast<FixedVectorType>(FIOpndTy)->getNumElements())
+ if (!FIOpndTy->isVectorTy() ||
+ CondVTy->getElementCount() !=
+ cast<VectorType>(FIOpndTy)->getElementCount())
return nullptr;
// TODO: If the backend knew how to deal with casts better, we could
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93083.311096.patch
Type: text/x-patch
Size: 2376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201211/251fd025/attachment.bin>
More information about the llvm-commits
mailing list