/* Interprocedural Identical Code Folding pass
- Copyright (C) 2014-2016 Free Software Foundation, Inc.
+ Copyright (C) 2014-2019 Free Software Foundation, Inc.
Contributed by Jan Hubicka <hubicka@ucw.cz> and Martin Liska <mliska@suse.cz>
#include "ipa-utils.h"
#include "tree-eh.h"
#include "builtins.h"
+#include "cfgloop.h"
#include "ipa-icf-gimple.h"
}
case LABEL_DECL:
{
+ if (t1 == t2)
+ return true;
+
int *bb1 = m_label_bb_map.get (t1);
int *bb2 = m_label_bb_map.get (t2);
- return return_with_debug (*bb1 == *bb2);
+ /* Labels can point to another function (non-local GOTOs). */
+ return return_with_debug (bb1 != NULL && bb2 != NULL && *bb1 == *bb2);
}
case PARM_DECL:
case RESULT_DECL:
{
case CONSTRUCTOR:
{
- unsigned length1 = vec_safe_length (CONSTRUCTOR_ELTS (t1));
- unsigned length2 = vec_safe_length (CONSTRUCTOR_ELTS (t2));
+ unsigned length1 = CONSTRUCTOR_NELTS (t1);
+ unsigned length2 = CONSTRUCTOR_NELTS (t2);
if (length1 != length2)
return return_false ();
return return_false_with_msg ("");
/* Type of the offset on MEM_REF does not matter. */
- return wi::to_offset (y1) == wi::to_offset (y2);
+ return known_eq (wi::to_poly_offset (y1), wi::to_poly_offset (y2));
}
case COMPONENT_REF:
{
}
}
-/* Compares two tree list operands T1 and T2 and returns true if these
- two trees are semantically equivalent. */
-
bool
-func_checker::compare_tree_list_operand (tree t1, tree t2)
+func_checker::compare_asm_inputs_outputs (tree t1, tree t2)
{
gcc_assert (TREE_CODE (t1) == TREE_LIST);
gcc_assert (TREE_CODE (t2) == TREE_LIST);
if (!compare_operand (TREE_VALUE (t1), TREE_VALUE (t2)))
return return_false ();
+ tree p1 = TREE_PURPOSE (t1);
+ tree p2 = TREE_PURPOSE (t2);
+
+ gcc_assert (TREE_CODE (p1) == TREE_LIST);
+ gcc_assert (TREE_CODE (p2) == TREE_LIST);
+
+ if (strcmp (TREE_STRING_POINTER (TREE_VALUE (p1)),
+ TREE_STRING_POINTER (TREE_VALUE (p2))) != 0)
+ return return_false ();
+
t2 = TREE_CHAIN (t2);
}
return return_with_debug (ret);
}
+/* Compare loop information for basic blocks BB1 and BB2. */
+
+bool
+func_checker::compare_loops (basic_block bb1, basic_block bb2)
+{
+ if ((bb1->loop_father == NULL) != (bb2->loop_father == NULL))
+ return return_false ();
+
+ struct loop *l1 = bb1->loop_father;
+ struct loop *l2 = bb2->loop_father;
+ if (l1 == NULL)
+ return true;
+
+ if ((bb1 == l1->header) != (bb2 == l2->header))
+ return return_false_with_msg ("header");
+ if ((bb1 == l1->latch) != (bb2 == l2->latch))
+ return return_false_with_msg ("latch");
+ if (l1->simdlen != l2->simdlen)
+ return return_false_with_msg ("simdlen");
+ if (l1->safelen != l2->safelen)
+ return return_false_with_msg ("safelen");
+ if (l1->can_be_parallel != l2->can_be_parallel)
+ return return_false_with_msg ("can_be_parallel");
+ if (l1->dont_vectorize != l2->dont_vectorize)
+ return return_false_with_msg ("dont_vectorize");
+ if (l1->force_vectorize != l2->force_vectorize)
+ return return_false_with_msg ("force_vectorize");
+ if (l1->unroll != l2->unroll)
+ return return_false_with_msg ("unroll");
+ if (!compare_variable_decl (l1->simduid, l2->simduid))
+ return return_false_with_msg ("simduid");
+
+ return true;
+}
/* Function visits all gimple labels and creates corresponding
mapping between basic blocks and labels. */
gimple_stmt_iterator gsi1, gsi2;
gimple *s1, *s2;
- gsi1 = gsi_start_bb_nondebug (bb1->bb);
- gsi2 = gsi_start_bb_nondebug (bb2->bb);
+ gsi1 = gsi_start_nondebug_bb (bb1->bb);
+ gsi2 = gsi_start_nondebug_bb (bb2->bb);
while (!gsi_end_p (gsi1))
{
if (!gsi_end_p (gsi2))
return return_false ();
+ if (!compare_loops (bb1->bb, bb2->bb))
+ return return_false ();
+
return true;
}
|| gimple_call_return_slot_opt_p (s1) != gimple_call_return_slot_opt_p (s2)
|| gimple_call_from_thunk_p (s1) != gimple_call_from_thunk_p (s2)
|| gimple_call_va_arg_pack_p (s1) != gimple_call_va_arg_pack_p (s2)
- || gimple_call_alloca_for_var_p (s1) != gimple_call_alloca_for_var_p (s2)
- || gimple_call_with_bounds_p (s1) != gimple_call_with_bounds_p (s2))
+ || gimple_call_alloca_for_var_p (s1) != gimple_call_alloca_for_var_p (s2))
return false;
if (gimple_call_internal_p (s1)
if (gimple_asm_input_p (g1) != gimple_asm_input_p (g2))
return false;
+ if (gimple_asm_inline_p (g1) != gimple_asm_inline_p (g2))
+ return false;
+
if (gimple_asm_ninputs (g1) != gimple_asm_ninputs (g2))
return false;
tree input1 = gimple_asm_input_op (g1, i);
tree input2 = gimple_asm_input_op (g2, i);
- if (!compare_tree_list_operand (input1, input2))
+ if (!compare_asm_inputs_outputs (input1, input2))
return return_false_with_msg ("ASM input is different");
}
tree output1 = gimple_asm_output_op (g1, i);
tree output2 = gimple_asm_output_op (g2, i);
- if (!compare_tree_list_operand (output1, output2))
+ if (!compare_asm_inputs_outputs (output1, output2))
return return_false_with_msg ("ASM output is different");
}