diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-12-17 18:43:43 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-12-17 18:43:43 +0000 |
commit | 9274f17a5ec5869e944d77b9f9c81c5f8063f360 (patch) | |
tree | 687a7d88d1942bb53dffd91c2586706414f991dd /llvm/lib/Target | |
parent | 077a0aff164a651ac439a035571dfe6af85f0221 (diff) | |
download | bcm5719-llvm-9274f17a5ec5869e944d77b9f9c81c5f8063f360.tar.gz bcm5719-llvm-9274f17a5ec5869e944d77b9f9c81c5f8063f360.zip |
[TargetLowering] Add DemandedElts mask to SimplifyDemandedBits (PR40000)
This is an initial patch to add the necessary support for a DemandedElts argument to SimplifyDemandedBits, more closely matching computeKnownBits and to help improve vector codegen.
I've added only a small amount of the changes necessary to get at least one test to update - a lot more can be done but I'd like to add these methodically with proper test coverage, at the same time the hope is to slowly move some/all of SimplifyDemandedVectorElts into SimplifyDemandedBits as well.
Differential Revision: https://reviews.llvm.org/D55768
llvm-svn: 349374
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 19 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.h | 1 |
2 files changed, 11 insertions, 9 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 6494a0ae10a..62972f58721 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -32397,8 +32397,9 @@ bool X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode( } bool X86TargetLowering::SimplifyDemandedBitsForTargetNode( - SDValue Op, const APInt &OriginalDemandedBits, KnownBits &Known, - TargetLoweringOpt &TLO, unsigned Depth) const { + SDValue Op, const APInt &OriginalDemandedBits, + const APInt &OriginalDemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, + unsigned Depth) const { unsigned BitWidth = OriginalDemandedBits.getBitWidth(); unsigned Opc = Op.getOpcode(); switch(Opc) { @@ -32424,8 +32425,8 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode( KnownBits KnownOp; unsigned ShAmt = ShiftImm->getZExtValue(); APInt DemandedMask = OriginalDemandedBits.lshr(ShAmt); - if (SimplifyDemandedBits(Op.getOperand(0), DemandedMask, KnownOp, TLO, - Depth + 1)) + if (SimplifyDemandedBits(Op.getOperand(0), DemandedMask, + OriginalDemandedElts, KnownOp, TLO, Depth + 1)) return true; } break; @@ -32446,8 +32447,8 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode( OriginalDemandedBits.countLeadingZeros() < ShAmt) DemandedMask.setSignBit(); - if (SimplifyDemandedBits(Op.getOperand(0), DemandedMask, KnownOp, TLO, - Depth + 1)) + if (SimplifyDemandedBits(Op.getOperand(0), DemandedMask, + OriginalDemandedElts, KnownOp, TLO, Depth + 1)) return true; } break; @@ -32475,8 +32476,8 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode( // MOVMSK only uses the MSB from each vector element. KnownBits KnownSrc; - if (SimplifyDemandedBits(Src, APInt::getSignMask(SrcBits), KnownSrc, TLO, - Depth + 1)) + if (SimplifyDemandedBits(Src, APInt::getSignMask(SrcBits), DemandedElts, + KnownSrc, TLO, Depth + 1)) return true; if (KnownSrc.One[SrcBits - 1]) @@ -32488,7 +32489,7 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode( } return TargetLowering::SimplifyDemandedBitsForTargetNode( - Op, OriginalDemandedBits, Known, TLO, Depth); + Op, OriginalDemandedBits, OriginalDemandedElts, Known, TLO, Depth); } /// Check if a vector extract from a target-specific shuffle of a load can be diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h index 3a7078a3db2..b3ac31f24ea 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.h +++ b/llvm/lib/Target/X86/X86ISelLowering.h @@ -871,6 +871,7 @@ namespace llvm { bool SimplifyDemandedBitsForTargetNode(SDValue Op, const APInt &DemandedBits, + const APInt &DemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth) const override; |