diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-06-13 12:28:32 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-06-13 12:28:32 +0000 |
| commit | b983ac6fe1d90b8d117c5e08054bf5a0b160c3a7 (patch) | |
| tree | 171b91fe28c2a261ee49754f3cf54529ea7d3b5b /llvm/lib | |
| parent | 96f492d7df9e2bc2f2d76afb4d26cd59574d969f (diff) | |
| download | bcm5719-llvm-b983ac6fe1d90b8d117c5e08054bf5a0b160c3a7.tar.gz bcm5719-llvm-b983ac6fe1d90b8d117c5e08054bf5a0b160c3a7.zip | |
[x86] eliminate even more sign-bit tests with vector select
This shortcoming was noted in D47330, and the test diffs show we already
had other examples where we failed to fold to a SHRUNKBLEND:
/// Dynamic (non-constant condition) vector blend where only the sign bits
/// of the condition elements are used. This is used to enforce that the
/// condition mask is not valid for generic VSELECT optimizations.
This patch implements an idea from D48043 and would obsolete that patch
because it catches more cases (notable the AVX1 case that was missed there).
All we're doing is allowing the existing transform to fire more often by
removing the post-legalize constraint. All of the relevant feature checks
and other predicates are left as-is.
Differential Revision: https://reviews.llvm.org/D48078
llvm-svn: 334592
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 0413f0f00b0..9f03df35570 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -32373,14 +32373,14 @@ static SDValue combineVSelectToShrunkBlend(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const X86Subtarget &Subtarget) { SDValue Cond = N->getOperand(0); - if (N->getOpcode() != ISD::VSELECT || !DCI.isBeforeLegalizeOps() || - DCI.isBeforeLegalize() || + if (N->getOpcode() != ISD::VSELECT || ISD::isBuildVectorOfConstantSDNodes(Cond.getNode())) return SDValue(); - // Don't optimize vector selects that map to mask-registers. + // Don't optimize before the condition has been transformed to a legal type + // and don't ever optimize vector selects that map to AVX512 mask-registers. unsigned BitWidth = Cond.getScalarValueSizeInBits(); - if (BitWidth == 1) + if (BitWidth < 8 || BitWidth > 64) return SDValue(); // We can only handle the cases where VSELECT is directly legal on the @@ -32418,7 +32418,6 @@ static SDValue combineVSelectToShrunkBlend(SDNode *N, SelectionDAG &DAG, if (UI->getOpcode() != ISD::VSELECT || UI.getOperandNo() != 0) return SDValue(); - assert(BitWidth >= 8 && BitWidth <= 64 && "Invalid mask size"); APInt DemandedMask(APInt::getSignMask(BitWidth)); KnownBits Known; TargetLowering::TargetLoweringOpt TLO(DAG, !DCI.isBeforeLegalize(), |

