[PATCH] D21291: [SimplifyCFG] Range reduce switches

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 30 09:37:42 PDT 2016


jmolloy added inline comments.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:5088
@@ +5087,3 @@
+  // First, transform the values such that they start at zero and ascend.
+  uint64_t Base = Values[0];
+  for (auto &V : Values)
----------------
hans wrote:
> why isn't Base int64_t already? Also, could the subtraction overflow?
I don't think overflow is possible. The subtraction moves values towards zero; the only way I can consider it overflowing is if the difference between the smallest value and the largest value is INT64_MAX or greater which is impossible.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:5106
@@ +5105,3 @@
+  // be beneficial - flag values are often powers of two and we could use a CLZ
+  // as the key function.
+  if (GCD <= 1 || !llvm::isPowerOf2_64(GCD))
----------------
hans wrote:
> Any bijective transformation of the case values will work. The problem is just deciding when they're profitable, I suppose. But I'm all for more creative switch lowerings :-)
:)


Repository:
  rL LLVM

https://reviews.llvm.org/D21291





More information about the llvm-commits mailing list