<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Aggressive optimization when computing GEP result."
href="https://bugs.llvm.org/show_bug.cgi?id=38107">38107</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Aggressive optimization when computing GEP result.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>zahira.ammarguellat@intel.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Let's look at this test case:
#include <stdio.h>
char * __strrchr_c_a (const char *__s, int __c) {
register unsigned long int __d0, __d1;
register char *__res;
__c = __c << 8;
__asm__
("cmpb %h2,%b2\n\t"
"cmove %1,%0\n\t"
: "=d" (__res), "=&S" (__d0), "=&a" (__d1)
: "0" (1), "1" (__s), "2" (__c));
return __res - 1;
}
int main() {
char * res = __strrchr_c_a("Hello, world!", 'S');
(res) ? printf("failed\n") : printf("passed\n");
}
bash-4.2$ gcc -O0 t1.c
bash-4.2$ ./a.out
passed
bash-4.2$ gcc -O2 t1.c
bash-4.2$ ./a.out
passed
bash-4.2$
Clang over optimizes.
bash-4.2$ clang -O0 t1.c
bash-4.2$ ./a.out
passed
bash-4.2$ clang -O2 t1.c
bash-4.2$ ./a.out
failed
bash-4.2$
ValueTracking is too aggressive optimizing away the argument to the tail call.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>