Skip to content

Provide some simplification of common routines like MIN/MAX #6942

@emesare

Description

@emesare

Created on behalf of @VisualEhrmanntraut

Optimiser for min, max expressions:

TYPE val;
if (Z > Y) {
  val = Y
} else {
  val = Z
}
// after
TYPE val = MIN(Y, Z);```
```// before 
TYPE val;
if (Z < Y) {
  val = Y
} else {
  val = Z
}
// after
TYPE val = MAX(Y, Z);

This should be done after all IL simplifications like constant propagation so that the analysis has a chance to optimize the MIN/MAX code out entirely. This really is not about any particular architecture plugin either, one can reasonably expect this operation to be performed by a set of instructions rather than any one instruction, were it the latter you might compromise and lift as an intrinsic, however even that is a little disappointing as you will stonewall certain analysis regarding the input and output registers.

Putting this as an HLIL issue because I believe that is the only place this optimization can be made considering the first sentence above.

Slack Message

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CoreIssue needs changes to the coreCore: HLILIssue involves High Level ILEffort: LowIssue should take < 1 weekIL OptimizationIssue involving optimization of representation (not correctness)Impact: MediumIssue is impactful with a bad, or no, workaround

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions