llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Flang] frontend `-funroll-loops` testcase does not capture target behaviour

Open mustartt opened this issue 1 year ago • 8 comments

2 test cases that are currently failing on ppc64-flang-aix and ppc64le-flang-rhel-clang

FAIL: Flang::unroll-loops.fir
FAIL: Flang::unroll-loops.f90
******************** TEST 'Flang :: Integration/unroll-loops.f90' FAILED ********************
Exit Code: 1
Command Output (stderr):
--
RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/flang -fc1 -emit-llvm -O1 -funroll-loops -mllvm -force-vector-width=2 -o- /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90 | /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90 --check-prefixes=CHECK,UNROLL
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90 --check-prefixes=CHECK,UNROLL
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/flang -fc1 -emit-llvm -O1 -funroll-loops -mllvm -force-vector-width=2 -o- /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90:22:17: error: UNROLL-NEXT: is not on the line after the previous match
 ! UNROLL-NEXT: %[[GEP0:.*]] = getelementptr i64, ptr %[[ARG0]], i64 %[[IND]]
                ^
<stdin>:21:2: note: 'next' match was here
 %1 = getelementptr i64, ptr %0, i64 %index
 ^
<stdin>:14:51: note: previous match ended here
 %step.add = add <2 x i64> %vec.ind, splat (i64 2)
                                                  ^
<stdin>:15:1: note: non-matching line after previous match is here
 %step.add.2 = add <2 x i64> %vec.ind, splat (i64 4)
^
Input file: <stdin>
Check file: /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90
-dump-input=help explains the following input dump.
Input was:
<<<<<<
         .
         .
         .
        16:  %step.add.3 = add <2 x i64> %vec.ind, splat (i64 6) 
        17:  %step.add.4 = add <2 x i64> %vec.ind, splat (i64 8) 
        18:  %step.add.5 = add <2 x i64> %vec.ind, splat (i64 10) 
        19:  %step.add.6 = add <2 x i64> %vec.ind, splat (i64 12) 
        20:  %step.add.7 = add <2 x i64> %vec.ind, splat (i64 14) 
        21:  %1 = getelementptr i64, ptr %0, i64 %index 
next:22      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  error: match on wrong line
        22:  %2 = getelementptr i8, ptr %1, i64 16 
        23:  %3 = getelementptr i8, ptr %1, i64 32 
        24:  %4 = getelementptr i8, ptr %1, i64 48 
        25:  %5 = getelementptr i8, ptr %1, i64 64 
        26:  %6 = getelementptr i8, ptr %1, i64 80 
         .
         .
         .
>>>>>>
--
********************

mustartt avatar Jan 20 '25 20:01 mustartt

@llvm/issue-subscribers-bug

Author: Henry Jiang (mustartt)

2 test cases that are currently failing on `ppc64-flang-aix` and `ppc64le-flang-rhel-clang`
FAIL: Flang::unroll-loops.fir
FAIL: Flang::unroll-loops.f90
******************** TEST 'Flang :: Integration/unroll-loops.f90' FAILED ********************
Exit Code: 1
Command Output (stderr):
--
RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/flang -fc1 -emit-llvm -O1 -funroll-loops -mllvm -force-vector-width=2 -o- /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90 | /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90 --check-prefixes=CHECK,UNROLL
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90 --check-prefixes=CHECK,UNROLL
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/flang -fc1 -emit-llvm -O1 -funroll-loops -mllvm -force-vector-width=2 -o- /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90:22:17: error: UNROLL-NEXT: is not on the line after the previous match
 ! UNROLL-NEXT: %[[GEP0:.*]] = getelementptr i64, ptr %[[ARG0]], i64 %[[IND]]
                ^
&lt;stdin&gt;:21:2: note: 'next' match was here
 %1 = getelementptr i64, ptr %0, i64 %index
 ^
&lt;stdin&gt;:14:51: note: previous match ended here
 %step.add = add &lt;2 x i64&gt; %vec.ind, splat (i64 2)
                                                  ^
&lt;stdin&gt;:15:1: note: non-matching line after previous match is here
 %step.add.2 = add &lt;2 x i64&gt; %vec.ind, splat (i64 4)
^
Input file: &lt;stdin&gt;
Check file: /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90
-dump-input=help explains the following input dump.
Input was:
&lt;&lt;&lt;&lt;&lt;&lt;
         .
         .
         .
        16:  %step.add.3 = add &lt;2 x i64&gt; %vec.ind, splat (i64 6) 
        17:  %step.add.4 = add &lt;2 x i64&gt; %vec.ind, splat (i64 8) 
        18:  %step.add.5 = add &lt;2 x i64&gt; %vec.ind, splat (i64 10) 
        19:  %step.add.6 = add &lt;2 x i64&gt; %vec.ind, splat (i64 12) 
        20:  %step.add.7 = add &lt;2 x i64&gt; %vec.ind, splat (i64 14) 
        21:  %1 = getelementptr i64, ptr %0, i64 %index 
