public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/67971] New: Failure to unify conditional argument selection with conditional result selection
@ 2015-10-15  8:24 rsandifo at gcc dot gnu.org
  2015-10-15  9:37 ` [Bug tree-optimization/67971] " rguenth at gcc dot gnu.org
  2015-10-15  9:43 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2015-10-15  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67971
           Summary: Failure to unify conditional argument selection with
                    conditional result selection
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rsandifo at gcc dot gnu.org
  Target Milestone: ---

We don't optimise:

int
f1 (int cond, double x, double y)
{ 
  double z1, z2;

  if (cond)
    z1 = __builtin_cos (x);
  else
    z1 = __builtin_cos (y);
  z2 = __builtin_cos (cond ? x : y);
  return z1 == z2;
}

to "return 1" at -O2.


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

* [Bug tree-optimization/67971] Failure to unify conditional argument selection with conditional result selection
  2015-10-15  8:24 [Bug tree-optimization/67971] New: Failure to unify conditional argument selection with conditional result selection rsandifo at gcc dot gnu.org
@ 2015-10-15  9:37 ` rguenth at gcc dot gnu.org
  2015-10-15  9:43 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-15  9:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-10-15
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
VRP jump-threads this into sth PRE then can transform to

  <bb 2>:
  if (cond_3(D) != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

  <bb 3>:
  z1_5 = __builtin_cos (x_4(D));
  goto <bb 5>;

  <bb 4>:
  z1_7 = __builtin_cos (y_6(D));

  <bb 5>:
  # iftmp.0_2 = PHI <y_6(D)(4), x_4(D)(3)>
  # z1_13 = PHI <z1_7(4), z1_5(3)>
  # prephitmp_1 = PHI <z1_7(4), z1_5(3)>
  # RANGE [0, 1]
  _9 = prephitmp_1 == z1_13;
  # RANGE [0, 1] NONZERO 1
  _10 = (int) _9;
  return _10;

leaving the followup missed equivalency for the inserted PHI.

but then somehow DOM running later CSEing z1_13 and prephitmp_1 fails
to fold the comparison and we end up with

  _9 = z1_13 == z1_13;

which even forwprop doesn't simplify (even though it is supposed to fold
all stmts).  We do have

(simplify
 (eq @0 @0)
 (if (! FLOAT_TYPE_P (TREE_TYPE (@0))
      || ! HONOR_NANS (TYPE_MODE (TREE_TYPE (@0))))
  { constant_boolean_node (true, type); }))

but for some reason it doesn't trigger.

Investigating.


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

* [Bug tree-optimization/67971] Failure to unify conditional argument selection with conditional result selection
  2015-10-15  8:24 [Bug tree-optimization/67971] New: Failure to unify conditional argument selection with conditional result selection rsandifo at gcc dot gnu.org
  2015-10-15  9:37 ` [Bug tree-optimization/67971] " rguenth at gcc dot gnu.org
@ 2015-10-15  9:43 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-15  9:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Ah, because they may be NaN if x or y were NaN.  Works ok with
-ffinite-math-only,
PRE already figures out the result is 1.

Thus invalid.

And thus if we performed this simplification on GENERIC somehow that was likely
an invalid transform.


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

end of thread, other threads:[~2015-10-15  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-15  8:24 [Bug tree-optimization/67971] New: Failure to unify conditional argument selection with conditional result selection rsandifo at gcc dot gnu.org
2015-10-15  9:37 ` [Bug tree-optimization/67971] " rguenth at gcc dot gnu.org
2015-10-15  9:43 ` 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).