[PATCH] D156612: [SimplifyCFG] Find the smallest table considering overflow in `switchToLookupTable`

DianQK via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 00:51:09 PDT 2023


DianQK added a comment.

In D156612#4647819 <https://reviews.llvm.org/D156612#4647819>, @khei4 wrote:

> I'm still not sure about the correctness of this. It seems like only setting the BeginCaseVal and EndCaseVal to the appropriate values is enough to handle overflowing switch cases. Test transformations themselves look correct!

Could you explain more about the overflow?
If you're referring to `RangeOverflow` in the code, this is a special handling to avoid redundant calculation.
Or do you mean that we can always find the smallest table whose End minus Begin does not overflow? Yes. But we need to introduce an overflow offset calculation.
For example, `[122, -128]([122, 128])` in the `@f_i8_128` case.



================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6439
+  });
+  SmallVectorImpl<ConstantInt *>::iterator CaseValIter = CaseVals.begin();
+  // We start by using the begin and end as the minimal table.
----------------
khei4 wrote:
> I think it's ok to use auto on this.
Thanks, if Nikita will continue to review it here, I'll change it directly. Otherwise I'll change it when I move to GitHub.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156612



More information about the llvm-commits mailing list