https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85501

            Bug ID: 85501
           Summary: missed if-conversion / phiopt trick
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
            Blocks: 53947, 85466
  Target Milestone: ---

PR85466 shows

For the "if" case, llvm turns:

if (myVector[n] > 0.5){
    result[n] = 0.8f;
}
else {
    result[n] = 0.1f;
}

into

const float tab[2] = { .8f, .1f };
result[n] = tab[item > .5f];

which is a neat trick.  Profitability is not without questions though
(if you'd do this to scalar code).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85466
[Bug 85466] Performance is slow when doing 'branchless' conditional style math
operations

Reply via email to