next:22      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  error: match on wrong line
        22:  %2 = getelementptr i8, ptr %1, i64 16 
        23:  %3 = getelementptr i8, ptr %1, i64 32 
        24:  %4 = getelementptr i8, ptr %1, i64 48 
        25:  %5 = getelementptr i8, ptr %1, i64 64 
        26:  %6 = getelementptr i8, ptr %1, i64 80 
         .
         .
         .
&gt;&gt;&gt;&gt;&gt;&gt;
--
********************

llvmbot avatar Jan 20 '25 21:01 llvmbot

At a glance at the error, it does look like the unrolling is happening here, it's just being much more aggressive on PPC than on the other targets I tested for some reason.

DavidTruby avatar Jan 22 '25 12:01 DavidTruby

At a glance at the error, it does look like the unrolling is happening here, it's just being much more aggressive on PPC than on the other targets I tested for some reason.

I took a look at the test case again, it seems that we are doing the unrolling, but we are unrolling 8 times with vector width 2, and there are some interleave differences. But overall unrolling is working correctly, and its an testcase issue.

mustartt avatar Jan 22 '25 17:01 mustartt

I'm seeing the same failures on Solaris/sparcv9:

  Flang :: HLFIR/unroll-loops.fir
  Flang :: Integration/unroll-loops.f90

Should I file a separate Issue for that or report it here?

rorth avatar Jan 23 '25 10:01 rorth

I'm seeing the same failures on Solaris/sparcv9:

  Flang :: HLFIR/unroll-loops.fir
  Flang :: Integration/unroll-loops.f90

Should I file a separate Issue for that or report it here?

I changed the title for the issue. I will put up a patch for the expected PPC behavior in the testcase.

mustartt avatar Jan 23 '25 15:01 mustartt

@mustartt,

Has the issue in PPC been fixed? If so, can this be closed?

tarunprabhu avatar Dec 24 '25 20:12 tarunprabhu

@rorth,

Are these still failing on Solaris/sparcv9?

tarunprabhu avatar Dec 24 '25 20:12 tarunprabhu

@llvm/issue-subscribers-flang-ir

Author: Henry Jiang (mustartt)

2 test cases that are currently failing on `ppc64-flang-aix` and `ppc64le-flang-rhel-clang`
FAIL: Flang::unroll-loops.fir
FAIL: Flang::unroll-loops.f90
******************** TEST 'Flang :: Integration/unroll-loops.f90' FAILED ********************
Exit Code: 1
Command Output (stderr):
--
RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/flang -fc1 -emit-llvm -O1 -funroll-loops -mllvm -force-vector-width=2 -o- /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90 | /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90 --check-prefixes=CHECK,UNROLL
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90 --check-prefixes=CHECK,UNROLL
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/flang -fc1 -emit-llvm -O1 -funroll-loops -mllvm -force-vector-width=2 -o- /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90:22:17: error: UNROLL-NEXT: is not on the line after the previous match
 ! UNROLL-NEXT: %[[GEP0:.*]] = getelementptr i64, ptr %[[ARG0]], i64 %[[IND]]
                ^
&lt;stdin&gt;:21:2: note: 'next' match was here
 %1 = getelementptr i64, ptr %0, i64 %index
 ^
&lt;stdin&gt;:14:51: note: previous match ended here
 %step.add = add &lt;2 x i64&gt; %vec.ind, splat (i64 2)
                                                  ^
&lt;stdin&gt;:15:1: note: non-matching line after previous match is here
 %step.add.2 = add &lt;2 x i64&gt; %vec.ind, splat (i64 4)
^
Input file: &lt;stdin&gt;
Check file: /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Integration/unroll-loops.f90
-dump-input=help explains the following input dump.
Input was:
&lt;&lt;&lt;&lt;&lt;&lt;
         .
         .
         .
        16:  %step.add.3 = add &lt;2 x i64&gt; %vec.ind, splat (i64 6) 
        17:  %step.add.4 = add &lt;2 x i64&gt; %vec.ind, splat (i64 8) 
        18:  %step.add.5 = add &lt;2 x i64&gt; %vec.ind, splat (i64 10) 
        19:  %step.add.6 = add &lt;2 x i64&gt; %vec.ind, splat (i64 12) 
        20:  %step.add.7 = add &lt;2 x i64&gt; %vec.ind, splat (i64 14) 
        21:  %1 = getelementptr i64, ptr %0, i64 %index 
next:22      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  error: match on wrong line
        22:  %2 = getelementptr i8, ptr %1, i64 16 
        23:  %3 = getelementptr i8, ptr %1, i64 32 
        24:  %4 = getelementptr i8, ptr %1, i64 48 
        25:  %5 = getelementptr i8, ptr %1, i64 64 
        26:  %6 = getelementptr i8, ptr %1, i64 80 
         .
         .
         .
&gt;&gt;&gt;&gt;&gt;&gt;
--
********************

llvmbot avatar Dec 25 '25 01:12 llvmbot