[llvm-bugs] [Bug 44033] New: LICM does not move accesses out of loop; variable not promoted to register

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Nov 17 09:55:44 PST 2019


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

            Bug ID: 44033
           Summary: LICM does not move accesses out of loop; variable not
                    promoted to register
           Product: tools
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: opt
          Assignee: unassignedbugs at nondot.org
          Reporter: uday at polymagelabs.com
                CC: llvm-bugs at lists.llvm.org

For this piece of code, LICM doesn't move the memory accesses (on *s) out of
the loop when run with:

$ clang -O0 test.cpp -c -S -emit-llvm -o - | opt -O2

but it does when run as part of:

$ clang -O2 test.cpp

LICM runs in both cases, and I was expecting the register promotion for *s to
happen in either case (although the generated code may differ); but it doesn't
with opt's -O2 pipeline.


https://godbolt.org/z/nCHkaW
==============
#include <stdlib.h>
#define N 100

void foo(int Y[N], int A[N][N], int X[N]) {
  for (int i = 0; i < N; ++i) {
    int *s = (int*)malloc((sizeof(int)));
    *s = Y[i];
    for (int j = 0; j < N; ++j) {
      *s += A[i][j] * X[j];
    }
    Y[i] += *s;
    free(s);
  }    
}
================

opt -version
LLVM (http://llvm.org/):
  LLVM version 8.0.0
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: skylake

-- 
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/20191117/a5a90869/attachment-0001.html>


More information about the llvm-bugs mailing list