On Mon, 16 Nov 2026 07:36:43 GMT, Shawn Emery <[email protected]> wrote:
>> src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp line 8976: >> >>> 8974: __ add(c[i - 5], c[i - 5], vt); >>> 8975: __ asr(vt, v, 36); >>> 8976: __ add(c[i - 4], c[i - 4], vt); >> >> This separation of shift and add instructions is extreme microarchitecture >> tweakiness, and arguably overfitting generic AArch64 to a silicon >> implementation of it. >> >> At least, please create a function for the combined shift-and-add, with a >> comment which explains why it exists at all, and specify here exactly which >> microarchitecture you're tuning for. And let's see if this tweak helps an >> independent implementation. >> >> Remember we're programming for an ISA, not a specific implementation of it. > > 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. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/33618#discussion_r4585513846
