On Mon, 16 Nov 2026 12:08:28 GMT, Andrew Dinn <[email protected]> wrote:

>> I don't feel comfortable adding a general function for operations that 
>> support shift specifically in this PR.  I believe that this type of work 
>> would better be served in a separate enhancement, where discussions of 
>> general interface design and operation combinitorics can be played out.
>
> @smemery Once again, there is a problem here that is about abstraction vs 
> underlying implementation.
> 
> You have a 'copy-pasta' sequence of 4 x 4 insns that are essentially the same 
> (modulo target register indices and bit positions/counts). Each subsequence 
> implements two adds with a shifted input for one of the operands and does so 
> with decoupled shift and add operations.
> 
> If you leave them as is then changing the implementation to use an add with 
> shifted register involves editing each occurrence.
> 
> If you use a generator sub-method then changing all these occurrences and 
> checking the performance of the alternative on different micro-archs is not 
> only trivial but, more importantly, enables 2 possible end positions to be 
> reached:
> 
> 1. we generate a single 'best' case implementation that is good enough for 
> all micro-archs
> 2. we generate variant, micro-arch specific implementations, gated on a 
> vm_version flag, to address any differences in performance found across 
> micro-arches that cannot acceptably be mitigated by a 'best' case choice
> 
> Two points to note:
> 
> Option 2 is something we rarely choose because we end up facing a 
> combinatorial explosion in dev and maintenance costs, especially as new hw 
> comes into play.
> 
> Your use of independent add and shift instructions rather than using the 
> available and more obvious choice of an add with shifted register looks very 
> much like you are pursuing option 2 without having first attended to the 
> possibility of option 1.

Yes, my interpretation was your Option 2, which is why I was deferring to a 
separate enhancement that would explore the "operation combinatorics".  I 
understand your and aph's point regarding this and have since reverted back to 
my original design, realizing that the updated code may not speed up 
performance on all architectures.  Done.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/33618#discussion_r4691447999

Reply via email to