# [llvm-bugs] [Bug 34531] New: NewGVN: Missed value inference that paper algorithm would get

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 8 15:08:37 PDT 2017

```https://bugs.llvm.org/show_bug.cgi?id=34531

Bug ID: 34531
Summary: NewGVN: Missed value inference that paper algorithm
would get
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: dberlin at dberlin.org
CC: davide at freebsd.org, llvm-bugs at lists.llvm.org

Just to write this down somewhere:

The value inference algorithm (which we use predicateinfo in part to replace)
in the paper is quite powerful.

It will catch things we do not.

In particular two types of cases (and all their variants), one easy, one hard:

c = a != b
if (a == b) {
use c
}

This we have a straightforward way of fixing.
We can fix it either in NewGVN, *or* in PredicateInfo

Here is one that is harder:

I = J + 0
if (J == 0) {
K = I // Or I + something if you like
use K;
}

Here, K is 0
The value inferencing algorithm knows that J is congruent to I, so that the
predicates that apply to J apply to I.
PredicateInfo does not.

Here is one that is even harder:

I = J + 2
if (J == 0) {
K = I // Or I + something if you like
use K;
}

Now, i believe actually that we can do something useful here.

I believe i can solve all of these through making predicateinfo a congruence
class thing instead of a per-variable thing.
(It applies to anything that is equivalent to a predicate, otherwise, they
could not be equivalent)
It would also help to be able to add predicateinfo uses as we go.

Currently we can't because it's an analysis.
I may turn it back into a virtual form (I think i can make it work now that
i've thought about it more) so we can do that.

I will probably start by making predicateinfo per-congruence class.

--
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/20170908/31313627/attachment.html>
```