This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/56365] New: Missed opportunities for smin/smax standard name patterns
- From: "olegendo at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 17 Feb 2013 15:27:22 +0000
- Subject: [Bug tree-optimization/56365] New: Missed opportunities for smin/smax standard name patterns
- Auto-submitted: auto-generated
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.