Skip to content

Commit 9285bf0

Browse files
committed
[TargetLowering] SimplifyDemandedBits - just call computeKnownBits for BUILD_VECTOR cases.
Don't do this locally, computeKnownBits does this better (and can handle non-constant cases as well). A next step would be to actually simplify non-constant elements - building on what we already do in SimplifyDemandedVectorElts. llvm-svn: 365309
1 parent 1500646 commit 9285bf0

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -639,29 +639,9 @@ bool TargetLowering::SimplifyDemandedBits(
639639
break;
640640
}
641641
case ISD::BUILD_VECTOR:
642-
// Collect the known bits that are shared by every constant vector element.
643-
Known.Zero.setAllBits(); Known.One.setAllBits();
644-
for (SDValue SrcOp : Op->ops()) {
645-
if (!isa<ConstantSDNode>(SrcOp)) {
646-
// We can only handle all constant values - bail out with no known bits.
647-
Known = KnownBits(BitWidth);
648-
return false;
649-
}
650-
Known2.One = cast<ConstantSDNode>(SrcOp)->getAPIntValue();
651-
Known2.Zero = ~Known2.One;
652-
653-
// BUILD_VECTOR can implicitly truncate sources, we must handle this.
654-
if (Known2.One.getBitWidth() != BitWidth) {
655-
assert(Known2.getBitWidth() > BitWidth &&
656-
"Expected BUILD_VECTOR implicit truncation");
657-
Known2 = Known2.trunc(BitWidth);
658-
}
659-
660-
// Known bits are the values that are shared by every element.
661-
// TODO: support per-element known bits.
662-
Known.One &= Known2.One;
663-
Known.Zero &= Known2.Zero;
664-
}
642+
// Collect the known bits that are shared by every demanded element.
643+
// TODO: Call SimplifyDemandedBits for non-constant demanded elements.
644+
Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
665645
return false; // Don't fall through, will infinitely loop.
666646
case ISD::LOAD: {
667647
LoadSDNode *LD = cast<LoadSDNode>(Op);

0 commit comments

Comments
 (0)