CT_00_031 -- Additional Constant Synthesis Improvements
Constant synthesis was greatly improved during 1H 2024. The areas noted here are exploratory and thus some ideas may be useful, some may not. These are primarily meant to improve pack sequences, though they may be helpful for designs without Zbkb.
Areas to explore:
For a constant where the high and low halves only differ by a few bits, consider using pack as an intermediate step and the Zbs instructions to make final adjustments.Similarly for cases where the high half can be constructed by merely shifting the low half.Improve handling of constants where the upper and lower 32bit halves are the same and zbkb is not available. It is believed this is a relatively small adjustment to the existing code.SImilar to the prior item with both halves equal, but when bit 31/63 are both on. For this case generate ~val (which will necessarily have bits 31/63 off), then xor against -1 to get the final target value.Some constants may be generated with something like lui+shadd+addi where the lui+shadd targets a nearby constant and the final addi fixes things up. The approach of targeting a nearby constant with a fixup at the end probably applies to most synthesis opportunities where the cost is 4+ instructions.
Stakeholders/Partners
RISE:
Ventana: Jeff Law & Raphael Zinsly – general oversight / guidance and implementation work.
Rivos: Vineet Gupta – generally interested in constant synthesis and has some state on #5 above.
External:
Dependencies
Status
Updates
- Various patches from Raphael targeting constants where the upper half can be derived from the lower half by bit manipulation, shifting, simple arithmetic were upstreamed in Sept.
- Raphael's work for generating constants where the upper/low halves are the same with bit 31/63 on has been integrated upstream.
- Matched upper/lower bits going through external review
- Upper half derivable via shifting lower half also going through review
- Noted as 2H 2024 work item