<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 - [Dead Store Elimination, Alias Analysis] Incorrect optimization"
href="https://bugs.llvm.org/show_bug.cgi?id=35923">35923</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Dead Store Elimination, Alias Analysis] Incorrect optimization
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>paulsson@linux.vnet.ibm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19664" name="attach_19664" title="reduced testcase">attachment 19664</a> <a href="attachment.cgi?id=19664&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase
This function:
struct S0 {
char f0;
char f1
} d, f[9][8];
struct S0 *e = &d;
fn1() {
struct S0 *g = &d;
struct S0 h = {0, 0};
*g = h;
char *i = &d.f1;
*e = f[8][7];
*i = 1;
}
seems to get optimized incorrectly by DSE. The 'd' struct first gets value
{0,0} (via *g) and then again gets {0,0} via *e. After this, the f1 field gets
value 1:
define signext i32 @fn1() #0 {
entry:
store i16 0, i16* bitcast (%struct.S0* @d to i16*), align 2
%0 = load i16*, i16** bitcast (%struct.S0** @e to i16**), align 8
%1 = load i16, i16* bitcast (i8* getelementptr inbounds
([9 x [8 x %struct.S0]], [9 x [8 x %struct.S0]]* @f, i64 0,
i64 8, i64 7, i32 0) to i16*), align 2
store i16 %1, i16* %0, align 1
store i8 1, i8* getelementptr inbounds (%struct.S0, %struct.S0* @d, i64 0,
i32 1), align 1
ret i32 undef
}
DSE: Partial overwrite: Earlier [0, 2) Later [1, 2)
DSE: Partial overwrite an earlier load [0, 2) by a later store [1, 2)
DSE: Merge Stores:
Earlier: store i16 0, i16* bitcast (%struct.S0* @d to i16*), align 2
Later: store i8 1, i8* getelementptr inbounds (%struct.S0, %struct.S0* @d,
i64 0, i32 1), align 1, !tbaa !6
Merged Value: 1
*** IR Dump After Dead Store Elimination ***
define signext i32 @fn1() #0 {
entry:
store i16 1, i16* bitcast (%struct.S0* @d to i16*), align 2
%0 = load i16*, i16** bitcast (%struct.S0** @e to i16**), align 8
%1 = load i16, i16* bitcast (i8* getelementptr inbounds
([9 x [8 x %struct.S0]], [9 x [8 x %struct.S0]]* @f, i64 0,
i64 8, i64 7, i32 0) to i16*), align 2
store i16 %1, i16* %0, align 1
ret i32 undef
}
It seems that DSE has combined the original store of i8 1 into the first store,
now storing an i16 1, which looks right since SystemZ is big endian. However,
the store to %0 was overwriting the same address, and therefore this is
incorrect.
Note that with -disable-basicaa this does not happen.
bin/opt tc_deadstore.ll -instcombine -dse -S -mtriple=s390x-linux-gnu -mcpu=z13</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>