From ca48af3c8786ad64a1533eaabae94a05028fbbf6 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 29 Apr 2017 16:43:11 +0000 Subject: [KnownBits] Add methods for determining if the known bits represent a negative/nonnegative number and add methods for changing the negative/nonnegative state Summary: This patch adds isNegative, isNonNegative for querying whether the sign bit is known. It also adds makeNegative and makeNonNegative for controlling the sign bit. Reviewers: RKSimon, spatel, davide Reviewed By: RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32651 llvm-svn: 301747 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG') diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index dabfb8bd06d..71d8109fb5a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2711,7 +2711,7 @@ void SelectionDAG::computeKnownBits(SDValue Op, KnownBits &Known, computeKnownBits(Op.getOperand(0), Known2, DemandedElts, Depth + 1); // If the source's MSB is zero then we know the rest of the bits already. - if (Known2.Zero[BitWidth - 1]) { + if (Known2.isNonNegative()) { Known.Zero = Known2.Zero; Known.One = Known2.One; break; @@ -3045,7 +3045,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts, // If we are subtracting one from a positive number, there is no carry // out of the result. - if (Known.Zero.isNegative()) + if (Known.isNonNegative()) return Tmp; } @@ -3069,7 +3069,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts, // If the input is known to be positive (the sign bit is known clear), // the output of the NEG has the same number of sign bits as the input. - if (Known.Zero.isNegative()) + if (Known.isNonNegative()) return Tmp2; // Otherwise, we treat this like a SUB. @@ -3208,9 +3208,9 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts, computeKnownBits(Op, Known, DemandedElts, Depth); APInt Mask; - if (Known.Zero.isNegative()) { // sign bit is 0 + if (Known.isNonNegative()) { // sign bit is 0 Mask = Known.Zero; - } else if (Known.One.isNegative()) { // sign bit is 1; + } else if (Known.isNegative()) { // sign bit is 1; Mask = Known.One; } else { // Nothing known. -- cgit v1.2.3