Hi,

Several ports in gcc support conditional compare instructions which is
an efficient way to handle SHORT_CIRCUIT. But the information is not
represented in TREE or GIMPLE. And it depends on BRANCH_COST and
combine pass to generate the instructions.

To explicitly represent the semantics of conditional compare (CCMP)
and remove the dependence on BRANCH_COST and combine, we propose to
add a set of new keywords/operators on TREE.

A CCMP operator has three operands: two are from the compare and
the other is from the result of previous compare.
e.g.

  r = CMP (a, b) && CMP (c, d)  /*CMP can be >, >=, etc.*/

in current gcc, if LOGICAL_OP_NON_SHORT_CIRCUIT, it is like

  t1 = CMP (a, b)
  t2 = CMP (c, d)
  r = t1 & t2

with CCMP, it will be

  t1 = CMP (a, b)
  r  = CCMP (t1, c, d)

SHORT_CIRCUIT expression will be converted to CCMP expressions
at the end of front-end.

The CCMP will keep until expand pass. In expand, we will define a new
operator for ports to generate optimized RTL directly.

Current status:
* The basic support can bootstrap on ARM Chomebook and x86-64,
  no ICE and runtime fail in regression tests.
* uninit, vrp and reassoc passes can handle CCMP.

I will post a series of patches for this feature, which includes
* Add new keywords support.
* Handle the new keywords in middle-end passes: uninit, vrp, reassoc, ...
* Add new op to expand CCMP.

Thanks!
-Zhenqiang

Reply via email to