[PATCH] D38265: [BypassSlowDivision] Improve our handling of divisions by constants

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 15:31:19 PDT 2017


sanjoy added inline comments.


================
Comment at: lib/Transforms/Utils/BypassSlowDivision.cpp:359
+    // it stays a constant so we don't have to worry about breaking DAGCombiner
+    // optimizations on divisions by constants.
 
----------------
jlebar wrote:
> The divisor also stays a constant in the other two cases, so is this really the thing that makes us want to do this transformation but not the other ones when the divisor is a constant?
The way I worked this out in my head is that, for the optimization to be worth it, the perf improvement from doing a shorter op must be more than the perf regression due to control flow.  When the op is divide the assumption is that this tradeoff is worth it, but when the op is multiply (division by constant) this tradeoff is not worth it.

However, if we can narrow the op (divide or multiply) without any control flow then there is no tradeoff -- we should always narrow the op.


https://reviews.llvm.org/D38265





More information about the llvm-commits mailing list