[LLVMdev] Is this a bug with loop unrolling and TargetTransformInfo ?

Tom Stellard tom at stellard.net
Wed Feb 4 11:45:26 PST 2015


Hi,

I ran into this issue recently and wanted to know if it was a bug or expected behavior.

In the R600 backend's TargetTransformInfo implementation, we were setting
UnrollingPreferences::Count = UINT_MAX.  This was a mistake as we should have been
setting UnrollingPreferences::MaxCount instead.  However, as a result of setting
Count to UINT_MAX, this loop would be unrolled 15 times:

if (b + 4 > a) {
  for (int i = 0; i < 4; i++, b++) {
    if (b + 1 <= a)
      *(dst + c + b) = 0;
     else
       break;
  }
}

Is this the expected behavior?  Is the loop unroll pass supposed to use the
value of UnrollingPreferecnes::Count even if it is clearly wrong?

I have an LLVM IR test case for this issue attached to this patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150202/257276.html

-Tom



More information about the llvm-dev mailing list