bootstrap/102681 - properly CSE PHIs with default def args
authorRichard Biener <rguenther@suse.de>
Fri, 22 Oct 2021 08:32:36 +0000 (10:32 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 22 Oct 2021 09:37:35 +0000 (11:37 +0200)
commitfe8475c500939011b90504304aec61bf6f48ac7d
treea80c3e0baa42ea49570b930bb3ba4e2509ef8bac
parentae5c540662e08de72c849bad992fea468e3b6017
bootstrap/102681 - properly CSE PHIs with default def args

The PR shows that we fail to CSE PHIs containing (different)
default definitions due to the fact on how we now handle
on-demand build of VN_INFO.  The following fixes this in the
same way the PHI visitation code does.

On gcc.dg/ubsan/pr81981.c this causes one expected warning to be
elided since the uninit pass sees the change

   <bb 4> [local count: 1073741824]:
   # u$0_2 = PHI <u$0_5(D)(3), i_3(D)(5)>
-  # cstore_11 = PHI <t$0_6(D)(3), i_3(D)(5)>
   v = u$0_2;
-  return cstore_11;
+  return u$0_2;

and thus only one of the conditionally uninitialized uses (the
other became dead).  I have XFAILed the missing diagnostic,
I don't see a way to preserve that.

2021-10-22  Richard Biener  <rguenther@suse.de>

PR bootstrap/102681
* tree-ssa-sccvn.c (vn_phi_insert): For undefined SSA args
record VN_TOP.
(vn_phi_lookup): Likewise.

* gcc.dg/tree-ssa/ssa-fre-97.c: New testcase.
* gcc.dg/ubsan/pr81981.c: XFAIL one case.
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-97.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/ubsan/pr81981.c
gcc/tree-ssa-sccvn.c