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

            Bug ID: 48279
           Summary: wrong code with "-sroa -loop-unroll -dse"
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: suochen...@163.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

*******************************************************************************
OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
*******************************************************************************
Program:
int printf(const char *, ...);
short a=0;
short *b = &a;
int main() {
  int c=0;
  int d[1];
  c = 0;
  for (; c < 1; c++)
    d[c] = 10;
  *b = d[0];
  printf("%d\n", a);
}
*******************************************************************************
clang version:
$ clang -v
clang version 12.0.0 (/home/suocy/src/llvm-dev/llvm-project/llvm/tools/clang
4455f3ce72ba2bb0276200f6f29629afca8812d4)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/suocy/bin/llvm-dev/bin
Found candidate GCC installation:
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation:
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
*******************************************************************************
Command Lines:
$ clang -c -emit-llvm -O3 -mllvm -disable-llvm-optzns a.c -o a.bc
$ opt -sroa -loop-unroll -dse  a.bc -o a.opt.bc
$ clang a.opt.bc -o af.o
$ ./af.o
0
$ opt a.bc -o a.opt.bc
$ clang a.opt.bc -o a.o
$ ./a.o
10

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

Reply via email to