]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sym-exec v9 - Added conditions printing support - Optimized conditions adding when...
authormatevos <matevosmehrabyan@gmail.com>
Fri, 16 Dec 2022 14:26:50 +0000 (18:26 +0400)
committerJeff Law <jlaw@ventanamicro>
Tue, 21 Mar 2023 15:03:19 +0000 (09:03 -0600)
16 files changed:
gcc/sym-exec/condition.cc
gcc/sym-exec/condition.h
gcc/sym-exec/expression.cc
gcc/sym-exec/state.cc
gcc/sym-exec/state.h
gcc/testsuite/gcc.dg/crc-1.c
gcc/testsuite/gcc.dg/crc-10.c
gcc/testsuite/gcc.dg/crc-2.c
gcc/testsuite/gcc.dg/crc-23.c
gcc/testsuite/gcc.dg/crc-3.c
gcc/testsuite/gcc.dg/crc-4.c
gcc/testsuite/gcc.dg/crc-5.c
gcc/testsuite/gcc.dg/crc-6.c
gcc/testsuite/gcc.dg/crc-7.c
gcc/testsuite/gcc.dg/crc-8.c
gcc/testsuite/gcc.dg/crc-9.c

index dc42cf9c221f92ea3021fe36a6e357a1da45abf3..dffb13620c1d8b423e0c302ea7ec30e1af17ec69 100644 (file)
@@ -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';
+    }
 }
 
 
index 687ebbf787d212452c32eedf9cf2a56f38017d87..7ecdde7ad3232b81788e77ab6e30780a77873763 100644 (file)
@@ -7,10 +7,8 @@ enum condition_type
 {
   GREAT_THAN,
   LESS_THAN,
-  NOT_ZERO,
   EQUAL,
   NOT_EQUAL,
-  GREAT_OR_EQUAL,
   IS_FALSE,
   IS_TRUE
 };
index 0065c13b05bd17c4160e0bd8ce68330ff010f30f..d980315fd74a3e99ed7e506dd2e6e0d9ed59e5e8 100644 (file)
@@ -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';
 }
 
 
index b32239dae90433f53e54e1c5554a5b9be535d5b4..02b433133d67840de79c8a6485d3e6cd088346bf 100644 (file)
@@ -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");
+}
index 9a4231cfe1d7795d146b54bb9777e887af2b76b3..45766ec9b4a11877c3c1c0e31f3ab818bb6739ed 100644 (file)
@@ -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.  */
index 951e755c17a15cf06f6b9ccc83f41928fddf48d2..acad4a3dc6e9020396c787f0d36f6a9c69515615 100644 (file)
@@ -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
index 33aa7602e4a98d325b85b55bd8cef1a2a367a565..bfea6bdc1b88805e1671958a4bb2181cb4094eaf 100644 (file)
@@ -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
index 99319e943f7db911d08eee08b1dba4d2b5e4ec5e..57bb9231392b199fe77de7ad9c091a1a942a225c 100644 (file)
@@ -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
index cdc277679d25c3240976da8efe3922d5798d6e50..141fe0d328ec4b7e48f49e5cafe347c72bc0bc1a 100644 (file)
@@ -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
index 71c57ad60e83510fd6d2fccd2f08ffe83dd6800c..fe0cbf808eb15ca08d77c0042c0f63261a4b5d56 100644 (file)
@@ -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
index 0aa1156fb4b0d3d96a9f6094b0cbe4a65e163f71..2bbc68e60c4371c655fd3a4a06a14b0494359c06 100644 (file)
@@ -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
index 9014937216c349fbfbfe8ab7d22d725ae29d9c81..d01669a210a9b7a6cc340ce115875a829d7bcded 100644 (file)
@@ -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
index 7fa60b237027323c23ff3fc0a09e611f7a7c2ede..ebeb373ee15e5b8a56d90a49573411846d34f02d 100644 (file)
@@ -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
index e6815c050f688276e1edad4c3947e8f1033e533d..f05d0557f097e2334325b1f5eff4858b5329f2f6 100644 (file)
@@ -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" } } */
index 730b7a9d3c5b8c340ba7b72d370e22a2c838973d..d04f42e541a27a06c205ff51a20b393cf321f6b6 100644 (file)
@@ -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" } } */
index 2eb796762197a8948ef56b941d475225e208a9b4..6c644b4ed70e80059f6d6a8aa776dc8e02621bf9 100644 (file)
@@ -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" } } */