[llvm-commits] [llvm] r51222 - /llvm/trunk/lib/Target/README.txt

Chris Lattner clattner at apple.com
Sun May 18 07:24:11 PDT 2008


On May 17, 2008, at 11:11 PM, Bill Wendling wrote:
>> +We should be able to evaluate this loop:
>> +
>> +int test(int x_offs) {
>> +  while (x_offs > 4)
>> +     x_offs -= 4;
>> +  return x_offs;
>> +}
>
> Into "x_offs % 4", right?

I would expect indvars to turn it to roughly into:

   int tripcount = x_offs/4;
   while (i = 0; i != tripcount; ++i)
     x_offs -= 4;
   return x_offs;

And then have exit value substitution turn it into:

   int tripcount = x_offs/4;
   x_offs1 = x_offs;
   while (i = 0; i != tripcount; ++i)
     x_offs1 -= 4;
   return x_offs-tripcount*4;

and then dead loop elim:

   int tripcount = x_offs/4;
   return x_offs-tripcount*4;

and then instcombine:

   return x_offs%4

-Chris



More information about the llvm-commits mailing list