[PATCH] D139415: [RFC][WebAssembly] Optimize GEPs

Thomas Lively via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 9 07:44:11 PST 2022


tlively added inline comments.


================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyOptimizeGEPs.cpp:11
+/// Optimize inbounds GetElemenPtr instructions so that LoopStrengthReduce and
+/// ScalarEvolutionExpander don't make modifications to the IR which loose the
+/// inbounds information.
----------------



================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyOptimizeGEPs.cpp:15
+/// To use immediate address offsets, the add operations need to be marked as
+/// nuw due to WebAssemblys infinite precision address offset calculation.
+/// Unfortunately, the inbounds information is easily lost when converting
----------------



================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyOptimizeGEPs.cpp:109
+  IntegerType *ArithTy = nullptr;
+  SmallVector<BaseOffsetPair, 4> BasePairs;
+  DenseMap<BaseOffsetPair, SmallVector<RebaseCandidate, 4>> Candidates;
----------------
Do we need `BasePairs`? It looks like we could remove it if we iterate through the `Candidates` keys instead.


================
Comment at: llvm/test/CodeGen/WebAssembly/optimize-geps.ll:6
+
+define hidden void @one_dim(ptr nocapture noundef readonly %arg, ptr nocapture noundef readonly %arg1, ptr nocapture noundef writeonly %arg2) {
+; CHECK-LABEL: @one_dim(
----------------
samparker wrote:
> tlively wrote:
> > Would it be possible to have a smaller test case? It's hard to tell what to look at here.
> Yeah, if I remove one array and move to i32 this should hopefully half the size.
Thanks! Could you also add comments in the test input pointing out where interesting things happen?


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

https://reviews.llvm.org/D139415



More information about the llvm-commits mailing list