-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The simplifier now rewrites two additional cases for power_exprt.
- Loading branch information
Showing
6 changed files
with
67 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ Author: Daniel Kroening, [email protected] | |
\*******************************************************************/ | ||
|
||
#include "mathematical_expr.h" | ||
|
||
#include "arith_tools.h" | ||
#include "mathematical_types.h" | ||
|
||
function_application_exprt::function_application_exprt( | ||
|
@@ -49,3 +51,9 @@ lambda_exprt::lambda_exprt(const variablest &_variables, const exprt &_where) | |
lambda_type(_variables, _where)) | ||
{ | ||
} | ||
|
||
power_exprt::power_exprt(const mp_integer &_base, const exprt &_exp) | ||
: power_exprt{from_integer(_base, _exp.type()), _exp} | ||
{ | ||
PRECONDITION(base().is_not_nil()); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected] | |
#include "fixedbv.h" | ||
#include "ieee_float.h" | ||
#include "invariant.h" | ||
#include "mathematical_expr.h" | ||
#include "mathematical_types.h" | ||
#include "namespace.h" | ||
#include "pointer_expr.h" | ||
|
@@ -1120,18 +1121,24 @@ simplify_exprt::simplify_shifts(const shift_exprt &expr) | |
} | ||
|
||
simplify_exprt::resultt<> | ||
simplify_exprt::simplify_power(const binary_exprt &expr) | ||
simplify_exprt::simplify_power(const power_exprt &expr) | ||
{ | ||
if(!is_number(expr.type())) | ||
return unchanged(expr); | ||
|
||
const auto base = numeric_cast<mp_integer>(expr.op0()); | ||
const auto exponent = numeric_cast<mp_integer>(expr.op1()); | ||
const auto base = numeric_cast<mp_integer>(expr.base()); | ||
const auto exponent = numeric_cast<mp_integer>(expr.exponent()); | ||
|
||
if(!base.has_value()) | ||
if(!exponent.has_value()) | ||
return unchanged(expr); | ||
|
||
if(!exponent.has_value()) | ||
if(exponent.value() == 0) | ||
return from_integer(1, expr.type()); | ||
|
||
if(exponent.value() == 1) | ||
return expr.base(); | ||
|
||
if(!base.has_value()) | ||
return unchanged(expr); | ||
|
||
mp_integer result = power(*base, *exponent); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters