[PATCH] Switch to Select range optimization

Marcello Maggioni hayarms at gmail.com
Fri Nov 14 12:17:05 PST 2014


Ok, thanks Hans!
I will do it next time. I usually use "git diff" for generating the diff , I'll take a look at Arcanist too though.

================
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 =
----------------
hans wrote:
> 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.
Will do.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:3721
@@ +3720,3 @@
+  bool DefaultCanTrigger = (((1 << (BitWidth - NumKnownCondBits)) -
+                        (FirstGroupValidCases + SecondGroupValidCases)) != 0);
+  DefaultCanTrigger &= (bool)DefaultResult;
----------------
hans wrote:
> 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.
Do you think I should hoist it to a separate static function in SimplifyCFG?

Is this what you had in mind?

http://reviews.llvm.org/D6269






More information about the llvm-commits mailing list