http://llvm.org/bugs/show_bug.cgi?id=18374

            Bug ID: 18374
           Summary: Loop reroller fails to reroll loop with variable upper
                    bound on 64-bit targets
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: opt
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Created attachment 11813
  --> http://llvm.org/bugs/attachment.cgi?id=11813&action=edit
test.c

Given this loop:

$ cat test.c
void foo(int *A, int *B, int n) {
  for (int i = 0; i < n; i+=4) {
    A[i+0] = B[i+0] * 4;
    A[i+1] = B[i+1] * 4;
    A[i+2] = B[i+2] * 4;
    A[i+3] = B[i+3] * 4;
  }
}

The loop reroller fails to reroll the loop on the 64-bit targets I tested
(x86_64 and AArch64).

  $ clang -target x86_64-none-linux test.c -S -o- -O1 -emit-llvm -o test.ll
  $ opt -loop-reroll -S -debug-only=loop-reroll -stats

It works correctly on 32-bit targets (tested i386 and armv7).

Looking at the bitcode, I suspect the problem is that the induction variable is
extended to 64-bits, but the loop bound remains 32-bits. The induction variable
is truncated inside the loop body to 32-bits. I think this makes SCEV unable to
compute the number of times the backedge is taken.

If I change the "int n" to a "long n" the loop is successfully rerolled.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to