ifcvt: Check if cmovs are needed.
authorRobin Dapp <rdapp@linux.ibm.com>
Wed, 19 Jan 2022 16:36:27 +0000 (17:36 +0100)
committerRobin Dapp <rdapp@linux.ibm.com>
Wed, 19 Jan 2022 17:33:53 +0000 (18:33 +0100)
commit4c46f5a471c239f7d3fb37c748f1f18a8ebae1a2
tree3daf62a0b89865bf617203851079cdc66cb54fc5
parentd5148d4faa6fb1e93b8ea1fad4a69806454f56f5
ifcvt: Check if cmovs are needed.

When if-converting multiple SETs and we encounter a swap-style idiom

  if (a > b)
    {
      tmp = c;   // [1]
      c = d;
      d = tmp;
    }

ifcvt should not generate a conditional move for the instruction at
[1].

In order to achieve that, this patch goes through all relevant SETs
and marks the relevant instructions.  This helps to evaluate costs.

On top, only generate temporaries if the current cmov is going to
overwrite one of the comparands of the initial compare.

gcc/ChangeLog:

* ifcvt.cc (need_cmov_or_rewire): New function.
(noce_convert_multiple_sets): Call it.
gcc/ifcvt.cc