forked from OSchip/llvm-project
[DAGCombine] Pull out repeated demanded bitmask generation. NFCI.
llvm-svn: 355932
This commit is contained in:
parent
02e88490c1
commit
9f0a5ca843
|
@ -15420,23 +15420,22 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) {
|
||||||
Value.getValueType().isInteger() &&
|
Value.getValueType().isInteger() &&
|
||||||
(!isa<ConstantSDNode>(Value) ||
|
(!isa<ConstantSDNode>(Value) ||
|
||||||
!cast<ConstantSDNode>(Value)->isOpaque())) {
|
!cast<ConstantSDNode>(Value)->isOpaque())) {
|
||||||
|
APInt TruncDemandedBits =
|
||||||
|
APInt::getLowBitsSet(Value.getScalarValueSizeInBits(),
|
||||||
|
ST->getMemoryVT().getScalarSizeInBits());
|
||||||
|
|
||||||
// See if we can simplify the input to this truncstore with knowledge that
|
// See if we can simplify the input to this truncstore with knowledge that
|
||||||
// only the low bits are being used. For example:
|
// only the low bits are being used. For example:
|
||||||
// "truncstore (or (shl x, 8), y), i8" -> "truncstore y, i8"
|
// "truncstore (or (shl x, 8), y), i8" -> "truncstore y, i8"
|
||||||
SDValue Shorter = DAG.GetDemandedBits(
|
SDValue Shorter = DAG.GetDemandedBits(Value, TruncDemandedBits);
|
||||||
Value, APInt::getLowBitsSet(Value.getScalarValueSizeInBits(),
|
|
||||||
ST->getMemoryVT().getScalarSizeInBits()));
|
|
||||||
AddToWorklist(Value.getNode());
|
AddToWorklist(Value.getNode());
|
||||||
if (Shorter.getNode())
|
if (Shorter)
|
||||||
return DAG.getTruncStore(Chain, SDLoc(N), Shorter,
|
return DAG.getTruncStore(Chain, SDLoc(N), Shorter, Ptr, ST->getMemoryVT(),
|
||||||
Ptr, ST->getMemoryVT(), ST->getMemOperand());
|
ST->getMemOperand());
|
||||||
|
|
||||||
// Otherwise, see if we can simplify the operation with
|
// Otherwise, see if we can simplify the operation with
|
||||||
// SimplifyDemandedBits, which only works if the value has a single use.
|
// SimplifyDemandedBits, which only works if the value has a single use.
|
||||||
if (SimplifyDemandedBits(
|
if (SimplifyDemandedBits(Value, TruncDemandedBits)) {
|
||||||
Value,
|
|
||||||
APInt::getLowBitsSet(Value.getScalarValueSizeInBits(),
|
|
||||||
ST->getMemoryVT().getScalarSizeInBits()))) {
|
|
||||||
// Re-visit the store if anything changed and the store hasn't been merged
|
// Re-visit the store if anything changed and the store hasn't been merged
|
||||||
// with another node (N is deleted) SimplifyDemandedBits will add Value's
|
// with another node (N is deleted) SimplifyDemandedBits will add Value's
|
||||||
// node back to the worklist if necessary, but we also need to re-visit
|
// node back to the worklist if necessary, but we also need to re-visit
|
||||||
|
|
Loading…
Reference in New Issue