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: unassig...@gcc.gnu.org ReportedBy: olege...@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.