[PATCH] D109565: Teach SimplifyCFG to fold switches into lookup tables in more cases.

Owen Anderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 10 15:26:13 PDT 2021


resistor added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5060
+  // materializing the array of constants.
+  C = cast<Constant>(C->stripInBoundsConstantOffsets());
+
----------------
nikic wrote:
> Note that GEPs are already handled below, so we should either drop that handling, or handle bitcasts in the same way. The current GEP handling uses "no notional overindexing" as the condition, which I agree is an unnecessary requirement here -- your choice of "inbounds with constant offsets" is the right one. Whether there is notional overindexing really shouldn't matter in this context, the relocation only cares about offsets.
> 
> However, something your implementation changes is that shouldBuildLookupTablesForConstant() no longer gets called on the original constant, only on the stripped one. It looks like only ARM uses this hook and wouldn't be affected by the change (because the stripped bitcasts/GEPs do not affect whether the constant requires relocation), but I think it would be in the spirit of the hook to continue calling it on the original constant.
Good point. I will update to account for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109565



More information about the llvm-commits mailing list