https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126896
Bug ID: 126896
Summary: backward threader cannot duplicate a PHI-of-compares
join block
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: aldyh at gcc dot gnu.org
CC: amacleod at redhat dot com, law at gcc dot gnu.org,
rguenth at gcc dot gnu.org
Target Milestone: ---
Another missing optimization. I don’t know who’s responsibility this is, cause
I don’t think this maps to ranger.
Fixing this category fixes the following regressions from disabling DOM jump
threading:
gcc.dg/tree-ssa/phi_on_compare-1.c
gcc.dg/tree-ssa/phi_on_compare-2.c
gcc.dg/tree-ssa/phi_on_compare-3.c
/* { dg-do compile } */
/* { dg-options "-O2 --param=dom-jump-threading=0 -fdump-tree-optimized" } */
/* Each arm computes a boolean relational; out-of-ssa leaves
t = PHI <t_9, t_6>; if (t). The exit conditional is [0,1] varying
on every path, so the backward threader rejects every candidate
path: it only registers a path with a resolved single out-edge.
DOM's forward threader duplicates the join block into each
predecessor as a "joiner" and its simplifier replaces the copied
if (t) with the arm's own comparison, so the bool PHI and the join
block die. With DOM threading disabled they survive. */
void g (void);
void
f (int x, int a, int b, int c, int d)
{
_Bool t;
if (x)
t = a < b;
else
t = c < d;
if (t)
g ();
}
/* { dg-final { scan-tree-dump-not "PHI" "optimized" } } */