Detect smin / umin idiom

Registered by Michael Hope

Detects and optimise idioms like:

#define min(x, y) ((x) <= (y)) ? (x) : (y)

unsigned int foo (unsigned int i, unsigned int x ,unsigned int y)
{
  return i < (min (x, y));
}

int bar (int i, int x, int y)
{
  return i < (min (x, y));
}

See https://code.launchpad.net/~ramana/gcc-linaro/47-smin-umin-idiom/+merge/104327 for more.

In addition to the backend patch it would be good to implement something similar in tree before the vectorizer kicks in allowing such loops to be vectorized.

Blueprint information

Status:
Complete
Approver:
Michael Hope
Priority:
Medium
Drafter:
Michael Hope
Direction:
Approved
Assignee:
Christophe Lyon
Definition:
Approved
Series goal:
Accepted for 4.8
Implementation:
Informational Informational
Milestone target:
milestone icon 4.8-2013.09
Started by
Matthew Gretton-Dann
Completed by
Matthew Gretton-Dann

Whiteboard

With the patch this becomes:

- cmp r2, r1
- movcs r2, r1
  cmp r2, r0
+ cmpcs r1, r0

[christophe-lyon 2013-02-11]
* After generation of suitable benchmark references (i.e. a recent 4.7 revision), there is a 96.9% score in spec2k's galgel.
* The middle-end implementation is described in this blueprint: https://blueprints.launchpad.net/gcc-linaro/+spec/end-of-loop-computations-min

Meta:
Headline: Improve GCC's recognition of signed/unsigned minima functions
Acceptance: Patch accepted into upstream GCC and backported to GCC Linaro.
Roadmap id: CARD-304

[2013-05-29 matthew-gretton-dann] Moved to Jira: http://cards.linaro.org/browse/TCWG-146

(?)

Work Items

Work items:
Rebase patch on current gcc-linaro-4.7: DONE
Check rebuild and testsuite are ok in cbuild: DONE
Benchmark under cbuild: DONE
Investigate regression: TODO
Investigate possible middle-end implementation: INPROGRESS
Send patch upstream: TODO
Backport to gcc-linaro: TODO

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.