[llvm-bugs] [Bug 50589] New: [Inliner] Noalias metadata incorrectly added to simplified calls
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jun 5 13:29:07 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50589
Bug ID: 50589
Summary: [Inliner] Noalias metadata incorrectly added to
simplified calls
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Interprocedural Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: nikita.ppv at gmail.com
CC: jeroen.dobbelaere at synopsys.com,
llvm-bugs at lists.llvm.org
>From https://reviews.llvm.org/D102110#inline-972360:
define <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* noalias %ptr2, <2 x i1>
%mask, <2 x i8> %passthru) {
%ret = call <2 x i8> @llvm.masked.load.v2i8(<2 x i8>* %ptr1, i32 1, <2 x i1>
%mask, <2 x i8> %passthru)
store <2 x i8> zeroinitializer, <2 x i8>* %ptr2
ret <2 x i8> %ret
}
define void @caller(<2 x i8>* %ptr1, <2 x i8>* %ptr2) {
%passthru = load <2 x i8>, <2 x i8>* %ptr2
call <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* %ptr2, <2 x i1>
zeroinitializer, <2 x i8> %passthru)
ret void
}
declare <2 x i8> @llvm.masked.load.v2i8(<2 x i8>*, i32, <2 x i1>, <2 x i8>)
Results in:
define <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* noalias %ptr2, <2 x i1>
%mask, <2 x i8> %passthru) {
%ret = call <2 x i8> @llvm.masked.load.v2i8.p0v2i8(<2 x i8>* %ptr1, i32 1, <2
x i1> %mask, <2 x i8> %passthru)
store <2 x i8> zeroinitializer, <2 x i8>* %ptr2, align 2
ret <2 x i8> %ret
}
define void @caller(<2 x i8>* %ptr1, <2 x i8>* %ptr2) {
%passthru = load <2 x i8>, <2 x i8>* %ptr2, align 2, !noalias !0
call void @llvm.experimental.noalias.scope.decl(metadata !0)
store <2 x i8> zeroinitializer, <2 x i8>* %ptr2, align 2, !alias.scope !0
ret void
}
In this case, we don't even need the incorrect annotation to go on an
instruction from the caller, it can also happen with a callee instruction:
define <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* noalias %ptr2, <2 x i1>
%mask) {
%passthru = load <2 x i8>, <2 x i8>* %ptr2
%ret = call <2 x i8> @llvm.masked.load.v2i8(<2 x i8>* %ptr1, i32 1, <2 x i1>
%mask, <2 x i8> %passthru)
store <2 x i8> zeroinitializer, <2 x i8>* %ptr2
ret <2 x i8> %ret
}
define void @caller(<2 x i8>* %ptr1, <2 x i8>* %ptr2) {
call <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* %ptr2, <2 x i1>
zeroinitializer)
ret void
}
declare <2 x i8> @llvm.masked.load.v2i8(<2 x i8>*, i32, <2 x i1>, <2 x i8>)
Results in:
define <2 x i8> @callee(<2 x i8>* %ptr1, <2 x i8>* noalias %ptr2, <2 x i1>
%mask) {
%passthru = load <2 x i8>, <2 x i8>* %ptr2, align 2
%ret = call <2 x i8> @llvm.masked.load.v2i8.p0v2i8(<2 x i8>* %ptr1, i32 1, <2
x i1> %mask, <2 x i8> %passthru)
store <2 x i8> zeroinitializer, <2 x i8>* %ptr2, align 2
ret <2 x i8> %ret
}
define void @caller(<2 x i8>* %ptr1, <2 x i8>* %ptr2) {
call void @llvm.experimental.noalias.scope.decl(metadata !0)
%passthru.i = load <2 x i8>, <2 x i8>* %ptr2, align 2, !alias.scope !0,
!noalias !0
store <2 x i8> zeroinitializer, <2 x i8>* %ptr2, align 2, !alias.scope !0
ret void
}
Note how the metadata is claiming that the load does not alias ... with itself.
We should not be adding noalias metadata to instructions that are the result of
simplification, as they may not correspond to the instruction from the original
function.
--
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/20210605/53fa4dfc/attachment.html>
More information about the llvm-bugs
mailing list