User account creation filtered due to spam.

Bug 46555 - [5/6/7/8 Regression] PHI RTL expansion leads to CSiBE regression
Summary: [5/6/7/8 Regression] PHI RTL expansion leads to CSiBE regression
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.6.0
: P2 normal
Target Milestone: 7.3
Assignee: Andrew Pinski
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2010-11-19 08:26 UTC by Jan Hubicka
Modified: 2017-08-16 07:35 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-01-05 00:00:00


Attachments
testcase (OpenTCP-1.0.4/icmp.c) (5.25 KB, application/octet-stream)
2010-11-19 08:26 UTC, Jan Hubicka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Hubicka 2010-11-19 08:26:47 UTC
Created attachment 22452 [details]
testcase (OpenTCP-1.0.4/icmp.c)

Hi,
the problem here seems to be worse regalloc and also
  # D.4060_6 = PHI <-1(2), -1(9), -1(11), -1(14), 0(15), -1(10)>
used to be optimized into since set of var to -1 (4 bytes), while now we
produce 3 different copies. 

Crossjumping would unify it, but very late in the game. The problem is that
ifcvt actually moves the set before conditoinal guarding the BB in question, so
the individual sets are drifted earlier to different places in the program.

Doing so might also complicate the regalloc.

Michael, perhaps we can tell out-of-ssa to unify such cases?  They are not that
infrequent (and I think old tree based out-of-ssa did that?)
Comment 1 Richard Biener 2010-11-19 10:55:11 UTC
Yep.  That's one optimization that was removed (out-of-SSA did that) and
we thought of doing this reverse mergephi optimization as a separate pass
before expansion.
Comment 2 Andrew Pinski 2016-01-05 22:22:02 UTC
  <bb 17>:

  # _6 = PHI <-1(17), 0(15), -1(10)>
<L26>:


It is not as bad on the trunk now but I don't think it has been fixed.
Comment 3 Andrew Pinski 2016-01-06 03:05:44 UTC
I am going to try to work on this so it can be in for stage 1 of 7.
Comment 4 Andrew Pinski 2016-01-14 04:40:41 UTC
.
Comment 5 Andrew Pinski 2016-01-14 06:27:26 UTC
PRE does some of it via tail merge:
find_duplicates: <bb 7> duplicate of <bb 8>
find_duplicates: <bb 7> duplicate of <bb 9>
Removing basic block 8
Removing basic block 9

Obviously if you have more complex code it won't do it.
This an example where PRE does it:
int h(void);
int f(int a, int b, int c)
{
  if (a)
    return 2;
  h();
  if (b)
    return 2;
  h();
  if (c)
    return 2;
  h();
  return 4;
}
Comment 6 Richard Biener 2016-01-14 09:56:28 UTC
The idea is to add forwarder blocks here.  Of course doing this too aggressively may be bad, not sure (extra jumps instead of extra copies).  Eventually the
targets want some control on this.
Comment 7 Jakub Jelinek 2017-05-02 15:57:23 UTC
GCC 7.1 has been released.