PR97359: Do not cache relops in GORI cache.
authorAldy Hernandez <aldyh@redhat.com>
Sat, 10 Oct 2020 06:28:52 +0000 (08:28 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Sat, 10 Oct 2020 08:26:30 +0000 (10:26 +0200)
commit14db1dfcd18e4d2712a043bdcd3976fcfb0642c2
tree4024be568c83e5548dce3a3f8481a4822947efad
parentc74a0e82fa305f52b84e5c4cd2c9e0d0e8e4f265
PR97359: Do not cache relops in GORI cache.

logical_stmt_cache::cacheable_p() returns true for relops, but
logical_combine (which does the caching) doesn't handle them and ICEs.
This patch fixes the inconsistency by returning false for relops.

This was working before because even though logical_combine doesn't
handle relops, statements with only one SSA are handled in cache_stmt,
which seems like the only statement we've ever encountered (even through
a full Fedora build).

lhs = s_5 > 999;

However, with two SSA operands we ICE because logical_combine doesn't
handle them:

lhs = s_5 > y_8;

We can either return false for relops in cacheable_p, or fix
logical_combine to handle them.  The original idea was to only cache
ANDs and ORs, so I've done the former to unbreak trunk.

We can decide later if there was ever any benefit in caching relops.

gcc/ChangeLog:

PR tree-optimization/97359
* gimple-range-gori.cc (logical_stmt_cache::cacheable_p): Only
handle ANDs and ORs.
(gori_compute_cache::cache_stmt): Adjust comment.

gcc/testsuite/ChangeLog:

* gcc.dg/pr97359.c: New test.
gcc/gimple-range-gori.cc
gcc/testsuite/gcc.dg/pr97359.c [new file with mode: 0644]