[llvm-bugs] [Bug 49980] New: GVN should leave loads alone that feed only into assumes
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Apr 15 17:32:28 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=49980
Bug ID: 49980
Summary: GVN should leave loads alone that feed only into
assumes
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: jdoerfert at anl.gov
CC: llvm-bugs at lists.llvm.org
As part of the new OpenMP device runtime we transform assertions into
`__builtin_assume` in release mode. This works just fine except that the GVN
pass, despite all load-pre options set to disable, messes with the code in ways
that are unfortunate.
I haven't distilled a perfect example but the following code gives an idea (
https://godbolt.org/z/8z719n6We):
```
int G;
int foo(int);
void square(int num, int *__restrict__ A) {
for (int i = 0; i < 100; ++i) {
__builtin_assume(G == 42);
if (A[i])
A[i] = foo(i);
__builtin_assume(G == 42);
}
}
```
What I want is the load that feeds into the assume to just stay with the
assume, make it simple to leverage the condition later on.
What happens is that the load is hoisted, sunk, deduplicated, etc., all is not
helpful, in parts because we will drop those loads in the end anyway.
I assume GVN needs to be aware of the result of
`CodeMetrics::collectEphemeralValues` to avoid "optimizing" things we will drop
anyway.
--
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/20210416/788f4b2e/attachment.html>
More information about the llvm-bugs
mailing list