[llvm-bugs] [Bug 45470] New: GVN incorrectly optimizes away a non-local load
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 7 17:28:15 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45470
Bug ID: 45470
Summary: GVN incorrectly optimizes away a non-local load
Product: libraries
Version: trunk
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: changpeng.fang at amd.com
CC: llvm-bugs at lists.llvm.org
Created attachment 23321
--> https://bugs.llvm.org/attachment.cgi?id=23321&action=edit
opt -O1 -gcn bug.ll
GVN pass incorrectly optimized away the load. Actually the load should have a
dependence on the store inside the loop. but it looks like the memory
dependence is somehow skipped and the load is found to depend on the alloca,
and thus replaced with undef.
---------------------------
.preheader: ; preds = %.preheader, %bb
%phi.i = phi i32 [ %next.i, %.preheader ], [ undef, %bb ]
%tmp1 = shl nuw nsw i32 %phi.i, 2
%offset = or i32 %tmp1, 2
%store.addr = getelementptr inbounds [16 x i16], [16 x i16] addrspace(5)*
%alloca, i32 0, i32 %offset
store i16 11878, i16 addrspace(5)* %store.addr, align 2
%next.i = add nuw nsw i32 %phi.i, 1
%cmp = icmp ult i32 %next.i, 8
br i1 %cmp, label %.preheader, label %.loopexit
.loopexit: ; preds = %.preheader
%addr = bitcast [16 x i16] addrspace(5)* %alloca to half addrspace(5)*
%result = load half, half addrspace(5)* %addr, align 2
call void @chfang(half %result)
unreachable
--------------------
to reproduce:
opt -O1 -gvn -S bug.ll
------------------------
You will find:
.loopexit: ; preds = %.preheader
%addr = bitcast [16 x i16] addrspace(5)* %alloca to half addrspace(5)*
tail call void @chfang(half undef)
unreachable
We don't think this non-local load should be optimized away.
--
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/20200408/ea393f38/attachment.html>
More information about the llvm-bugs
mailing list