diff options
author | Nate Begeman <natebegeman@mac.com> | 2006-02-16 21:11:51 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2006-02-16 21:11:51 +0000 |
commit | 368e18d56a87308045d341e85584597bfe7426e9 (patch) | |
tree | b986949c4c567bd3389329148b6b169876bfc01c /lib/Target | |
parent | a6bbfe844811fe5b2b678d93fcb637831272699f (diff) |
Rework the SelectionDAG-based implementations of SimplifyDemandedBits
and ComputeMaskedBits to match the new improved versions in instcombine.
Tested against all of multisource/benchmarks on ppc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26238 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/Sparc/SparcISelDAGToDAG.cpp | 39 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 14 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.h | 15 |
3 files changed, 44 insertions, 24 deletions
diff --git a/lib/Target/Sparc/SparcISelDAGToDAG.cpp b/lib/Target/Sparc/SparcISelDAGToDAG.cpp index 8671b608b9..d80c0064f3 100644 --- a/lib/Target/Sparc/SparcISelDAGToDAG.cpp +++ b/lib/Target/Sparc/SparcISelDAGToDAG.cpp @@ -98,11 +98,14 @@ namespace { SparcTargetLowering(TargetMachine &TM); virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG); - /// isMaskedValueZeroForTargetNode - Return true if 'Op & Mask' is known to - /// be zero. Op is expected to be a target specific node. Used by DAG - /// combiner. - virtual bool isMaskedValueZeroForTargetNode(const SDOperand &Op, - uint64_t Mask) const; + /// computeMaskedBitsForTargetNode - Determine which of the bits specified + /// in Mask are known to be either zero or one and return them in the + /// KnownZero/KnownOne bitsets. + virtual void computeMaskedBitsForTargetNode(const SDOperand Op, + uint64_t Mask, + uint64_t &KnownZero, + uint64_t &KnownOne, + unsigned Depth = 0) const; virtual std::vector<SDOperand> LowerArguments(Function &F, SelectionDAG &DAG); @@ -246,20 +249,30 @@ const char *SparcTargetLowering::getTargetNodeName(unsigned Opcode) const { /// isMaskedValueZeroForTargetNode - Return true if 'Op & Mask' is known to /// be zero. Op is expected to be a target specific node. Used by DAG /// combiner. -bool SparcTargetLowering:: -isMaskedValueZeroForTargetNode(const SDOperand &Op, uint64_t Mask) const { +void SparcTargetLowering::computeMaskedBitsForTargetNode(const SDOperand Op, + uint64_t Mask, + uint64_t &KnownZero, + uint64_t &KnownOne, + unsigned Depth) const { + uint64_t KnownZero2, KnownOne2; + KnownZero = KnownOne = 0; // Don't know anything. + switch (Op.getOpcode()) { - default: return false; + default: break; case SPISD::SELECT_ICC: case SPISD::SELECT_FCC: - assert(MVT::isInteger(Op.getValueType()) && "Not an integer select!"); - // These operations are masked zero if both the left and the right are zero. - return MaskedValueIsZero(Op.getOperand(0), Mask) && - MaskedValueIsZero(Op.getOperand(1), Mask); + ComputeMaskedBits(Op.getOperand(1), Mask, KnownZero, KnownOne, Depth+1); + ComputeMaskedBits(Op.getOperand(0), Mask, KnownZero2, KnownOne2, Depth+1); + assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); + + // Only known if known in both the LHS and RHS. + KnownOne &= KnownOne2; + KnownZero &= KnownZero2; + break; } } - /// LowerArguments - V8 uses a very simple ABI, where all values are passed in /// either one or two GPRs, including FP values. TODO: we should pass FP values /// in FP registers for fastcc functions. diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index adaa986ffc..3e0a21063f 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -2035,19 +2035,23 @@ const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const { } } -bool X86TargetLowering::isMaskedValueZeroForTargetNode(const SDOperand &Op, - uint64_t Mask) const { +void X86TargetLowering::computeMaskedBitsForTargetNode(const SDOperand Op, + uint64_t Mask, + uint64_t &KnownZero, + uint64_t &KnownOne, + unsigned Depth) const { unsigned Opc = Op.getOpcode(); + KnownZero = KnownOne = 0; // Don't know anything. switch (Opc) { default: assert(Opc >= ISD::BUILTIN_OP_END && "Expected a target specific node"); break; - case X86ISD::SETCC: return (Mask & 1) == 0; + case X86ISD::SETCC: + KnownZero |= (MVT::getIntVTBitMask(Op.getValueType()) ^ 1ULL); + break; } - - return false; } std::vector<unsigned> X86TargetLowering:: diff --git a/lib/Target/X86/X86ISelLowering.h b/lib/Target/X86/X86ISelLowering.h index 88d8e6ca3f..dc1a13c79f 100644 --- a/lib/Target/X86/X86ISelLowering.h +++ b/lib/Target/X86/X86ISelLowering.h @@ -218,12 +218,15 @@ namespace llvm { /// DAG node. virtual const char *getTargetNodeName(unsigned Opcode) const; - /// isMaskedValueZeroForTargetNode - Return true if 'Op & Mask' is known to - /// be zero. Op is expected to be a target specific node. Used by DAG - /// combiner. - virtual bool isMaskedValueZeroForTargetNode(const SDOperand &Op, - uint64_t Mask) const; - + /// computeMaskedBitsForTargetNode - Determine which of the bits specified + /// in Mask are known to be either zero or one and return them in the + /// KnownZero/KnownOne bitsets. + virtual void computeMaskedBitsForTargetNode(const SDOperand Op, + uint64_t Mask, + uint64_t &KnownZero, + uint64_t &KnownOne, + unsigned Depth = 0) const; + SDOperand getReturnAddressFrameIndex(SelectionDAG &DAG); std::vector<unsigned> |