[PATCH] D47024: [MathExtras] Add alignToPowerOf2

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 18 11:08:34 PDT 2018


ruiu added a comment.

In https://reviews.llvm.org/D47024#1104843, @MaskRay wrote:

> Sorry for being unclear. I mean that code also wants to avoid a division instruction. Is that because the symbols are iterated NumSymbols*Concurrency times to the saving is significant but other alignment improvement may be unnoticeable?


Well, I don't know the answer, and I don't think I should make a guess whether some optimization is effective or not, as the axiom "don't guess, measure!" says. If you believe that that could make a difference, you should just run a benchmark with and without your change.

(But before start optimizing something, you want to make sure that the code you are trying to optimize is a bottleneck. If the code takes only 1% of total execution time, optimizing it by 1% improves the total execution time only by 0.01% which is perhaps too small to measure.)

That particular code you pointed out was chosen as a result of benchmarking. We generally don't want to micro-optimize code like that, but since if it was proved to be effective, we did that.


Repository:
  rL LLVM

https://reviews.llvm.org/D47024





More information about the llvm-commits mailing list