[llvm-bugs] [Bug 33104] New: delinearization fails: casting issue?

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 19 10:41:52 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33104

            Bug ID: 33104
           Summary: delinearization fails: casting issue?
           Product: Polly
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Other
          Assignee: polly-dev at googlegroups.com
          Reporter: cychan at lbl.gov
                CC: llvm-bugs at lists.llvm.org

The delinearization analysis fails on the sample codes (Listings 4 and 5)
presented in the Grosser IMPACT2015 paper due to possible casting issues.

The following code (Listing 4) was tested with "clang test.c  -O3 -mllvm -polly
 -c -mllvm -debug-only=polly-scops -mllvm -polly-process-unprofitable":

#include <stddef.h>
struct TwoDArray {
size_t size0; size_t size1; float *Base;
};
#define ACCESS_2D(A, x, y) \
*(A->Base + (x) * A->size1 + (y))
#define SIZE0_2D(A) A->size0
#define SIZE1_2D(A) A->size1
void gemm(struct TwoDArray *A, struct TwoDArray *B,
          struct TwoDArray *C) {
  for (int i = 0; i < SIZE0_2D(C); i++)
    for (int j = 0; j < SIZE1_2D(C); j++)
      for (int k = 0; k < SIZE1_2D(A); ++k)
        ACCESS_2D(C, i, j) += ACCESS_2D(A, i, k) * ACCESS_2D(B, k, j);
}

There was no output produced.  I tried running "opt -debug -basicaa
-delinearize -polly-process-unprofitable -polly-scops -analyze temp.s.ll" on
the canonicalized IR, but i was unable to decipher the output.

The following code (Listing 5) was tested with "clang test.c  -O3 -mllvm -polly
 -c -mllvm -debug-only=polly-scops -mllvm -polly-process-unprofitable":

void set_subarray(unsigned n1, unsigned n2,
    unsigned o0, unsigned o1, unsigned o2,
    unsigned s0, unsigned s1, unsigned s2,
    float A[]) {
  for (unsigned i = 0; i < s0; i++)
    for (unsigned j = 0; j < s1; j++)
      for (unsigned k = 0; k < s2; k++)
        A[(n2 * (n1 * o0 + o1) + o2) + n1 * n2 * i + n2 * j + k] = 1;
}

Which produces the following output:

    Function: set_subarray
    Region: %for.cond4.preheader---%for.inc15
    Max Loop Depth:  1
    Invariant Accesses: {
    }
    Context:
    [s2, p_1, p_2, p_3, o2] -> {  : -2147483648 <= s2 <= 2147483647 and
-2147483648 <= p_1 <= 2147483647 and -2147483648 <= p_2 <= 2147483647 and
-2147483648 <= p_3 <= 2147483647 and -2147483648 <= o2 <= 2147483647 }
    Assumed Context:
    [s2, p_1, p_2, p_3, o2] -> {  :  }
    Invalid Context:
    [s2, p_1, p_2, p_3, o2] -> {  : s2 > 0 and (o2 <= -2147483649 - p_2 - p_3
or o2 <= -2147483649 - p_3 or o2 >= 2147483649 - s2 - p_1 - p_2 - p_3 or o2 >=
2147483648 - p_3 or o2 >= 2147483648 - p_2 - p_3 or o2 < -p_1 - p_2 - p_3) }
    p0: %s2
    p1: {0,+,%n2}<%for.cond4.preheader>
    p2: {0,+,(%n1 * %n2)}<%for.cond1.preheader>
    p3: (((%n1 * %o0) + %o1) * %n2)
    p4: %o2
    Arrays {
        i32 MemRef_j_08; // Element size 4
        float MemRef_A[*]; // Element size 4
    }
    Arrays (Bounds as pw_affs) {
        i32 MemRef_j_08; // Element size 4
        float MemRef_A[*]; // Element size 4
    }
    Alias Groups (0):
        n/a
    Statements {
        Stmt_for_cond4_preheader
            Domain :=
                [s2, p_1, p_2, p_3, o2] -> { Stmt_for_cond4_preheader[] };
            Schedule :=
                [s2, p_1, p_2, p_3, o2] -> { Stmt_for_cond4_preheader[] -> [0,
0] };
            MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
                [s2, p_1, p_2, p_3, o2] -> { Stmt_for_cond4_preheader[] ->
MemRef_j_08[] };
        Stmt_for_body6
            Domain :=
                [s2, p_1, p_2, p_3, o2] -> { Stmt_for_body6[i0] : 0 <= i0 < s2
};
            Schedule :=
                [s2, p_1, p_2, p_3, o2] -> { Stmt_for_body6[i0] -> [1, i0] };
            MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
                [s2, p_1, p_2, p_3, o2] -> { Stmt_for_body6[i0] -> MemRef_A[p_1
+ p_2 + p_3 + o2 + i0] };
    }

Changing unsigned to long appears to correct the issue:

    Function: set_subarray
    Region: %entry.split---%for.cond.cleanup
    Max Loop Depth:  3
    Invariant Accesses: {
    }
    Context:
    [s0, s1, s2, n1, n2, o0, o1, o2] -> {  : -9223372036854775808 <= s0 <=
9223372036854775807 and -9223372036854775808 <= s1 <= 9223372036854775807 and
-9223372036854775808 <= s2 <= 9223372036854775807 and -9223372036854775808 <=
n1 <= 9223372036854775807 and -9223372036854775808 <= n2 <= 9223372036854775807
and -9223372036854775808 <= o0 <= 9223372036854775807 and -9223372036854775808
<= o1 <= 9223372036854775807 and -9223372036854775808 <= o2 <=
9223372036854775807 }
    Assumed Context:
    [s0, s1, s2, n1, n2, o0, o1, o2] -> {  : -n1 <= o1 <= 1 - s1 + n1 and ((o1
> -n1 and -n2 <= o2 <= -s2) or (o1 <= -s1 + n1 and 0 <= o2 <= -s2 + n2) or (-n1
< o1 <= -s1 + n1 and o2 >= -n2 and -s2 < o2 <= -s2 + n2 and o2 < 0)) }
    Invalid Context:
    [s0, s1, s2, n1, n2, o0, o1, o2] -> {  : (s1 > 0 and s2 > 0 and o0 >=
9223372036854775809 - s0) or (s0 > 0 and s2 > 0 and o1 >= 9223372036854775809 -
s1) or (s0 > 0 and s1 > 0 and o2 >= 9223372036854775809 - s2) }
    p0: %s0
    p1: %s1
    p2: %s2
    p3: %n1
    p4: %n2
    p5: %o0
    p6: %o1
    p7: %o2
    Arrays {
        float MemRef_A[*][%n1][%n2]; // Element size 4
    }
    Arrays (Bounds as pw_affs) {
        float MemRef_A[*][ [n1] -> { [] -> [(n1)] } ][ [n2] -> { [] -> [(n2)] }
]; // Element size 4
    }
    Alias Groups (0):
        n/a
    Statements {
        Stmt_for_body8
            Domain :=
                [s0, s1, s2, n1, n2, o0, o1, o2] -> { Stmt_for_body8[i0, i1,
i2] : 0 <= i0 < s0 and 0 <= i1 < s1 and 0 <= i2 < s2 };
            Schedule :=
                [s0, s1, s2, n1, n2, o0, o1, o2] -> { Stmt_for_body8[i0, i1,
i2] -> [i0, i1, i2] };
            MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
                [s0, s1, s2, n1, n2, o0, o1, o2] -> { Stmt_for_body8[i0, i1,
i2] -> MemRef_A[-1 + o0 + i0, -1 + n1 + o1 + i1, n2 + o2 + i2] : i1 <= -o1 and
i2 < -o2; Stmt_for_body8[i0, i1, i2] -> MemRef_A[o0 + i0, -1 + o1 + i1, n2 + o2
+ i2] : i1 > -o1 and i2 < -o2; Stmt_for_body8[i0, i1, i2] -> MemRef_A[-1 + o0 +
i0, n1 + o1 + i1, o2 + i2] : i1 < -o1 and i2 >= -o2; Stmt_for_body8[i0, i1, i2]
-> MemRef_A[o0 + i0, o1 + i1, o2 + i2] : i1 >= -o1 and i2 >= -o2 };
    }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170519/504c6cb7/attachment-0001.html>


More information about the llvm-bugs mailing list