Skip to content

Commit a134cec

Browse files
committed
Add DAG parameter to ComputeNumSignBitsForTargetNode
This way, you can check the number of sign bits in the operands. The depth parameter it already has is pretty useless without this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205649 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9121540 commit a134cec

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

include/llvm/Target/TargetLowering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,6 +1905,7 @@ class TargetLowering : public TargetLoweringBase {
19051905
/// This method can be implemented by targets that want to expose additional
19061906
/// information about sign bits to the DAG Combiner.
19071907
virtual unsigned ComputeNumSignBitsForTargetNode(SDValue Op,
1908+
const SelectionDAG &DAG,
19081909
unsigned Depth = 0) const;
19091910

19101911
struct DAGCombinerInfo {

lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2422,7 +2422,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, unsigned Depth) const{
24222422
Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN ||
24232423
Op.getOpcode() == ISD::INTRINSIC_W_CHAIN ||
24242424
Op.getOpcode() == ISD::INTRINSIC_VOID) {
2425-
unsigned NumBits = TLI->ComputeNumSignBitsForTargetNode(Op, Depth);
2425+
unsigned NumBits = TLI->ComputeNumSignBitsForTargetNode(Op, *this, Depth);
24262426
if (NumBits > 1) FirstAnswer = std::max(FirstAnswer, NumBits);
24272427
}
24282428

lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ void TargetLowering::computeMaskedBitsForTargetNode(const SDValue Op,
10741074
/// targets that want to expose additional information about sign bits to the
10751075
/// DAG Combiner.
10761076
unsigned TargetLowering::ComputeNumSignBitsForTargetNode(SDValue Op,
1077+
const SelectionDAG &,
10771078
unsigned Depth) const {
10781079
assert((Op.getOpcode() >= ISD::BUILTIN_OP_END ||
10791080
Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN ||

lib/Target/X86/X86ISelLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16576,8 +16576,10 @@ void X86TargetLowering::computeMaskedBitsForTargetNode(const SDValue Op,
1657616576
}
1657716577
}
1657816578

16579-
unsigned X86TargetLowering::ComputeNumSignBitsForTargetNode(SDValue Op,
16580-
unsigned Depth) const {
16579+
unsigned X86TargetLowering::ComputeNumSignBitsForTargetNode(
16580+
SDValue Op,
16581+
const SelectionDAG &,
16582+
unsigned Depth) const {
1658116583
// SETCC_CARRY sets the dest to ~0 for true or 0 for false.
1658216584
if (Op.getOpcode() == X86ISD::SETCC_CARRY)
1658316585
return Op.getValueType().getScalarType().getSizeInBits();

lib/Target/X86/X86ISelLowering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ namespace llvm {
626626
// ComputeNumSignBitsForTargetNode - Determine the number of bits in the
627627
// operation that are sign bits.
628628
unsigned ComputeNumSignBitsForTargetNode(SDValue Op,
629+
const SelectionDAG &DAG,
629630
unsigned Depth) const override;
630631

631632
bool isGAPlusOffset(SDNode *N, const GlobalValue* &GA,

0 commit comments

Comments
 (0)