summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatevos <matevosmehrabyan@gmail.com>2022-12-16 18:26:50 +0400
committerJeff Law <jlaw@ventanamicro>2023-03-21 09:03:19 -0600
commitc6bf87a55bef0e7b5bcabc1873f18e1118021d1f (patch)
treef882c968dca2f73970d544cb841ef59f5b970dd5
parent1c76a5f50d28e0ca91fef42884a5b9068a8ad61e (diff)
downloadgcc-c6bf87a55bef0e7b5bcabc1873f18e1118021d1f.tar.gz
sym-exec v9 - Added conditions printing support - Optimized conditions adding when only some of argument's bits are constants - Added basic checks for sym-exec some crc-*.c tests
-rw-r--r--gcc/sym-exec/condition.cc31
-rw-r--r--gcc/sym-exec/condition.h2
-rw-r--r--gcc/sym-exec/expression.cc2
-rw-r--r--gcc/sym-exec/state.cc363
-rw-r--r--gcc/sym-exec/state.h10
-rw-r--r--gcc/testsuite/gcc.dg/crc-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/crc-10.c6
-rw-r--r--gcc/testsuite/gcc.dg/crc-2.c5
-rw-r--r--gcc/testsuite/gcc.dg/crc-23.c6
-rw-r--r--gcc/testsuite/gcc.dg/crc-3.c5
-rw-r--r--gcc/testsuite/gcc.dg/crc-4.c5
-rw-r--r--gcc/testsuite/gcc.dg/crc-5.c5
-rw-r--r--gcc/testsuite/gcc.dg/crc-6.c5
-rw-r--r--gcc/testsuite/gcc.dg/crc-7.c6
-rw-r--r--gcc/testsuite/gcc.dg/crc-8.c6
-rw-r--r--gcc/testsuite/gcc.dg/crc-9.c6
16 files changed, 377 insertions, 92 deletions
diff --git a/gcc/sym-exec/condition.cc b/gcc/sym-exec/condition.cc
index dc42cf9c221..dffb13620c1 100644
--- a/gcc/sym-exec/condition.cc
+++ b/gcc/sym-exec/condition.cc
@@ -6,6 +6,37 @@ bit_condition::bit_condition (value* left, value* right, condition_type type)
this->left = left;
this->right = right;
this->type = type;
+
+ switch (this->type)
+ {
+ case GREAT_THAN:
+ op_sign[0] = '>';
+ op_sign[1] = '\0';
+ break;
+ case LESS_THAN:
+ op_sign[0] = '<';
+ op_sign[1] = '\0';
+ break;
+ case EQUAL:
+ op_sign[0] = '=';
+ op_sign[1] = '=';
+ break;
+ case NOT_EQUAL:
+ op_sign[0] = '!';
+ op_sign[1] = '=';
+ break;
+ case IS_FALSE:
+ op_sign[0] = '0';
+ op_sign[1] = '\0';
+ break;
+ case IS_TRUE:
+ op_sign[0] = '1';
+ op_sign[1] = '\0';
+ break;
+ default:
+ op_sign[0] = '\0';
+ op_sign[1] = '\0';
+ }
}
diff --git a/gcc/sym-exec/condition.h b/gcc/sym-exec/condition.h
index 687ebbf787d..7ecdde7ad32 100644
--- a/gcc/sym-exec/condition.h
+++ b/gcc/sym-exec/condition.h
@@ -7,10 +7,8 @@ enum condition_type
{
GREAT_THAN,
LESS_THAN,
- NOT_ZERO,
EQUAL,
NOT_EQUAL,
- GREAT_OR_EQUAL,
IS_FALSE,
IS_TRUE
};
diff --git a/gcc/sym-exec/expression.cc b/gcc/sym-exec/expression.cc
index 0065c13b05b..d980315fd74 100644
--- a/gcc/sym-exec/expression.cc
+++ b/gcc/sym-exec/expression.cc
@@ -198,7 +198,7 @@ bit_or_expression::bit_or_expression (value *left, value *right)
this->left = left;
this->right = right;
op_sign[0] = '|';
- op_sign[0] = '\0';
+ op_sign[1] = '\0';
}
diff --git a/gcc/sym-exec/state.cc b/gcc/sym-exec/state.cc
index b32239dae90..02b433133d6 100644
--- a/gcc/sym-exec/state.cc
+++ b/gcc/sym-exec/state.cc
@@ -183,7 +183,7 @@ state::clear_conditions ()
}
-/* performs AND operation for 2 symbolic_bit operands. */
+/* Performs AND operation for 2 symbolic_bit operands. */
value *
state::and_sym_bits (const value * var1, const value * var2)
@@ -192,7 +192,7 @@ state::and_sym_bits (const value * var1, const value * var2)
}
-/* performs AND operation for a symbolic_bit and const_bit operands. */
+/* Performs AND operation for a symbolic_bit and const_bit operands. */
value *
state::and_var_const (const value * var1, const bit * const_bit)
@@ -204,7 +204,7 @@ state::and_var_const (const value * var1, const bit * const_bit)
}
-/* performs AND operation for 2 constant bit operands. */
+/* Performs AND operation for 2 constant bit operands. */
bit *
state::and_const_bits (const bit * const_bit1, const bit * const_bit2)
@@ -216,7 +216,7 @@ state::and_const_bits (const bit * const_bit1, const bit * const_bit2)
}
-/* performs OR operation for 2 symbolic_bit operands. */
+/* Performs OR operation for 2 symbolic_bit operands. */
value *
state::or_sym_bits (const value * var1, const value * var2)
@@ -225,7 +225,7 @@ state::or_sym_bits (const value * var1, const value * var2)
}
-/* performs OR operation for a symbolic_bit and a constant bit operands. */
+/* Performs OR operation for a symbolic_bit and a constant bit operands. */
value *
state::or_var_const (const value * var1, const bit * const_bit)
@@ -237,7 +237,7 @@ state::or_var_const (const value * var1, const bit * const_bit)
}
-/* performs OR operation for 2 constant bit operands. */
+/* Performs OR operation for 2 constant bit operands. */
bit *
state::or_const_bits (const bit * const_bit1, const bit * const_bit2)
@@ -544,7 +544,7 @@ state::get_value (const vec <value *> * bits_value)
}
-/* shift_left operation. Case: var2 is a sym_bit. */
+/* Shift_left operation. Case: var2 is a sym_bit. */
void
state::shift_left_sym_bits (vec<value*> * arg1_bits, vec<value*> * arg2_bits,
@@ -622,7 +622,7 @@ state::do_shift_right (vec<value*> * arg1_bits, vec<value*> * arg2_bits,
/* Adds two bits and carry value.
-Resturn result and stores new carry bit in "carry". */
+ Resturn result and stores new carry bit in "carry". */
value*
state::full_adder (value* var1, value* var2, value*& carry)
@@ -1224,6 +1224,8 @@ state::add_equal_cond (tree arg1, tree arg2)
void
state::add_equal_cond (vec<value*> * arg1_bits, vec<value*> * arg2_bits)
{
+
+ /* If both arguments are constants then we can evaluate it. */
if (is_bit_vector (arg1_bits) && is_bit_vector (arg2_bits))
{
bool result = check_const_bit_equality (arg1_bits, arg2_bits);
@@ -1231,8 +1233,27 @@ state::add_equal_cond (vec<value*> * arg1_bits, vec<value*> * arg2_bits)
: condition_status::CS_FALSE;
return;
}
+
+ /* When some of bits are constants and they differ by value,
+ then we can evalate it to be false. */
for (size_t i = 0; i < arg1_bits->length (); i++)
{
+ if (is_a<bit*> ((*arg1_bits)[i]) && is_a<bit*> ((*arg2_bits)[i])
+ && as_a<bit*> ((*arg1_bits)[i])->get_val ()
+ != as_a<bit*> ((*arg2_bits)[i])->get_val ())
+ {
+ last_cond_status = condition_status::CS_FALSE;
+ return;
+ }
+ }
+
+ for (size_t i = 0; i < arg1_bits->length (); i++)
+ {
+ /* If there is a constant bit pair, then they are equal
+ as we checked not equality above. */
+ if (is_a<bit*> ((*arg1_bits)[i]) && is_a<bit*> ((*arg2_bits)[i]))
+ continue;
+
conditions.add (new bit_condition ((*arg1_bits)[i]->copy (),
(*arg2_bits)[i]->copy (),
condition_type::EQUAL));
@@ -1273,9 +1294,27 @@ state::add_not_equal_cond (vec<value*> * arg1_bits, vec<value*> * arg2_bits)
return;
}
+ /* When some of bits are constants and they differ by value,
+ then we can evalate it to be true. */
+ for (size_t i = 0; i < arg1_bits->length (); i++)
+ {
+ if (is_a<bit*> ((*arg1_bits)[i]) && is_a<bit*> ((*arg2_bits)[i])
+ && as_a<bit*> ((*arg1_bits)[i])->get_val ()
+ != as_a<bit*> ((*arg2_bits)[i])->get_val ())
+ {
+ last_cond_status = condition_status::CS_TRUE;
+ return;
+ }
+ }
+
bit_expression * prev = nullptr;
for (size_t i = 0; i < arg1_bits->length (); i++)
{
+ /* If there is a constant bit pair, then they are equal
+ as we checked not equality above. */
+ if (is_a<bit*> ((*arg1_bits)[i]) && is_a<bit*> ((*arg2_bits)[i]))
+ continue;
+
bit_condition* new_cond = new bit_condition ((*arg1_bits)[i]->copy (),
(*arg2_bits)[i]->copy (),
condition_type::NOT_EQUAL);
@@ -1328,8 +1367,30 @@ state::add_greater_than_cond (vec<value*> * arg1_bits,
return;
}
- last_cond_status = condition_status::CS_SYM;
- conditions.add (construct_great_than_cond (arg1_bits, arg2_bits));
+ if (is_bit_vector (arg2_bits) && is_a<bit*> (arg1_bits->last ())
+ && get_value (arg2_bits) == 0 /* && is_signed (arg1_bits). */)
+ {
+ if (as_a<bit*> (arg1_bits->last ())->get_val () == 1)
+ last_cond_status = condition_status::CS_FALSE;
+ else
+ {
+ for (size_t i = 0; i < arg1_bits->length (); i++)
+ if (is_a<bit*> ((*arg1_bits)[i])
+ && as_a<bit*> ((*arg1_bits)[i])->get_val ())
+ {
+ last_cond_status = condition_status::CS_TRUE;
+ return;
+ }
+ }
+ }
+
+ bit_expression * gt_cond = construct_great_than_cond (arg1_bits, arg2_bits);
+ if (gt_cond)
+ {
+ /* Otherwise its status is already set. */
+ last_cond_status = condition_status::CS_SYM;
+ conditions.add (gt_cond);
+ }
}
@@ -1341,26 +1402,61 @@ state::construct_great_than_cond (vec<value*> * arg1_bits,
vec<value*> * arg2_bits)
{
bit_expression* prev = nullptr;
- size_t i = 0;
- for ( ; i < arg1_bits->length () - 1; i++)
- {
- bit_condition* greater_cond
- = new bit_condition ((*arg1_bits)[i]->copy (), (*arg2_bits)[i]->copy (),
- condition_type::GREAT_THAN);
- bit_condition* eq_cond = new bit_condition ((*arg1_bits)[i + 1]->copy (),
- (*arg2_bits)[i + 1]->copy (),
- condition_type::EQUAL);
- bit_expression* and_expr = new bit_and_expression (eq_cond, greater_cond);
- if (prev)
- prev = new bit_or_expression (and_expr, prev);
+ int i = arg1_bits->length () - 1;
+ for ( ; i >= 0; i--)
+ {
+ if (is_a<bit *> ((*arg1_bits)[i]) && is_a<bit *> ((*arg2_bits)[i]))
+ {
+ if (as_a<bit*> ((*arg1_bits)[i])->get_val ()
+ > as_a<bit*> ((*arg2_bits)[i])->get_val ())
+ {
+ if (!prev)
+ last_cond_status = condition_status::CS_TRUE;
+ return prev;
+ }
+ else if (as_a<bit*> ((*arg1_bits)[i])->get_val ()
+ < as_a<bit*> ((*arg2_bits)[i])->get_val ())
+ {
+ if (prev)
+ {
+ bit_expression* ret_val
+ = as_a<bit_expression*> (prev->get_left ()->copy ());
+ delete prev;
+ return ret_val;
+ }
+ else
+ {
+ last_cond_status = condition_status::CS_FALSE;
+ return nullptr;
+ }
+ }
+ }
else
- prev = and_expr;
+ {
+ bit_condition* gt_cond
+ = new bit_condition ((*arg1_bits)[i]->copy (),
+ (*arg2_bits)[i]->copy (),
+ condition_type::GREAT_THAN);
+ bit_expression* expr = nullptr;
+ if (i)
+ {
+ bit_condition* eq_cond
+ = new bit_condition ((*arg1_bits)[i]->copy (),
+ (*arg2_bits)[i]->copy (),
+ condition_type::EQUAL);
+ expr = new bit_or_expression (gt_cond, eq_cond);
+ }
+ else
+ expr = gt_cond;
+
+ if (prev)
+ prev = new bit_and_expression (expr, prev);
+ else
+ prev = expr;
+ }
}
- bit_condition* greater_cond = new bit_condition ((*arg1_bits)[i]->copy (),
- (*arg2_bits)[i]->copy (),
- condition_type::GREAT_THAN);
- return new bit_or_expression (greater_cond, prev);
+ return prev;
}
@@ -1393,7 +1489,9 @@ state::add_less_than_cond (tree arg1, tree arg2)
void
state::add_less_than_cond (vec<value*> * arg1_bits, vec<value*> * arg2_bits)
{
- if (is_bit_vector (arg1_bits) && is_bit_vector (arg2_bits))
+ if (is_bit_vector (arg1_bits) && is_bit_vector (arg2_bits)
+ /* Fix this after adding signed numbers support. */
+ && get_value (arg2_bits) != 0)
{
bool result = check_const_bit_is_less_than (arg1_bits, arg2_bits);
last_cond_status = result ? condition_status::CS_TRUE
@@ -1402,7 +1500,27 @@ state::add_less_than_cond (vec<value*> * arg1_bits, vec<value*> * arg2_bits)
}
last_cond_status = condition_status::CS_SYM;
- conditions.add (construct_less_than_cond (arg1_bits, arg2_bits));
+ if (is_bit_vector (arg2_bits) && get_value (arg2_bits) == 0)
+ {
+ /* TODO: handle is_signed (arg1_bits) case properly. */
+ if (is_a<bit*> (arg1_bits->last ()))
+ {
+ if (as_a<bit*> (arg1_bits->last ())->get_val () == 1)
+ last_cond_status = condition_status::CS_TRUE;
+ else
+ last_cond_status = condition_status::CS_FALSE;
+ }
+ else
+ conditions.add (new bit_condition (arg1_bits->last ()->copy (),
+ new bit (1), condition_type::EQUAL));
+
+ return;
+ }
+
+ bit_expression * lt_cond = construct_less_than_cond (arg1_bits, arg2_bits);
+ if (lt_cond)
+ /* Otherwise its status is already set. */
+ conditions.add (lt_cond);
}
@@ -1414,26 +1532,61 @@ state::construct_less_than_cond (vec<value*> * arg1_bits,
vec<value*> * arg2_bits)
{
bit_expression* prev = nullptr;
- size_t i = 0;
- for ( ; i < arg1_bits->length () - 1; i++)
- {
- bit_condition* less_cond = new bit_condition ((*arg1_bits)[i]->copy (),
- (*arg2_bits)[i]->copy (),
- condition_type::LESS_THAN);
- bit_condition* eq_cond = new bit_condition ((*arg1_bits)[i + 1]->copy (),
- (*arg2_bits)[i + 1]->copy (),
- condition_type::EQUAL);
- bit_expression* and_expr = new bit_and_expression (eq_cond, less_cond);
- if (prev)
- prev = new bit_or_expression (and_expr, prev);
+ int i = arg1_bits->length () - 1;
+ for ( ; i >= 0; i--)
+ {
+ if (is_a<bit *> ((*arg1_bits)[i]) && is_a<bit *> ((*arg2_bits)[i]))
+ {
+ if (as_a<bit*> ((*arg1_bits)[i])->get_val ()
+ < as_a<bit*> ((*arg2_bits)[i])->get_val ())
+ {
+ if (!prev)
+ last_cond_status = condition_status::CS_TRUE;
+ return prev;
+ }
+ else if (as_a<bit*> ((*arg1_bits)[i])->get_val ()
+ > as_a<bit*> ((*arg2_bits)[i])->get_val ())
+ {
+ if (prev)
+ {
+ bit_expression* ret_val
+ = as_a<bit_expression*> (prev->get_left ()->copy ());
+ delete prev;
+ return ret_val;
+ }
+ else
+ {
+ last_cond_status = condition_status::CS_FALSE;
+ return nullptr;
+ }
+ }
+ }
else
- prev = and_expr;
+ {
+ bit_condition* lt_cond
+ = new bit_condition ((*arg1_bits)[i]->copy (),
+ (*arg2_bits)[i]->copy (),
+ condition_type::LESS_THAN);
+ bit_expression* expr = nullptr;
+ if (i)
+ {
+ bit_condition* eq_cond
+ = new bit_condition ((*arg1_bits)[i]->copy (),
+ (*arg2_bits)[i]->copy (),
+ condition_type::EQUAL);
+ expr = new bit_or_expression (lt_cond, eq_cond);
+ }
+ else
+ expr = lt_cond;
+
+ if (prev)
+ prev = new bit_and_expression (expr, prev);
+ else
+ prev = expr;
+ }
}
- bit_condition* less_cond = new bit_condition ((*arg1_bits)[i]->copy (),
- (*arg2_bits)[i]->copy (),
- condition_type::LESS_THAN);
- return new bit_or_expression (less_cond, prev);
+ return prev;
}
@@ -1450,7 +1603,9 @@ void
state::add_greater_or_equal_cond (vec<value*> * arg1_bits,
vec<value*> * arg2_bits)
{
- if (is_bit_vector (arg1_bits) && is_bit_vector (arg2_bits))
+ if (is_bit_vector (arg1_bits) && is_bit_vector (arg2_bits)
+ /* Fix this after adding signed numbers support. */
+ && get_value (arg2_bits) == 0)
{
bool is_greater_than = check_const_bit_is_greater_than (arg1_bits,
arg2_bits);
@@ -1462,9 +1617,31 @@ state::add_greater_or_equal_cond (vec<value*> * arg1_bits,
}
last_cond_status = condition_status::CS_SYM;
- conditions.add (
- new bit_or_expression (construct_great_than_cond (arg1_bits, arg2_bits),
- construct_equal_cond (arg1_bits, arg2_bits)));
+ if (is_bit_vector (arg2_bits) && get_value (arg2_bits) == 0)
+ {
+ /* TODO: handle is_signed (arg1_bits) case properly. */
+ if (is_a<bit*> (arg1_bits->last ()))
+ {
+ if (as_a<bit*> (arg1_bits->last ())->get_val () == 1)
+ last_cond_status = condition_status::CS_FALSE;
+ else
+ last_cond_status = condition_status::CS_TRUE;
+ }
+ else
+ conditions.add (new bit_condition (arg1_bits->last ()->copy (),
+ new bit (0), condition_type::EQUAL));
+
+ return;
+ }
+
+ bit_expression * eq_cond = construct_equal_cond (arg1_bits, arg2_bits);
+ if (!eq_cond)
+ return;
+
+ bit_expression * gt_cond = construct_great_than_cond (arg1_bits, arg2_bits);
+ if (gt_cond)
+ /* Otherwise its status is already set. */
+ conditions.add (new bit_or_expression (eq_cond, gt_cond));
}
@@ -1492,9 +1669,14 @@ state::add_less_or_equal_cond (vec<value*> * arg1_bits,
}
last_cond_status = condition_status::CS_SYM;
- conditions.add (
- new bit_or_expression (construct_less_than_cond (arg1_bits, arg2_bits),
- construct_equal_cond (arg1_bits, arg2_bits)));
+ bit_expression * eq_cond = construct_equal_cond (arg1_bits, arg2_bits);
+ if (!eq_cond)
+ return;
+
+ bit_expression * lt_cond = construct_less_than_cond (arg1_bits, arg2_bits);
+ if (lt_cond)
+ /* Otherwise its status is already set. */
+ conditions.add (new bit_or_expression (eq_cond, lt_cond));
}
@@ -1509,22 +1691,30 @@ state::add_bool_cond (tree arg)
return false;
}
+
vec<value *> * arg_bits = var_states.get (arg);
+ for (size_t i = 0; i < arg_bits->length (); i++)
+ if (is_a<bit *>((*arg_bits)[i])
+ && as_a<bit *>((*arg_bits)[i])->get_val () != 0)
+ {
+ last_cond_status = condition_status::CS_TRUE;
+ print_conditions ();
+ return true;
+ }
+
if (is_bit_vector (arg_bits))
{
last_cond_status = condition_status::CS_FALSE;
- for (size_t i = 0; i < arg_bits->length (); i++)
- if (as_a<bit *>((*arg_bits)[i])->get_val () != 0)
- {
- last_cond_status = condition_status::CS_TRUE;
- break;
- }
+ print_conditions ();
return true;
}
bit_expression* prev = nullptr;
for (size_t i = 0; i < arg_bits->length (); i++)
{
+ if (is_a<bit*> ((*arg_bits)[i]))
+ continue;
+
bit_condition* not_eq_cond
= new bit_condition ((*arg_bits)[i], new bit (0),
condition_type::NOT_EQUAL);
@@ -1536,6 +1726,7 @@ state::add_bool_cond (tree arg)
last_cond_status = condition_status::CS_SYM;
conditions.add (prev);
+ print_conditions ();
return true;
}
@@ -1586,6 +1777,7 @@ state::add_binary_cond (tree arg1, tree arg2, binary_cond_func cond_func)
(this->*cond_func)(arg1_bits, arg2_bits);
free_bits (&arg1_const_bits);
free_bits (&arg2_const_bits);
+ print_conditions ();
return true;
}
@@ -1597,6 +1789,28 @@ bit_expression*
state::construct_equal_cond (vec<value*> * arg1_bits,
vec<value*> * arg2_bits)
{
+ /* If both arguments are constants then we can evaluate it. */
+ if (is_bit_vector (arg1_bits) && is_bit_vector (arg2_bits))
+ {
+ bool result = check_const_bit_equality (arg1_bits, arg2_bits);
+ last_cond_status = result ? condition_status::CS_TRUE
+ : condition_status::CS_FALSE;
+ return nullptr;
+ }
+
+ /* When some of bits are constants and they differ by value,
+ then we can evalate it to be false. */
+ for (size_t i = 0; i < arg1_bits->length (); i++)
+ {
+ if (is_a<bit*> ((*arg1_bits)[i]) && is_a<bit*> ((*arg2_bits)[i])
+ && as_a<bit*> ((*arg1_bits)[i])->get_val ()
+ != as_a<bit*> ((*arg2_bits)[i])->get_val ())
+ {
+ last_cond_status = condition_status::CS_FALSE;
+ return nullptr;
+ }
+ }
+
bit_expression* prev = nullptr;
for (size_t i = 0; i < arg1_bits->length (); i++)
{
@@ -1672,6 +1886,8 @@ state::make_copy (vec<value *> *bits)
}
+/* Returns status of last added condition. */
+
condition_status
state::get_last_cond_status ()
{
@@ -1679,6 +1895,8 @@ state::get_last_cond_status ()
}
+/* Prints given bits as expressions. */
+
void
state::print_bits (vec<value *> * bits)
{
@@ -1829,3 +2047,30 @@ state::create_lfsr (tree crc, vec<value *> *polynomial, bool is_bit_forward)
return lfsr;
}
+
+
+/* Prints added conditions. */
+
+void
+state::print_conditions ()
+{
+ if (!dump_file || !(dump_flags & TDF_DETAILS))
+ return;
+
+ fprintf (dump_file, "Conditions {");
+ auto iter = conditions.begin ();
+ while (true)
+ {
+ if (iter != conditions.end ())
+ {
+ (*iter)->print ();
+ ++iter;
+ }
+
+ if (iter != conditions.end ())
+ fprintf (dump_file, ", ");
+ else
+ break;
+ }
+ fprintf (dump_file, "}\n");
+}
diff --git a/gcc/sym-exec/state.h b/gcc/sym-exec/state.h
index 9a4231cfe1d..45766ec9b4a 100644
--- a/gcc/sym-exec/state.h
+++ b/gcc/sym-exec/state.h
@@ -152,11 +152,11 @@ class state {
/* Performs XOR operation for a symbolic_bit and const_bit operands. */
static value *xor_var_const (const value * var, const bit * const_bit);
- /* shift_right operation. Case: var2 is a sym_bit. */
+ /* Shift_right operation. Case: var2 is a sym_bit. */
void shift_right_sym_bits (vec<value*> * arg1_bits, vec<value*> * arg2_bits,
tree dest);
- /* shift_left operation. Case: var2 is a sym_bit. */
+ /* Shift_left operation. Case: var2 is a sym_bit. */
void shift_left_sym_bits (vec<value*> * arg1_bits, vec<value*> * arg2_bits,
tree dest);
@@ -242,9 +242,13 @@ class state {
/* Returns size of the given variable. */
unsigned get_var_size (tree var);
+ /* Prints given bits as expressions. */
static void print_bits (vec<value *> * bits);
- /* returns the value of the number represented as a bit vector. */
+ /* Prints added conditions. */
+ void print_conditions ();
+
+ /* Returns the value of the number represented as a bit vector. */
static unsigned HOST_WIDE_INT get_value (const vec <value *> *bit_vector);
/* Does bit-level XOR operation for given variables. */
diff --git a/gcc/testsuite/gcc.dg/crc-1.c b/gcc/testsuite/gcc.dg/crc-1.c
index 951e755c17a..acad4a3dc6e 100644
--- a/gcc/testsuite/gcc.dg/crc-1.c
+++ b/gcc/testsuite/gcc.dg/crc-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
#include <stdio.h>
#include <stdint.h>
@@ -52,5 +52,5 @@ uint16_t gen_crc16(const uint8_t *data, uint16_t size) {
/* { dg-final { scan-tree-dump "Return size is 16" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 15" "crc"} } */
/* { dg-final { scan-tree-dump "Bit forward" "crc"} } */
-
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+(\(\[a-zA-Z\]\))?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */ \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/crc-10.c b/gcc/testsuite/gcc.dg/crc-10.c
index 33aa7602e4a..bfea6bdc1b8 100644
--- a/gcc/testsuite/gcc.dg/crc-10.c
+++ b/gcc/testsuite/gcc.dg/crc-10.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
#include <stdint.h>
@@ -21,5 +21,5 @@ u8 crc8(u16 data) {
/* { dg-final { scan-tree-dump "Return size is 8" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
/* { dg-final { scan-tree-dump "Bit forward" "crc"} } */
-
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */ \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/crc-2.c b/gcc/testsuite/gcc.dg/crc-2.c
index 99319e943f7..57bb9231392 100644
--- a/gcc/testsuite/gcc.dg/crc-2.c
+++ b/gcc/testsuite/gcc.dg/crc-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
#define CRC16_CCITT 0x102
#define POLYNOM CRC16_CCITT
@@ -25,4 +25,5 @@ unsigned int crc16(unsigned int crcValue, unsigned char newByte) {
/* { dg-final { scan-tree-dump "Return size is 32" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
/* { dg-final { scan-tree-dump "Bit forward" "crc"} } */
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */ \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/crc-23.c b/gcc/testsuite/gcc.dg/crc-23.c
index cdc277679d2..141fe0d328e 100644
--- a/gcc/testsuite/gcc.dg/crc-23.c
+++ b/gcc/testsuite/gcc.dg/crc-23.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
#include <stdint.h>
@@ -18,4 +18,6 @@ uint16_t crc16(uint16_t crc, uint8_t a, uint16_t polynom) {
/* { dg-final { scan-tree-dump "Attention! crc16 function calculates CRC." "crc"} } */
/* { dg-final { scan-tree-dump "Return size is 16" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
-/* { dg-final { scan-tree-dump "Bit reversed" "crc"} } */ \ No newline at end of file
+/* { dg-final { scan-tree-dump "Bit reversed" "crc"} } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */ \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/crc-3.c b/gcc/testsuite/gcc.dg/crc-3.c
index 71c57ad60e8..fe0cbf808eb 100644
--- a/gcc/testsuite/gcc.dg/crc-3.c
+++ b/gcc/testsuite/gcc.dg/crc-3.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
unsigned short crc16(char *data_p, unsigned short length) {
unsigned char i;
@@ -30,4 +30,5 @@ unsigned short crc16(char *data_p, unsigned short length) {
/* { dg-final { scan-tree-dump "Return size is 16" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
/* { dg-final { scan-tree-dump "Bit reversed" "crc"} } */
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */ \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/crc-4.c b/gcc/testsuite/gcc.dg/crc-4.c
index 0aa1156fb4b..2bbc68e60c4 100644
--- a/gcc/testsuite/gcc.dg/crc-4.c
+++ b/gcc/testsuite/gcc.dg/crc-4.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
#include <stdint.h>
@@ -19,4 +19,5 @@ uint16_t crc16_update(uint16_t crc, uint8_t a) {
/* { dg-final { scan-tree-dump "Return size is 16" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
/* { dg-final { scan-tree-dump "Bit reversed" "crc"} } */
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */ \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/crc-5.c b/gcc/testsuite/gcc.dg/crc-5.c
index 9014937216c..d01669a210a 100644
--- a/gcc/testsuite/gcc.dg/crc-5.c
+++ b/gcc/testsuite/gcc.dg/crc-5.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
typedef unsigned short ee_u16;
typedef unsigned char ee_u8;
@@ -26,4 +26,5 @@ ee_u16 crcu8(ee_u8 data, ee_u16 crc) {
/* { dg-final { scan-tree-dump "Return size is 16" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
/* { dg-final { scan-tree-dump "Bit reversed" "crc"} } */
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */ \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/crc-6.c b/gcc/testsuite/gcc.dg/crc-6.c
index 7fa60b23702..ebeb373ee15 100644
--- a/gcc/testsuite/gcc.dg/crc-6.c
+++ b/gcc/testsuite/gcc.dg/crc-6.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
#include <stdint.h>
@@ -30,4 +30,5 @@ crcSlow(uint8_t const message[], int nBytes) {
/* { dg-final { scan-tree-dump "Return size is 8" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
/* { dg-final { scan-tree-dump "Bit forward" "crc"} } */
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */ \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/crc-7.c b/gcc/testsuite/gcc.dg/crc-7.c
index e6815c050f6..f05d0557f09 100644
--- a/gcc/testsuite/gcc.dg/crc-7.c
+++ b/gcc/testsuite/gcc.dg/crc-7.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
#include <stdint.h>
@@ -19,5 +19,5 @@ uint16_t crc_xmodem_update(uint16_t crc, uint8_t data) {
/* { dg-final { scan-tree-dump "Return size is 16" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
/* { dg-final { scan-tree-dump "Bit forward" "crc"} } */
-
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */
diff --git a/gcc/testsuite/gcc.dg/crc-8.c b/gcc/testsuite/gcc.dg/crc-8.c
index 730b7a9d3c5..d04f42e541a 100644
--- a/gcc/testsuite/gcc.dg/crc-8.c
+++ b/gcc/testsuite/gcc.dg/crc-8.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
#include <stdint.h>
@@ -19,5 +19,5 @@ uint8_t _crc_ibutton_update(uint8_t crc, uint8_t data) {
/* { dg-final { scan-tree-dump "Return size is 8" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
/* { dg-final { scan-tree-dump "Bit reversed" "crc"} } */
-
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */
diff --git a/gcc/testsuite/gcc.dg/crc-9.c b/gcc/testsuite/gcc.dg/crc-9.c
index 2eb79676219..6c644b4ed70 100644
--- a/gcc/testsuite/gcc.dg/crc-9.c
+++ b/gcc/testsuite/gcc.dg/crc-9.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-crc" } */
+/* { dg-options "-O2 -fdump-tree-crc-details" } */
#include <stdio.h>
@@ -24,5 +24,5 @@ uint8_t gencrc(uint8_t *data, size_t len) {
/* { dg-final { scan-tree-dump "Return size is 8" "crc"} } */
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */
/* { dg-final { scan-tree-dump "Bit forward" "crc"} } */
-
-
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */
+/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */