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

            Bug ID: 33238
           Summary: Wrong isl ast schedule generated
           Product: Polly
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Other
          Assignee: polly-...@googlegroups.com
          Reporter: huih...@codeaurora.org
                CC: llvm-bugs@lists.llvm.org

Created attachment 18547
  --> https://bugs.llvm.org/attachment.cgi?id=18547&action=edit
test input

Attaching the test.ll as test input

Run command "opt -polly-codegen -S test.ll -debug"

Polly produce the isl ast schedule of:

    {
      if (p_0 >= 3) {
        for (int c0 = 0; c0 < (p_0 + 2) / 4; c0 += 1) {
          Stmt0(c0);
          if (p_0 >= 4 * c0 + 3) {
            Stmt2(c0);
            if (p_0 >= 4 * c0 + 4) {
              Stmt4(c0);
              if (p_0 >= 4 * c0 + 5)
                Stmt6(c0);
            }
          }
        }
        if ((p_0 - 1) % 4 == 0) {
          Stmt7();
        } else if (p_0 % 4 == 0) {
          Stmt5();
        } else if ((p_0 + 1) % 4 == 0) {
          Stmt3();
        }
      } else {
        Stmt0(0);
      }
      Stmt1();
    }

else
    {  /* original code */ }

However, the correct schedule should be:

    {
      if (p_0 >= 3) {
        for (int c0 = 0; c0 < (p_0 + 2) / 4; c0 += 1) {
          Stmt0(c0);
          if (p_0 >= 4 * c0 + 3) {
            Stmt2(c0);
            if (p_0 >= 4 * c0 + 4) {
              Stmt4(c0);
              if (p_0 >= 4 * c0 + 5)
                Stmt6(c0);
            }
          }
        }
        if ((p_0 - 1) % 4 == 0) {
          Stmt7();
        } else if (p_0 % 4 == 0) {
          Stmt5();
        } else if ((p_0 + 1) % 4 == 0) {
          Stmt3();
        }
      } else {
        Stmt0(0);
      }
      if((n <= 2) || ((n - 2)%4 == 0))
        Stmt1();
    }

else
    {  /* original code */ }

Notice that for Statement Stmt1(), Polly produce universe domain, Stmt1 is
being executed unconditionally. However, if going through the basic blocks of
the input test.ll file, Stmt1 will only be executed under condition "((n <= 2)
|| ((n - 2)%4 == 0))"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to