From e017ed32450573c16e981b91e16a883299fee59a Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sat, 1 Dec 2018 12:08:55 +0000 Subject: [SelectionDAG] Improve SimplifyDemandedBits to SimplifyDemandedVectorElts simplification D52935 introduced the ability for SimplifyDemandedBits to call SimplifyDemandedVectorElts through BITCASTs if the demanded bit mask entirely covered the sub element. This patch relaxes this to demanding an element if we need any bit from it. Differential Revision: https://reviews.llvm.org/D54761 llvm-svn: 348073 --- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 0a7ba894866..3ad71d5677e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1248,8 +1248,8 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op, TLO.DAG.getNode(ISD::SHL, dl, VT, Sign, ShAmt)); } } - // If bitcast from a vector and the mask covers entire elements, see if we - // can use SimplifyDemandedVectorElts. + // If bitcast from a vector, see if we can use SimplifyDemandedVectorElts by + // demanding the element if any bits from it are demanded. // TODO - bigendian once we have test coverage. // TODO - bool vectors once SimplifyDemandedVectorElts has SETCC support. if (SrcVT.isVector() && NumSrcEltBits > 1 && @@ -1261,10 +1261,8 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op, for (unsigned i = 0; i != Scale; ++i) { unsigned Offset = i * NumSrcEltBits; APInt Sub = DemandedBits.extractBits(NumSrcEltBits, Offset); - if (Sub.isAllOnesValue()) + if (!Sub.isNullValue()) DemandedSubElts.setBit(i); - else if (!Sub.isNullValue()) - return false; } return true; }; -- cgit v1.2.3