[llvm-bugs] [Bug 28829] New: Missed optimization when mixing volatile with normal access
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 3 10:39:06 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28829
Bug ID: 28829
Summary: Missed optimization when mixing volatile with normal
access
Product: new-bugs
Version: 3.8
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: ahmad at a3f.at
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Godbolt link: https://godbolt.org/g/9brNCj
int x;
static int y;
int f() { x = 1; *(volatile int *)(&x) = x; x = 2; return x;}
int g() { y = 1; *(volatile int *)(&y) = y; y = 2; return y;}
int h() { int z = 1; *(volatile int *)(&z) = z; z = 2; return z;}
with clang 3.8 -O2 on AMD64 compiles to:
f: # @f
movl $1, x(%rip)
movl $1, x(%rip)
movl $2, x(%rip)
movl $2, %eax
retq
g: # @g
movl $1, y(%rip)
movl $1, y(%rip)
movl $2, y(%rip)
movl $2, %eax
retq
h: # @h
movl $1, -4(%rsp)
movl $1, -4(%rsp)
movl $2, %eax
retq
Is this intended behavior? My opinion is that the first $1 written isn't
necessary and that the $2 written to y should have been optimized out as well.
--
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/20160803/e001dfbc/attachment-0001.html>
More information about the llvm-bugs
mailing list