public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about the pass_fre about merging if blocks.
@ 2023-10-20 11:47 Hanke Zhang
  2023-10-20 13:33 ` Richard Biener
  0 siblings, 1 reply; 8+ messages in thread
From: Hanke Zhang @ 2023-10-20 11:47 UTC (permalink / raw)
  To: gcc

Hi, I'm trying to make pass_fre work better for me. But I got a
problem. Like the code below:

int glob;

void __attribute__((oninline))
foo() {
  // do nothing meaningful
}

int main() {
  if (glob) {
    foo();
  } else {
    // do something that won't change glob
  }

  if (glob) {
    foo();
  } else {
    // do something that won't change glob
  }
}

I'm trying to merge the two if blocks. And of course it won't work. I
see the code in tree-ssa-structalias.cc, it will do this check:

static bool
pt_solution_includes_1 (struct pt_solution *pt, const_tree decl) {
  // xxxx
  if (pt->nonlocal
      && is_global_var (decl))
    return true;
 // xxxx
}

So the pt->nonlocal will prevent the merge. I would like to ask if I
can make this check less rigid by providing more information about
function foo(). Because obviously the foo function does not change the
value of glob here, but it is caused by the fact that it is noinline.

So if I can prove that foo won't change glob and pass this infomation
to this check, my goal was achieved. Is this possible?

Thanks
Hanke Zhang

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-21 16:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20 11:47 Question about the pass_fre about merging if blocks Hanke Zhang
2023-10-20 13:33 ` Richard Biener
2023-10-20 14:33   ` Hanke Zhang
2023-10-20 15:26     ` Richard Biener
2023-10-21  8:58       ` Hanke Zhang
2023-10-21 10:23         ` Richard Biener
2023-10-21 14:39           ` Hanke Zhang
2023-10-21 16:47             ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).