[llvm] r365309 - [TargetLowering] SimplifyDemandedBits - just call computeKnownBits for BUILD_VECTOR cases.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 8 04:00:40 PDT 2019
Author: rksimon
Date: Mon Jul 8 04:00:39 2019
New Revision: 365309
URL: http://llvm.org/viewvc/llvm-project?rev=365309&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=365309&r1=365308&r2=365309&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Mon Jul 8 04:00:39 2019
@@ -639,29 +639,9 @@ bool TargetLowering::SimplifyDemandedBit
break;
}
case ISD::BUILD_VECTOR:
- // Collect the known bits that are shared by every constant vector element.
- Known.Zero.setAllBits(); Known.One.setAllBits();
- for (SDValue SrcOp : Op->ops()) {
- if (!isa<ConstantSDNode>(SrcOp)) {
- // We can only handle all constant values - bail out with no known bits.
- Known = KnownBits(BitWidth);
- return false;
- }
- Known2.One = cast<ConstantSDNode>(SrcOp)->getAPIntValue();
- Known2.Zero = ~Known2.One;
-
- // BUILD_VECTOR can implicitly truncate sources, we must handle this.
- if (Known2.One.getBitWidth() != BitWidth) {
- assert(Known2.getBitWidth() > BitWidth &&
- "Expected BUILD_VECTOR implicit truncation");
- Known2 = Known2.trunc(BitWidth);
- }
-
- // Known bits are the values that are shared by every element.
- // TODO: support per-element known bits.
- Known.One &= Known2.One;
- Known.Zero &= Known2.Zero;
- }
+ // Collect the known bits that are shared by every demanded element.
+ // TODO: Call SimplifyDemandedBits for non-constant demanded elements.
+ Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
return false; // Don't fall through, will infinitely loop.
case ISD::LOAD: {
LoadSDNode *LD = cast<LoadSDNode>(Op);
More information about the llvm-commits
mailing list