[PATCH] D136475: [InstCombine] Allow simplify demanded transformations on scalable vectors
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 21 11:17:48 PDT 2022
reames created this revision.
reames added reviewers: craig.topper, asb, frasercrmck, RKSimon, paulwalker-arm, david-arm, spatel.
Herald added subscribers: StephenFan, bollu, hiraditya, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added a subscriber: alextsao1999.
Herald added a project: LLVM.
This depends on D136470 <https://reviews.llvm.org/D136470> so that we can get element wise results from compute known bits. This change is fairly trivial on its own.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136475
Files:
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/test/Transforms/InstCombine/mul-masked-bits.ll
llvm/test/Transforms/InstCombine/udiv-simplify.ll
Index: llvm/test/Transforms/InstCombine/udiv-simplify.ll
===================================================================
--- llvm/test/Transforms/InstCombine/udiv-simplify.ll
+++ llvm/test/Transforms/InstCombine/udiv-simplify.ll
@@ -106,8 +106,7 @@
define <vscale x 1 x i32> @udiv_demanded3(<vscale x 1 x i32> %a) {
; CHECK-LABEL: @udiv_demanded3(
-; CHECK-NEXT: [[O:%.*]] = or <vscale x 1 x i32> [[A:%.*]], shufflevector (<vscale x 1 x i32> insertelement (<vscale x 1 x i32> poison, i32 3, i32 0), <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer)
-; CHECK-NEXT: [[U:%.*]] = udiv <vscale x 1 x i32> [[O]], shufflevector (<vscale x 1 x i32> insertelement (<vscale x 1 x i32> poison, i32 12, i32 0), <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer)
+; CHECK-NEXT: [[U:%.*]] = udiv <vscale x 1 x i32> [[A:%.*]], shufflevector (<vscale x 1 x i32> insertelement (<vscale x 1 x i32> poison, i32 12, i32 0), <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer)
; CHECK-NEXT: ret <vscale x 1 x i32> [[U]]
;
%o = or <vscale x 1 x i32> %a, shufflevector (<vscale x 1 x i32> insertelement (<vscale x 1 x i32> poison, i32 3, i32 0), <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer)
Index: llvm/test/Transforms/InstCombine/mul-masked-bits.ll
===================================================================
--- llvm/test/Transforms/InstCombine/mul-masked-bits.ll
+++ llvm/test/Transforms/InstCombine/mul-masked-bits.ll
@@ -82,8 +82,7 @@
; CHECK-LABEL: @combine_mul_self_demandedbits_vector2(
; CHECK-NEXT: [[TMP1:%.*]] = freeze <vscale x 2 x i32> [[X:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = mul <vscale x 2 x i32> [[TMP1]], [[TMP1]]
-; CHECK-NEXT: [[TMP3:%.*]] = and <vscale x 2 x i32> [[TMP2]], shufflevector (<vscale x 2 x i32> insertelement (<vscale x 2 x i32> poison, i32 -3, i32 0), <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer)
-; CHECK-NEXT: ret <vscale x 2 x i32> [[TMP3]]
+; CHECK-NEXT: ret <vscale x 2 x i32> [[TMP2]]
;
%1 = freeze <vscale x 2 x i32> %x
%2 = mul <vscale x 2 x i32> %1, %1
Index: llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -130,9 +130,6 @@
if (Depth == MaxAnalysisRecursionDepth)
return nullptr;
- if (isa<ScalableVectorType>(VTy))
- return nullptr;
-
Instruction *I = dyn_cast<Instruction>(V);
if (!I) {
computeKnownBits(V, Known, Depth, CxtI);
@@ -424,7 +421,9 @@
if (auto *DstVTy = dyn_cast<VectorType>(VTy)) {
if (auto *SrcVTy = dyn_cast<VectorType>(I->getOperand(0)->getType())) {
- if (cast<FixedVectorType>(DstVTy)->getNumElements() !=
+ if (isa<ScalableVectorType>(DstVTy) ||
+ isa<ScalableVectorType>(SrcVTy) ||
+ cast<FixedVectorType>(DstVTy)->getNumElements() !=
cast<FixedVectorType>(SrcVTy)->getNumElements())
// Don't touch a bitcast between vectors of different element counts.
return nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136475.469698.patch
Type: text/x-patch
Size: 3177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221021/162027c7/attachment.bin>
More information about the llvm-commits
mailing list