[all-commits] [llvm/llvm-project] 21a77e: [IR] Reorder Value fields to put the SubclassID fi...

Reid Kleckner via All-commits all-commits at lists.llvm.org
Fri Jan 12 15:15:06 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 21a77e8a92a8d97f0dfd5f9f4faa7b6bc82887aa
      https://github.com/llvm/llvm-project/commit/21a77e8a92a8d97f0dfd5f9f4faa7b6bc82887aa
  Author: Reid Kleckner <rnk at google.com>
  Date:   2024-01-12 (Fri, 12 Jan 2024)

  Changed paths:
    M llvm/include/llvm/IR/Value.h
    M llvm/lib/IR/Value.cpp

  Log Message:
  -----------
  [IR] Reorder Value fields to put the SubclassID first (#53520)

Placing the class id at offset 0 should make `isa` and `dyn_cast` faster
by eliminating the field offset (previously 0x10) from the memory
operand, saving encoding space on x86, and, in theory, an add micro-op.
You can see the load encodes one byte smaller here:
https://godbolt.org/z/Whvz4can9

The compile time tracker shows some modestly positive results in the
on the `cycle` metric and in the final clang binary size metric:
https://llvm-compile-time-tracker.com/compare.php?from=33b54f01fe32030ff60d661a7a951e33360f82ee&to=2530347a57401744293c54f92f9781fbdae3d8c2&stat=cycles
Clicking through to the per-library size breakdown shows that
instcombine size reduces by 0.68%, which is meaningful, and I believe
instcombine is known to be a hotspot.

It is, however, potentially noise. I still think we should do this,
because notionally, the class id really acts as the vptr of the Value,
and conventionally the vptr is always at offset 0.




More information about the All-commits mailing list