<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 - [Polly] [ScopDetect/Info] Incorrect Invariant Load Hoisting"
href="https://bugs.llvm.org/show_bug.cgi?id=32778">32778</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Polly] [ScopDetect/Info] Incorrect Invariant Load Hoisting
</td>
</tr>
<tr>
<th>Product</th>
<td>Polly
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>polly-dev@googlegroups.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>huihuiz@codeaurora.org
</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=18346" name="attach_18346" title="generetated output file">attachment 18346</a> <a href="attachment.cgi?id=18346&action=edit" title="generetated output file">[details]</a></span>
generetated output file
For Polly test case "test/Isl/CodeGen/reduction_2.ll"
The patch "[ScopDetect/Info] Allow unconditional hoisting of loads from
dereferenceable ptrs"
git-svn-id: <a href="https://llvm.org/svn/llvm-project/polly/trunk@297375">https://llvm.org/svn/llvm-project/polly/trunk@297375</a>
Actually generate incorrect output code.
Run command: opt -polly-process-unprofitable -polly-remarks-minimal -basicaa
-polly-ast -analyze -polly-invariant-load-hoisting=true <
./test/Isl/CodeGen/reduction_2.ll -polly-scops
Shows that RED[0] is invariant access
Function: main
Region: %for.cond---%if.end
Max Loop Depth: 1
Invariant Accesses: {
ReadAccess := [Reduction Type: NONE] [Scalar: 0]
[tmp34] -> { Stmt_for_end[] -> MemRef_RED[0] };
Execution Context: [tmp34] -> { : }
}
...
Run command: opt -polly-process-unprofitable -polly-remarks-minimal -basicaa
-polly-invariant-load-hoisting=true < ./test/Isl/CodeGen/reduction_2.ll
-polly-codegen -S -o test.ll
to get the generated ll output.
For BB polly.stmt.for.body, "%p_add30 = add nsw i32 %polly.access.RED.load,
%tmp26_p_scalar_"
is using the old value %polly.access.RED.load, which only get preloaded once,
and never reloaded.
While the "store i32 %p_add30, i32* %polly.access.cast.RED, !alias.scope !0,
!noalias !2",
stores to %polly.access.cast.RED
polly.stmt.for.body: ; preds = %polly.loop_header
%scevgep1 = getelementptr i32, i32* %scevgep, i64 %polly.indvar
%tmp10_p_scalar_ = load i32, i32* %scevgep1, !alias.scope !3, !noalias !5
%scevgep2 = getelementptr [1021 x i32], [1021 x i32]* %A, i64 0, i64
%polly.indvar
%tmp16_p_scalar_ = load i32, i32* %scevgep2, !alias.scope !3, !noalias !5
%p_add = add nsw i32 %tmp10_p_scalar_, %tmp16_p_scalar_
%scevgep4 = getelementptr i32, i32* %scevgep3, i64 %polly.indvar
store i32 %p_add, i32* %scevgep4, !alias.scope !3, !noalias !5
%tmp26_p_scalar_ = load i32, i32* %scevgep2, !alias.scope !3, !noalias !5
%p_add30 = add nsw i32 %polly.access.RED.load, %tmp26_p_scalar_
store i32 %p_add30, i32* %polly.access.cast.RED, !alias.scope !0, !noalias !2
%polly.indvar_next = add nsw i64 %polly.indvar, 1
%polly.loop_cond = icmp sle i64 %polly.indvar, 1017
br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
polly.preload.begin: ; preds =
%polly.split_new_and_old
%0 = bitcast [1 x i32]* undef to i32*
%polly.access.RED = getelementptr i32, i32* %polly.access.cast.RED, i64 0
%polly.access.RED.load = load i32, i32* %polly.access.RED, !alias.scope !0,
!noalias !2
store i32 %polly.access.RED.load, i32* %tmp34.preload.s2a
br i1 true, label %polly.start, label %for.cond.pre_entry_bb
I attached the output test.ll for easier verification.
The correct generated ll should look something like:
polly.stmt.for.body:
...
%tmp1 = load i32, i32* %RED
%p_add = add nsw i32 %tmp2, %tmp1
store i32 %p_add, i32* %RED
...</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>