public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/67975] Failure to optimise equality between two call sequences
       [not found] <bug-67975-4@http.gcc.gnu.org/bugzilla/>
@ 2015-10-15 12:53 ` rguenth at gcc dot gnu.org
  2015-10-15 13:23 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-15 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-10-15
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  The issue is that to do the optimization we rely on jump-threading
to duplicate out the tails.  We can't see the equivalence of the functions
without
that trick.  Basically the following kind of pattern

  <bb 3>:
  if (x_6(D) < 2.0e+1)
    goto <bb 10>;
  else
    goto <bb 4>;

  <bb 10>:
  goto <bb 5>;

  <bb 4>:

  <bb 5>:
  # iftmp.1_2 = PHI <x_6(D)(10), y_5(D)(4)>
  iftmp.0_7 = __builtin_tan (iftmp.1_2);
  z1_15 = __builtin_cos (iftmp.0_7);
  if (x_6(D) < 2.0e+1)
    goto <bb 11>;
  else
    goto <bb 6>;

  <bb 11>:
  goto <bb 7>;

  <bb 6>:

  <bb 7>:
  # iftmp.3_4 = PHI <x_6(D)(11), y_5(D)(6)>
  iftmp.2_9 = __builtin_tan (iftmp.3_4);
  _23 = __builtin_cos (iftmp.2_9);

requires jump-threading to remove the duplicate check and prove the
PHIs equal.  VRP misses a secondary jump-threading opportunity here
for example.

I will think about this a bit to see whether it's (easily) possible to
value-number the PHIs the same without performing the jump-threading.


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

* [Bug tree-optimization/67975] Failure to optimise equality between two call sequences
       [not found] <bug-67975-4@http.gcc.gnu.org/bugzilla/>
  2015-10-15 12:53 ` [Bug tree-optimization/67975] Failure to optimise equality between two call sequences rguenth at gcc dot gnu.org
@ 2015-10-15 13:23 ` rguenth at gcc dot gnu.org
  2015-10-16 10:38 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-15 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
int foo (int x, int y)
{
  int a = x > 5 ? x : y;
  int b = x > 5 ? x : y;
  return a == b;
}

this should be handled in FRE1 already (well, if hopefully easily possible).
Currently two PHIs are only ever considered to have the same value if they
appear in the same basic-block.


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

* [Bug tree-optimization/67975] Failure to optimise equality between two call sequences
       [not found] <bug-67975-4@http.gcc.gnu.org/bugzilla/>
  2015-10-15 12:53 ` [Bug tree-optimization/67975] Failure to optimise equality between two call sequences rguenth at gcc dot gnu.org
  2015-10-15 13:23 ` rguenth at gcc dot gnu.org
@ 2015-10-16 10:38 ` rguenth at gcc dot gnu.org
  2015-10-16 12:29 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-16 10:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I have a prototype that handles (extended) diamonds.  With this FRE1 is able to
optimize the check to 1 (with -O -ffast-math).


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

* [Bug tree-optimization/67975] Failure to optimise equality between two call sequences
       [not found] <bug-67975-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2015-10-16 10:38 ` rguenth at gcc dot gnu.org
@ 2015-10-16 12:29 ` rguenth at gcc dot gnu.org
  2015-10-19 10:22 ` rsandifo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-16 12:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
https://gcc.gnu.org/ml/gcc-patches/2015-10/msg01580.html

Hope that fixes all cases you ran into.


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

* [Bug tree-optimization/67975] Failure to optimise equality between two call sequences
       [not found] <bug-67975-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2015-10-16 12:29 ` rguenth at gcc dot gnu.org
@ 2015-10-19 10:22 ` rsandifo at gcc dot gnu.org
  2015-10-19 14:00 ` rguenth at gcc dot gnu.org
  2015-10-19 14:01 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2015-10-19 10:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #4)
> https://gcc.gnu.org/ml/gcc-patches/2015-10/msg01580.html
> 
> Hope that fixes all cases you ran into.

Yeah, thanks.  That fixes the builtins-20.c failures that I was seeing
after moving fold_strip_sign_ops to gimple.


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

* [Bug tree-optimization/67975] Failure to optimise equality between two call sequences
       [not found] <bug-67975-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2015-10-19 10:22 ` rsandifo at gcc dot gnu.org
@ 2015-10-19 14:00 ` rguenth at gcc dot gnu.org
  2015-10-19 14:01 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-19 14:00 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.


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

* [Bug tree-optimization/67975] Failure to optimise equality between two call sequences
       [not found] <bug-67975-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2015-10-19 14:00 ` rguenth at gcc dot gnu.org
@ 2015-10-19 14:01 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-19 14:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Mon Oct 19 14:00:28 2015
New Revision: 228971

URL: https://gcc.gnu.org/viewcvs?rev=228971&root=gcc&view=rev
Log:
2015-10-19  Richard Biener  <rguenther@suse.de>

        PR tree-optimization/67975
        * tree-cfg.h (extract_true_false_controlled_edges): Declare.
        * tree-cfg.c (extract_true_false_controlled_edges): Split out
        core worker from ...
        * tree-ssa-loop-im.c (extract_true_false_args_from_phi): ... here.
        * tree-ssa-sccvn.c (vn_phi_compute_hash): Hash number of args
        instead of block number for PHIs with two or one args.
        (vn_phi_eq): Compare edge predicates of PHIs that are in different
        blocks.

        * gcc.dg/tree-ssa/ssa-fre-50.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-50.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfg.c
    trunk/gcc/tree-cfg.h
    trunk/gcc/tree-ssa-loop-im.c
    trunk/gcc/tree-ssa-sccvn.c


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

end of thread, other threads:[~2015-10-19 14:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-67975-4@http.gcc.gnu.org/bugzilla/>
2015-10-15 12:53 ` [Bug tree-optimization/67975] Failure to optimise equality between two call sequences rguenth at gcc dot gnu.org
2015-10-15 13:23 ` rguenth at gcc dot gnu.org
2015-10-16 10:38 ` rguenth at gcc dot gnu.org
2015-10-16 12:29 ` rguenth at gcc dot gnu.org
2015-10-19 10:22 ` rsandifo at gcc dot gnu.org
2015-10-19 14:00 ` rguenth at gcc dot gnu.org
2015-10-19 14:01 ` rguenth at gcc dot gnu.org

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).