[llvm-bugs] [Bug 47033] New: The loop will not be unrolled by writing the -fno-unroll-loops option before or after -O2.
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Fri Aug  7 03:36:35 PDT 2020
    
    
  
https://bugs.llvm.org/show_bug.cgi?id=47033
            Bug ID: 47033
           Summary: The loop will not be unrolled by writing the
                    -fno-unroll-loops option before or after -O2.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: fj8765ah at aa.jp.fujitsu.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk
a.c:
void foo(double * restrict a,
         double * restrict b,
         double * restrict c,
         int n) {
  for (int i=0;i<n;i++)
    c[i] = a[i] + b[i];
  return;
}
The loop will not be unrolled by writing the -fno-unroll-loops option before or
after -O2.
# For AArch64, this problem does not occur unless the -mcpu option is
specified, for example, thunderx2t99.
% clang -target x86_64-unkown-linux-gnu -O2 a.c -Rpass=unroll -S
a.c:6:3: remark: unrolled loop by a factor of 2 with run-time trip count
[-Rpass=loop-unroll]
  for (int i=0;i<n;i++)
  ^
% clang -target x86_64-unkown-linux-gnu -fno-unroll-loops -O2 a.c -Rpass=unroll
-S
% clang -target x86_64-unkown-linux-gnu -O2 -fno-unroll-loops a.c -Rpass=unroll
-S
However, the loop is not vectorized only if the -fno-vectorize option is
written after -O2.
% clang -target x86_64-unkown-linux-gnu -O2 a.c -Rpass=vector -S
a.c:6:3: remark: vectorized loop (vectorization width: 2, interleaved count: 2)
[-Rpass=loop-vectorize]
  for (int i=0;i<n;i++)
  ^
% clang -target x86_64-unkown-linux-gnu -fno-vectorize -O2 a.c -Rpass=vector -S
a.c:6:3: remark: vectorized loop (vectorization width: 2, interleaved count: 2)
[-Rpass=loop-vectorize]
  for (int i=0;i<n;i++)
  ^
% clang -target x86_64-unkown-linux-gnu -O2 -fno-vectorize a.c -Rpass=vector -S
%
I think it is because I did not check the positional relation with -O2 in
clang/lib/Driver/ToolChains/Clang.cpp.
I think -fno-unroll-loops should behave like -fno-vectorize.
How do you like it?
-- 
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/20200807/1d9d60da/attachment.html>
    
    
More information about the llvm-bugs
mailing list