Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 6 Next »

When the Zbkb extension is enabled an arbitrary 64bit constant can be loaded in a maximum of 5 instructions.  A lui+addi for the upper and lower 32 bits and a pack to merge them.   High performance uarchs will execute this in 2c and even a simplistic uarch would probably take a maximum of 5c.   Contrast to the what we do now where we push complex constants into the constant pool.  That's probably 3 instructions and 5c on most uarchs.  Naturally we would like to see constant synthesis improved when Zbkb is enabled.  The basic support for Zbkb is development-complete.  So the effort here is really just to use it in constant synthesis.


Known areas to improve:

  1. Use bseti when profitable.  Many cases of poor constant synthesis are failure to use bseti.
  2. Use "uw" variants of shifts/arithmetic instructions when the constant has bit 0x80000000 set.
  3. Use shNadd for constants evenly divisible by 9, 5 or 3.
  4. Use blcri in conjunction with lui or addi to clear a small number of bits, particularly in the high 33 bits of a 64bit word
  5. Adjust constant so low 13 bits are 0x1800, recursively re-synthesize and restore low bits with trailing addi.
  6. Use pack for repeating constants
  7. Use pack as synthesis of last resort

There are also cases that could be improved for designs without Zbkb, but which do have Zbs.  Consider a constant with just 4 bits set.  Say two non-consecutive bits in the high 32bit part of a 64bit word, then two bits down in the low 12 bits.   Such constants will tend to end up in the constant pool.  But this could be implemented with two bsets+addi.  That is going to be the same size and almost certainly faster than a constant pool reference. 

Stakeholders/Partners

RISE:

Ventana: Jeff Law – general oversight / guidance and implementation work.

External:

                    RAU: Sevak Sargsyan & Lyut Nersisyan – Lyut did the initial Zbkb work under contract to Ventana.


Dependencies



Status

Development

IN PROGRESS


Development Timeline1H2024
Upstreaming

IN PROGRESS



Upstream Version

gcc-15 (target)

(Spring 2025)





Contacts

Jeff Law (Ventana)


DependenciesNone


Updates

 

  • Updated list of various deficiencies in GCC's constant synthesis
  • Note that some of these are recently fixed (first week of May)
  • Hoping to have this done within the next week or so.

 

  • Basic Zbkb patterns written.  Haven't started on synthesis changes though.
  • Noted as a 1H2024 work item.
  • No labels