https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122660

            Bug ID: 122660
           Summary: uninit predicated analysis not strong enough (derived
                    from uninit-pred-7_a.c)
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Created attachment 62779
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62779&action=edit
gimple testcase

Take the attached gimple testcase which derived from uninit-pred-7_a.c with a
pass_mergephi added after pass_dominator (the one right after pass_sra):
```
diff --git a/gcc/passes.def b/gcc/passes.def
index fac04cd86c7..2eb5b948618 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -258,6 +258,7 @@ along with GCC; see the file COPYING3.  If not see
       /* Threading can leave many const/copy propagations in the IL.
         Clean them up.  Failure to do so well can lead to false
         positives from warnings for erroneous code.  */
+      NEXT_PASS (pass_merge_phi);
       NEXT_PASS (pass_copy_prop);
       /* Identify paths that should never be executed in a conforming
         program and isolate those paths.  */

```

We get a bogus uninitialized warning:
```
<source>: In function 'foo':
<source>:105:3: warning: 'v' may be used uninitialized [-Wmaybe-uninitialized]
  105 |   blah (v_28);
      |   ^~~~
<source>:9:7: note: 'v' was declared here
    9 |   int v;
      |       ^
```

I will be xfailing uninit-pred-7_a.c when I submit the patches for PR122493 but
I wanted to file this first as it can be reproduced using a gimple testcase. 

The main difference the merge_phi here does here is allows tail_merge to find
the bb containing the call to `blah (v);`:
```
find_duplicates: <bb 13> duplicate of <bb 11>
...
Removing basic block 13
;; basic block 13, loop depth 0
;;  pred:
blah (v_34);
;;  succ:       14
```

Reply via email to