[llvm-bugs] [Bug 32778] New: [Polly] [ScopDetect/Info] Incorrect Invariant Load Hoisting
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 24 16:35:45 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32778
Bug ID: 32778
Summary: [Polly] [ScopDetect/Info] Incorrect Invariant Load
Hoisting
Product: Polly
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Optimizer
Assignee: polly-dev at googlegroups.com
Reporter: huihuiz at codeaurora.org
CC: llvm-bugs at lists.llvm.org
Created attachment 18346
--> https://bugs.llvm.org/attachment.cgi?id=18346&action=edit
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: https://llvm.org/svn/llvm-project/polly/trunk@297375
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
...
--
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/20170424/1b93e7b6/attachment.html>
More information about the llvm-bugs
mailing list