Skip to content

Commit

Permalink
[TargetLowering] Add UNDEF folding to SimplifyDemandedVectorElts
Browse files Browse the repository at this point in the history
If all the demanded elements of the SimplifyDemandedVectorElts are known to be UNDEF, we can simplify to an ISD::UNDEF node.

Zero constant folding will be handled in a future patch - its a little trickier as we often have bitcasted zero values.

Differential Revision: https://reviews.llvm.org/D55511

llvm-svn: 348784
  • Loading branch information
RKSimon committed Dec 10, 2018
1 parent 17e53b9 commit fc2c9af
Showing 4 changed files with 593 additions and 579 deletions.
7 changes: 6 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
@@ -1783,8 +1783,13 @@ bool TargetLowering::SimplifyDemandedVectorElts(
break;
}
}

assert((KnownUndef & KnownZero) == 0 && "Elements flagged as undef AND zero");

// Constant fold all undef cases.
// TODO: Handle zero cases as well.
if (DemandedElts.isSubsetOf(KnownUndef))
return TLO.CombineTo(Op, TLO.DAG.getUNDEF(VT));

return false;
}

7 changes: 3 additions & 4 deletions llvm/test/CodeGen/X86/var-permute-256.ll
Original file line number Diff line number Diff line change
@@ -876,11 +876,10 @@ define <32 x i8> @var_shuffle_v32i8_from_v16i8(<16 x i8> %v, <32 x i8> %indices)
; AVX512VLBW-LABEL: var_shuffle_v32i8_from_v16i8:
; AVX512VLBW: # %bb.0:
; AVX512VLBW-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
; AVX512VLBW-NEXT: vinserti128 $1, %xmm0, %ymm0, %ymm2
; AVX512VLBW-NEXT: vpshufb %ymm1, %ymm2, %ymm2
; AVX512VLBW-NEXT: vinserti128 $1, %xmm0, %ymm0, %ymm0
; AVX512VLBW-NEXT: vpshufb %ymm1, %ymm0, %ymm0
; AVX512VLBW-NEXT: vpcmpgtb {{.*}}(%rip), %ymm1, %k1
; AVX512VLBW-NEXT: vpshufb %ymm1, %ymm0, %ymm2 {%k1}
; AVX512VLBW-NEXT: vmovdqa %ymm2, %ymm0
; AVX512VLBW-NEXT: vpshufb %ymm1, %ymm0, %ymm0 {%k1}
; AVX512VLBW-NEXT: retq
;
; VLVBMI-LABEL: var_shuffle_v32i8_from_v16i8:
579 changes: 292 additions & 287 deletions llvm/test/CodeGen/X86/vector-reduce-mul-widen.ll

Large diffs are not rendered by default.

579 changes: 292 additions & 287 deletions llvm/test/CodeGen/X86/vector-reduce-mul.ll

Large diffs are not rendered by default.

0 comments on commit fc2c9af

Please sign in to comment.