[PATCH] D135982: [SimplifyCFG] Try unsigned case value for switch to lookup table

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 14 18:32:22 PDT 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6373
+  // try unsigned if the case value is signed overflow
+  if (MinCaseVal->isMinSignedValue() && MaxCaseVal->isMaxValue(true)) {
+    for (auto Case : SI->cases()) {
----------------
bcl5980 wrote:
> craig.topper wrote:
> > Why not use `isMaxSignedValue` to be consistent with the use of `isMinSignedValue`?
> There is no `isMaxSignedValue` in Constant class. 
> `isMaxSignedValue` is on the APInt class.
Then maybe use isMinValue here? Looks like isMinSignedValue() goes down to Constant which has to dyn_cast back to ConstantInt to call isMinValue.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135982/new/

https://reviews.llvm.org/D135982



More information about the llvm-commits mailing list