public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/56365] New: Missed opportunities for smin/smax standard name patterns
@ 2013-02-17 15:27 olegendo at gcc dot gnu.org
  2013-02-18 10:58 ` [Bug tree-optimization/56365] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: olegendo at gcc dot gnu.org @ 2013-02-17 15:27 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56365
           Summary: Missed opportunities for smin/smax standard name
                    patterns
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: olegendo@gcc.gnu.org


While working on a patch for PR 55303 to add signed / unsigned clipping insns
for the SH2A target, I've noticed the following (tested with -O2 on 196091 for
SH and ARM cross configs):

int test_03 (int a, int b)
{
  int r = a + b;
  if (r > 127)
    r = 127;
  else if (r < -128)
    r = -128;
  return r;
}

This will utilize smin / smax standard name patterns.

The following equivalent (if I'm not mistaken), however:

static inline int min (int a, int b) { return a < b ? a : b; }
static inline int max (int a, int b) { return a < b ? b : a; }

int test_04 (int a, int b)
{
  return max (-128, min (127, a));
}

will not expand to smin / smax patterns.


Another case is:

int test_05 (int a)
{
  if (127 <= a)
    a = 127;
  else if (a <= -128)
    a = -128;
  return a;
}

For integers this could also be done with smin / smax, but it isn't.


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

end of thread, other threads:[~2014-10-17 11:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-17 15:27 [Bug tree-optimization/56365] New: Missed opportunities for smin/smax standard name patterns olegendo at gcc dot gnu.org
2013-02-18 10:58 ` [Bug tree-optimization/56365] " rguenth at gcc dot gnu.org
2013-02-18 20:05 ` olegendo at gcc dot gnu.org
2014-05-10 12:52 ` [Bug tree-optimization/56365] Missed opportunities for smin/smax standard name patterns when compiling as C++ olegendo at gcc dot gnu.org
2014-07-31 17:04 ` olegendo at gcc dot gnu.org
2014-10-17 10:14 ` olegendo at gcc dot gnu.org
2014-10-17 11:41 ` 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).