This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/5] IPA ICF pass


> > +/* Verifies for given GIMPLEs S1 and S2 that
> > +   goto statements are semantically equivalent.  */
> > +
> > +bool
> > +func_checker::compare_gimple_goto (gimple g1, gimple g2)
> > +{
> > +  tree dest1, dest2;
> > +
> > +  dest1 = gimple_goto_dest (g1);
> > +  dest2 = gimple_goto_dest (g2);
> > +
> > +  if (TREE_CODE (dest1) != TREE_CODE (dest2) || TREE_CODE (dest1) != SSA_NAME)
> > +    return false;
> > +
> > +  return compare_operand (dest1, dest2);
> > 
> > You probably need to care only about indirect gotos, the direct ones are checked by
> > CFG compare.  So is the condtional jump.
> 
> It looks that this code is visited quite rare.

Hmm, perhaps it is called only for indirect calls, because all others are not represented as statements.
> 
> > +
> > +/* Verifies for given GIMPLEs S1 and S2 that ASM statements are equivalent.
> > +   For the beginning, the pass only supports equality for
> > +   '__asm__ __volatile__ ("", "", "", "memory")'.  */
> > +
> > +bool
> > +func_checker::compare_gimple_asm (gimple g1, gimple g2)
> > +{
> > +  if (gimple_asm_volatile_p (g1) != gimple_asm_volatile_p (g2))
> > +    return false;
> > +
> > +  if (gimple_asm_ninputs (g1) || gimple_asm_ninputs (g2))
> > +    return false;
> > +
> > +  if (gimple_asm_noutputs (g1) || gimple_asm_noutputs (g2))
> > +    return false;
> > +
> > +  if (gimple_asm_nlabels (g1) || gimple_asm_nlabels (g2))
> > +    return false;
> > +
> > +  if (gimple_asm_nclobbers (g1) != gimple_asm_nclobbers (g2))
> > +    return false;
> > +
> > +  for (unsigned i = 0; i < gimple_asm_nclobbers (g1); i++)
> > +    {
> > +      tree clobber1 = TREE_VALUE (gimple_asm_clobber_op (g1, i));
> > +      tree clobber2 = TREE_VALUE (gimple_asm_clobber_op (g2, i));
> > +
> > +      if (!operand_equal_p (clobber1, clobber2, OEP_ONLY_CONST))
> > +	return false;
> > +    }
> > +
> > 
> > Even asm statements with no inputs or outputs can differ by the actual
> > asm statement. Compare it too.
> > 
> > Comparing inputs/outputs/labels should be very easy to do.
> > 
> > Compare all gimple_asm_n* for equivalency.
> 
> This makes fully sense, but I don't understand what kind of operands do you mean?

You can look some other code dealing with gimple asm statements.  You can just compare
gimple_op for 0.... gimple_num_ops and be ready to deal with TREE_LIST as described
bellow. 

Honza
> 
> > At the end walk operands and watch the case they are TREE_LIST.
> > THen compare TREE_VALUE (op) of the list for operand_equal_p
> > and TREE_VALUE (TREE_PURPOSE (op)) for equivalency
> > (those are the constraints)
> > 
> > If they are not (clobbers are not, those are just strings), operand_equal_p
> > should do.
> > 
> > +  return true;
> > +}
> > +
> > +} // ipa_icf namespace
> > 
> > Otherwise I think ipa-gimple-icf is quite fine now.
> > Please send updated version and I think it can go to mainline before the actual ipa-icf.
> 
> I renamed both files and put them to a newly created namespace ipa_icf_gimple.
> 
> Thank you,
> Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]