Skip to content

Commit

Permalink
[InstCombine] Allow simplify demanded transformations on scalable vec…
Browse files Browse the repository at this point in the history
…tors

Differential Revision: https://reviews.llvm.org/D136475
  • Loading branch information
preames committed Oct 31, 2022
1 parent 6288f70 commit a819f6c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Expand Up @@ -130,9 +130,6 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
if (Depth == MaxAnalysisRecursionDepth)
return nullptr;

if (isa<ScalableVectorType>(VTy))
return nullptr;

Instruction *I = dyn_cast<Instruction>(V);
if (!I) {
computeKnownBits(V, Known, Depth, CxtI);
Expand Down Expand Up @@ -424,7 +421,9 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,

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;
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/Transforms/InstCombine/mul-masked-bits.ll
Expand Up @@ -82,8 +82,7 @@ define <vscale x 2 x i32> @combine_mul_self_demandedbits_vector2(<vscale x 2 x i
; 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
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/Transforms/InstCombine/udiv-simplify.ll
Expand Up @@ -106,8 +106,7 @@ define i32 @udiv_exact_demanded(i32 %a) {

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)
Expand Down

0 comments on commit a819f6c

Please sign in to comment.