diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-06 20:13:21 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-06 20:13:21 +0000 | 
| commit | 7e7b6700743285c0af506ac6299ddf82ebd434b9 (patch) | |
| tree | 578d2ea1868b77f3dff145df7f8f3fe73272c09e /lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | |
| parent | 4b570baa7e867c652fa7d690585098278082fae9 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
| -rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 17 | 
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index cb803585282f..a07bd8f83546 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -40,6 +40,7 @@  #include "llvm/CodeGen/StackMaps.h"  #include "llvm/CodeGen/WinEHFuncInfo.h"  #include "llvm/IR/CallingConv.h" +#include "llvm/IR/ConstantRange.h"  #include "llvm/IR/Constants.h"  #include "llvm/IR/DataLayout.h"  #include "llvm/IR/DebugInfo.h" @@ -7339,19 +7340,23 @@ SDValue SelectionDAGBuilder::lowerRangeToAssertZExt(SelectionDAG &DAG,    if (!Range)      return Op; -  Constant *Lo = cast<ConstantAsMetadata>(Range->getOperand(0))->getValue(); -  if (!Lo->isNullValue()) +  ConstantRange CR = getConstantRangeFromMetadata(*Range); +  if (CR.isFullSet() || CR.isEmptySet() || CR.isWrappedSet())      return Op; -  Constant *Hi = cast<ConstantAsMetadata>(Range->getOperand(1))->getValue(); -  unsigned Bits = cast<ConstantInt>(Hi)->getValue().logBase2(); +  APInt Lo = CR.getUnsignedMin(); +  if (!Lo.isMinValue()) +    return Op; + +  APInt Hi = CR.getUnsignedMax(); +  unsigned Bits = Hi.getActiveBits();    EVT SmallVT = EVT::getIntegerVT(*DAG.getContext(), Bits);    SDLoc SL = getCurSDLoc(); -  SDValue ZExt = DAG.getNode(ISD::AssertZext, SL, Op.getValueType(), -                             Op, DAG.getValueType(SmallVT)); +  SDValue ZExt = DAG.getNode(ISD::AssertZext, SL, Op.getValueType(), Op, +                             DAG.getValueType(SmallVT));    unsigned NumVals = Op.getNode()->getNumValues();    if (NumVals == 1)      return ZExt;  | 
