public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/59660] New: We fail to optimize common boolean checks pre-inlining
@ 2014-01-02 20:33 hubicka at gcc dot gnu.org
  2014-01-02 20:33 ` [Bug tree-optimization/59660] " hubicka at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: hubicka at gcc dot gnu.org @ 2014-01-02 20:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59660

            Bug ID: 59660
           Summary: We fail to optimize common boolean checks pre-inlining
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hubicka at gcc dot gnu.org

We fail to inline the following function from graphite-poly.h:
/* Determine whether CHREC is an affine evolution function or not.  */

static inline bool
evolution_function_is_affine_p (const_tree chrec)
{
  return chrec
    && TREE_CODE (chrec) == POLYNOMIAL_CHREC
    && evolution_function_is_invariant_p (CHREC_RIGHT (chrec),
                                          CHREC_VARIABLE (chrec))
    && (TREE_CODE (CHREC_RIGHT (chrec)) != POLYNOMIAL_CHREC
        || evolution_function_is_affine_p (CHREC_RIGHT (chrec)));
}


It is tail recursive, but the recursion is easy to remove and handled by late
tail recursion pass (post inlining).  Pre-inlining we stop at:
  <bb 6>:
  _15 = evolution_function_is_affine_p (_12);
  if (_15 != 0)
    goto <bb 7>;
  else
    goto <bb 8>;

  <bb 7>:

  <bb 8>:
  # iftmp.121_1 = PHI <1(7), 0(3), 0(2), 0(6), 0(4), 1(5)>
  return iftmp.121_1;


The conditional here is autogenerated by the boolean expression but is
pointless. Phiopt gets it into:
  <bb 6>:
  _15 = evolution_function_is_affine_p (_12);

  <bb 7>:
  # iftmp.121_1 = PHI <1(5), 0(3), 0(2), _15(6), 0(4)>
  return iftmp.121_1;


This seems rather common pattern suggesting that perhaps we may phiopt
pre-inline or do the same trick in one of existing early opts?


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

end of thread, other threads:[~2023-08-18 20:42 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-02 20:33 [Bug tree-optimization/59660] New: We fail to optimize common boolean checks pre-inlining hubicka at gcc dot gnu.org
2014-01-02 20:33 ` [Bug tree-optimization/59660] " hubicka at gcc dot gnu.org
2014-01-07 11:39 ` rguenth at gcc dot gnu.org
2014-01-07 13:04 ` hubicka at ucw dot cz
2014-01-07 13:13 ` rguenther at suse dot de
2014-01-07 15:07 ` hubicka at ucw dot cz
2014-01-07 15:10 ` rguenther at suse dot de
2014-01-08 13:09 ` hubicka at ucw dot cz
2014-01-08 14:03 ` rguenther at suse dot de
2014-01-08 17:23 ` hubicka at ucw dot cz
2014-01-08 18:37 ` hubicka at ucw dot cz
2014-01-09  9:52 ` rguenth at gcc dot gnu.org
2014-01-09 13:12 ` hubicka at ucw dot cz
2021-06-01 22:16 ` pinskia at gcc dot gnu.org
2021-09-06  0:36 ` pinskia at gcc dot gnu.org
2023-04-09 23:27 ` pinskia at gcc dot gnu.org
2023-04-09 23:40 ` pinskia at gcc dot gnu.org
2023-06-14 16:28 ` pinskia at gcc dot gnu.org
2023-08-18 20:42 ` pinskia 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).