From b4c2d54fee5a287a0afbb2851e6438a474917d84 Mon Sep 17 00:00:00 2001 From: trevor_hansen Date: Sat, 29 May 2010 05:04:50 +0000 Subject: [PATCH] Simplifyin BVSX to CONCAT if the topmost bit of the thing being extended is known. git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@800 e59a4935-1847-0410-ae03-e826735625c1 --- src/simplifier/simplifier.cpp | 15 ++++++++++++++- src/simplifier/simplifier.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/simplifier/simplifier.cpp b/src/simplifier/simplifier.cpp index 21a6031..9f23495 100644 --- a/src/simplifier/simplifier.cpp +++ b/src/simplifier/simplifier.cpp @@ -2158,9 +2158,22 @@ namespace BEEV if (a0.GetValueWidth() == len) { //nothing to signextend - return a0; + output = a0; + break; } + // If the msb is known. Then puts 0's or the 1's infront. + if (mostSignificantConstants(a0) > 0) + { + if (getConstantBit(a0,0) == 0) + output = _bm->CreateTerm(BVCONCAT, len, _bm->CreateZeroConst(len-a0.GetValueWidth()), a0); + else + output = _bm->CreateTerm(BVCONCAT, len, _bm->CreateMaxConst(len-a0.GetValueWidth()), a0); + + break; + } + + switch (a0.GetKind()) { case BVCONST: diff --git a/src/simplifier/simplifier.h b/src/simplifier/simplifier.h index bda86df..9b64944 100644 --- a/src/simplifier/simplifier.h +++ b/src/simplifier/simplifier.h @@ -46,6 +46,7 @@ namespace BEEV //Ptr to STP Manager STPMgr * _bm; + NodeFactory * nf; public: /**************************************************************** @@ -61,6 +62,7 @@ namespace BEEV ASTTrue = bm->CreateNode(TRUE); ASTFalse = bm->CreateNode(FALSE); ASTUndefined = bm->CreateNode(UNDEFINED); + nf = bm->defaultNodeFactory; } ~Simplifier() -- 2.47.3