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: Tweak to gengtype



On 20/01/2005, at 5:21 PM, Giovanni Bajo wrote:




Geoffrey Keating wrote:



void
gt_ggc_mx_use_optype_d (void *x_p)
{
   struct use_optype_d * const x = (struct use_optype_d *)x_p;
   if (ggc_test_and_set_mark (x))
     {
       {
         size_t i0;
         for (i0 = 0; i0 < (size_t)(((*x)).num_uses); i0++) {
         }
       }
     }
}

I don't know how to avoid the empty loop, and GCC doesn't know how
to remove it :-/  Ideas, anyone?


GCC should really be able to remove a trivial empty loop like this one. It's easy to prove that it (a) really is empty and (b) is guaranteed to terminate. (The second condition is a bit harder, but all the logic should be there.) Do you know why it's not being removed?


How do you prove that x->num_uses is not 0xFFFFFFFF (or similar)?

You don't have to, when 'i0' becomes 0xFFFFFFFF then you'll have 0xFFFFFFFF < 0xFFFFFFFF which is false, so the loop will terminate.



Attachment: smime.p7s
Description: S/MIME cryptographic signature


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