[LLVMbugs] [Bug 17281] New: relaxed atomic operations lead to vastly inefficient code
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Sep 18 22:21:47 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17281
Bug ID: 17281
Summary: relaxed atomic operations lead to vastly inefficient
code
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: dvyukov at google.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
$ clang -v
clang version 3.4 (trunk 190948)
Target: x86_64-unknown-linux-gnu
$ cat 1.c
int a, b, c, d, e, f, g, h, a1, b1, c1, d1, e1, f1, g1, h1, a2, b2, c2, d2, x;
void foobar() {
int a_ = a;
int b_ = b;
int c_ = c;
int d_ = d;
int e_ = e;
int f_ = f;
int g_ = g;
int h_ = h;
int a1_ = a1;
int b1_ = b1;
int c1_ = c1;
int d1_ = d1;
int e1_ = e1;
int f1_ = f1;
int g1_ = g1;
int h1_ = h1;
int a2_ = a2;
int b2_ = b2;
int c2_ = c2;
int d2_ = d2;
#ifdef BUILTIN
__atomic_store_n(&x, __atomic_load_n(&x, __ATOMIC_RELAXED) + 1,
__ATOMIC_RELAXED);
#else
x = x + 1;
#endif
a = a_ + 1;
b = b_ + 1;
c = c_ + 1;
d = d_ + 1;
e = e_ + 1;
f = f_ + 1;
g = g_ + 1;
h = h_ + 1;
a1 = a1_;
b1 = b1_;
c1 = c1_;
d1 = d1_;
e1 = e1_;
f1 = f1_;
g1 = g1_;
h1 = h1_;
a2 = a2_;
b2 = b2_;
c2 = c2_;
d2 = d2_;
}
EOF
$ clang -c -O3 1.c && objdump -d 1.o
0000000000000000 <foobar>:
0: 44 8b 05 00 00 00 00 mov 0x0(%rip),%r8d # 7 <foobar+0x7>
7: 44 8b 0d 00 00 00 00 mov 0x0(%rip),%r9d # e <foobar+0xe>
e: 44 8b 15 00 00 00 00 mov 0x0(%rip),%r10d # 15
<foobar+0x15>
15: 8b 35 00 00 00 00 mov 0x0(%rip),%esi # 1b
<foobar+0x1b>
1b: 8b 3d 00 00 00 00 mov 0x0(%rip),%edi # 21
<foobar+0x21>
21: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 27
<foobar+0x27>
27: 8b 0d 00 00 00 00 mov 0x0(%rip),%ecx # 2d
<foobar+0x2d>
2d: 8b 15 00 00 00 00 mov 0x0(%rip),%edx # 33
<foobar+0x33>
33: ff 05 00 00 00 00 incl 0x0(%rip) # 39 <foobar+0x39>
39: ff c2 inc %edx
3b: 89 15 00 00 00 00 mov %edx,0x0(%rip) # 41
<foobar+0x41>
41: ff c1 inc %ecx
43: 89 0d 00 00 00 00 mov %ecx,0x0(%rip) # 49
<foobar+0x49>
49: ff c0 inc %eax
4b: 89 05 00 00 00 00 mov %eax,0x0(%rip) # 51
<foobar+0x51>
51: ff c7 inc %edi
53: 89 3d 00 00 00 00 mov %edi,0x0(%rip) # 59
<foobar+0x59>
59: ff c6 inc %esi
5b: 89 35 00 00 00 00 mov %esi,0x0(%rip) # 61
<foobar+0x61>
61: 41 ff c2 inc %r10d
64: 44 89 15 00 00 00 00 mov %r10d,0x0(%rip) # 6b
<foobar+0x6b>
6b: 41 ff c1 inc %r9d
6e: 41 ff c0 inc %r8d
71: 44 89 05 00 00 00 00 mov %r8d,0x0(%rip) # 78
<foobar+0x78>
78: 44 89 0d 00 00 00 00 mov %r9d,0x0(%rip) # 7f
<foobar+0x7f>
7f: c3 retq
$ clang -c -O3 1.c -DBUILTIN && objdump -d 1.o
0000000000000000 <foobar>:
0: 55 push %rbp
1: 41 57 push %r15
3: 41 56 push %r14
5: 41 55 push %r13
7: 41 54 push %r12
9: 53 push %rbx
a: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 10
<foobar+0x10>
10: 89 44 24 fc mov %eax,-0x4(%rsp)
14: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 1a
<foobar+0x1a>
1a: 89 44 24 f8 mov %eax,-0x8(%rsp)
1e: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 24
<foobar+0x24>
24: 89 44 24 f4 mov %eax,-0xc(%rsp)
28: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 2e
<foobar+0x2e>
2e: 89 44 24 f0 mov %eax,-0x10(%rsp)
32: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 38
<foobar+0x38>
38: 89 44 24 ec mov %eax,-0x14(%rsp)
3c: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 42
<foobar+0x42>
42: 89 44 24 e8 mov %eax,-0x18(%rsp)
46: 44 8b 25 00 00 00 00 mov 0x0(%rip),%r12d # 4d
<foobar+0x4d>
4d: 44 8b 2d 00 00 00 00 mov 0x0(%rip),%r13d # 54
<foobar+0x54>
54: 44 8b 35 00 00 00 00 mov 0x0(%rip),%r14d # 5b
<foobar+0x5b>
5b: 8b 1d 00 00 00 00 mov 0x0(%rip),%ebx # 61
<foobar+0x61>
61: 8b 2d 00 00 00 00 mov 0x0(%rip),%ebp # 67
<foobar+0x67>
67: 44 8b 1d 00 00 00 00 mov 0x0(%rip),%r11d # 6e
<foobar+0x6e>
6e: 44 8b 15 00 00 00 00 mov 0x0(%rip),%r10d # 75
<foobar+0x75>
75: 44 8b 0d 00 00 00 00 mov 0x0(%rip),%r9d # 7c
<foobar+0x7c>
7c: 44 8b 05 00 00 00 00 mov 0x0(%rip),%r8d # 83
<foobar+0x83>
83: 8b 3d 00 00 00 00 mov 0x0(%rip),%edi # 89
<foobar+0x89>
89: 8b 35 00 00 00 00 mov 0x0(%rip),%esi # 8f
<foobar+0x8f>
8f: 8b 15 00 00 00 00 mov 0x0(%rip),%edx # 95
<foobar+0x95>
95: 8b 0d 00 00 00 00 mov 0x0(%rip),%ecx # 9b
<foobar+0x9b>
9b: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # a1
<foobar+0xa1>
a1: 44 8b 3d 00 00 00 00 mov 0x0(%rip),%r15d # a8
<foobar+0xa8>
a8: 41 ff c7 inc %r15d
ab: 44 89 3d 00 00 00 00 mov %r15d,0x0(%rip) # b2
<foobar+0xb2>
b2: ff c0 inc %eax
b4: 89 05 00 00 00 00 mov %eax,0x0(%rip) # ba
<foobar+0xba>
ba: ff c1 inc %ecx
bc: 89 0d 00 00 00 00 mov %ecx,0x0(%rip) # c2
<foobar+0xc2>
c2: ff c2 inc %edx
c4: 89 15 00 00 00 00 mov %edx,0x0(%rip) # ca
<foobar+0xca>
ca: ff c6 inc %esi
cc: 89 35 00 00 00 00 mov %esi,0x0(%rip) # d2
<foobar+0xd2>
d2: ff c7 inc %edi
d4: 89 3d 00 00 00 00 mov %edi,0x0(%rip) # da
<foobar+0xda>
da: 41 ff c0 inc %r8d
dd: 44 89 05 00 00 00 00 mov %r8d,0x0(%rip) # e4
<foobar+0xe4>
e4: 41 ff c1 inc %r9d
e7: 44 89 0d 00 00 00 00 mov %r9d,0x0(%rip) # ee
<foobar+0xee>
ee: 41 ff c2 inc %r10d
f1: 44 89 15 00 00 00 00 mov %r10d,0x0(%rip) # f8
<foobar+0xf8>
f8: 44 89 1d 00 00 00 00 mov %r11d,0x0(%rip) # ff
<foobar+0xff>
ff: 89 2d 00 00 00 00 mov %ebp,0x0(%rip) # 105
<foobar+0x105>
105: 89 1d 00 00 00 00 mov %ebx,0x0(%rip) # 10b
<foobar+0x10b>
10b: 44 89 35 00 00 00 00 mov %r14d,0x0(%rip) # 112
<foobar+0x112>
112: 44 89 2d 00 00 00 00 mov %r13d,0x0(%rip) # 119
<foobar+0x119>
119: 44 89 25 00 00 00 00 mov %r12d,0x0(%rip) # 120
<foobar+0x120>
120: 8b 44 24 e8 mov -0x18(%rsp),%eax
124: 89 05 00 00 00 00 mov %eax,0x0(%rip) # 12a
<foobar+0x12a>
12a: 8b 44 24 ec mov -0x14(%rsp),%eax
12e: 89 05 00 00 00 00 mov %eax,0x0(%rip) # 134
<foobar+0x134>
134: 8b 44 24 f0 mov -0x10(%rsp),%eax
138: 89 05 00 00 00 00 mov %eax,0x0(%rip) # 13e
<foobar+0x13e>
13e: 8b 44 24 f4 mov -0xc(%rsp),%eax
142: 89 05 00 00 00 00 mov %eax,0x0(%rip) # 148
<foobar+0x148>
148: 8b 44 24 f8 mov -0x8(%rsp),%eax
14c: 89 05 00 00 00 00 mov %eax,0x0(%rip) # 152
<foobar+0x152>
152: 8b 44 24 fc mov -0x4(%rsp),%eax
156: 89 05 00 00 00 00 mov %eax,0x0(%rip) # 15c
<foobar+0x15c>
15c: 5b pop %rbx
15d: 41 5c pop %r12
15f: 41 5d pop %r13
161: 41 5e pop %r14
163: 41 5f pop %r15
165: 5d pop %rbp
166: c3 retq
I would expect these codes to be the same with and w/o -DBUILTIN.
--
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/20130919/5b7a3b93/attachment.html>
More information about the llvm-bugs
mailing list