https://bugs.llvm.org/show_bug.cgi?id=47895
Bug ID: 47895
Summary: Unnecessary load not eliminated
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Extracted from PR47887
Testcase:
void foo(int *p,int *q,int x) {
*p=x;
*q=x;
if(*p!=x) /* false */
__builtin_abort();
}
Clang -O3:
foo(int*, int*, int): # @foo(int*, int*, int)
push rax
mov dword ptr [rdi], edx
mov dword ptr [rsi], edx
cmp dword ptr [rdi], edx
jne .LBB0_2
pop rax
ret
.LBB0_2:
call abort
GCC can remove unnecessary load.
foo(int*, int*, int):
mov DWORD PTR [rdi], edx
mov DWORD PTR [rsi], edx
ret
Analysis of the problem by Florian Hahn (thx!):
"In the case above neither of the stores is dead. The load is unnecessary, but
only because we store the same value to both p and q. `store i32 x, i32* q` may
alias `load p`, but it stores the same value as the store to p.
We should be able to handle this with MemorySSA, possibly as an extension of
DSE, but it won't fit directly in the main elimination loop and will need some
extra code."
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs