[PATCH] D21291: [SimplifyCFG] Range reduce switches

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 16:48:57 PDT 2016


sanjoy added inline comments.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:5029
@@ +5028,3 @@
+  for (auto &V : Values)
+    GCD = llvm::GreatestCommonDivisor64(GCD, (uint64_t)V);
+  if (GCD <= 1 || !llvm::isPowerOf2_64(GCD))
----------------
eli.friedman wrote:
> sanjoy wrote:
> > This gcd computation looks like extra work -- why not:
> > 
> > ```
> > uint64_t PotentialGCD = Values[1];
> > if (!isPowerOf2(PotentialGCD)) return false;
> > if (!all_of(Values, [](uint64_t V) { return V & (PotentialGCD - 1) == 0; }) return false;
> > ```
> > 
> That isn't equivalent for something like "0, 8, 12, 16, 20".
Yeah, you're right.  I was still thinking in terms of the older "100% dense" scheme.


Repository:
  rL LLVM

http://reviews.llvm.org/D21291





More information about the llvm-commits mailing list