[PATCH] Switch to Select range optimization

Hans Wennborg hans at chromium.org
Fri Nov 14 12:09:31 PST 2014


The patch seems to have been uploaded without context. If you're uploading the patch manually (i.e. not using arcanist), please generate the diff with -U99999. That way it's much easier to look at it in the review tool.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:3540
@@ +3539,3 @@
+  // the minimum and maximum cases and the zeroes and ones for this case group.
+  for (auto &Case : Cases) {
+    bool CaseMatchesCondPattern =
----------------
I don't see any need for auto here..

for (ConstantInt *Case : Cases)

would be clearer, and it avoids making Case a reference to a pointer type, which seems unnecessary.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:3721
@@ +3720,3 @@
+  bool DefaultCanTrigger = (((1 << (BitWidth - NumKnownCondBits)) -
+                        (FirstGroupValidCases + SecondGroupValidCases)) != 0);
+  DefaultCanTrigger &= (bool)DefaultResult;
----------------
Using known bits to figure out if the default case can trigger is clever. Other optimizations would benefit from this too, so I think SimplifyCFG should have a separate transformation that does this analysis and makes the default case unreachable. That way more optimizations benefit, and the code here becomes simpler.

http://reviews.llvm.org/D6269






More information about the llvm-commits mailing list