cloud9_root/src/third_party/stp/src/simplifier/simplifier.cpp
// If the shift is bigger than the bitwidth, replace by an extract.
If the shift is bigger than the bitwidth, replace by an extract.
If the shift is bigger than the bitwidth replace by an extract .
ASTNode
  Simplifier::convertArithmeticKnownShiftAmount(const Kind k, const ASTVec& children, STPMgr& bm, NodeFactory *nf)
  {
    const ASTNode a = children[0];
    const ASTNode b = children[1];
    const int width = children[0].GetValueWidth();
    ASTNode output;
    assert(b.isConstant());
    assert(k == BVSRSHIFT);
    if (CONSTANTBV::Set_Max(b.GetBVConst()) > 1 + log2(width))
      {
        ASTNode top = bm.CreateBVConst(32, width - 1);
        return nf->CreateTerm(BVSX, width, nf->CreateTerm(BVEXTRACT, 1, children[0], top, top),
            bm.CreateBVConst(32, width));
      }
    else
      {
        if (b.GetUnsignedConst() >= width)
          {
            ASTNode top = bm.CreateBVConst(32, width - 1);
            return nf->CreateTerm(BVSX, width, nf->CreateTerm(BVEXTRACT, 1, children[0], top, top),
                bm.CreateBVConst(32, width));
          }
      }
    return ASTNode();
  }
ASTNode Simplifier :: convertArithmeticKnownShiftAmount ( const Kind k , const ASTVec & children , STPMgr & bm , NodeFactory * nf ) { const ASTNode a = children [ 0 ] ; const ASTNode b = children [ 1 ] ; const int width = children [ 0 ] . GetValueWidth ( ) ; ASTNode output ; assert ( b . isConstant ( ) ) ; assert ( k == BVSRSHIFT ) ; if ( CONSTANTBV :: Set_Max ( b . GetBVConst ( ) ) > 1 + log2 ( width ) ) { ASTNode top = bm . CreateBVConst ( 32 , width - 1 ) ; return nf -> CreateTerm ( BVSX , width , nf -> CreateTerm ( BVEXTRACT , 1 , children [ 0 ] , top , top ) , bm . CreateBVConst ( 32 , width ) ) ; } else { if ( b . GetUnsignedConst ( ) >= width ) { ASTNode top = bm . CreateBVConst ( 32 , width - 1 ) ; return nf -> CreateTerm ( BVSX , width , nf -> CreateTerm ( BVEXTRACT , 1 , children [ 0 ] , top , top ) , bm . CreateBVConst ( 32 , width ) ) ; } } return ASTNode ( ) ; }
If the shift is bigger than the bitwidth, replace by an extract.
If the shift is bigger than the bitwidth replace by an extract .