[PATCH] D129734: [InstCombine] Canonicalize GEP of GEP by swapping constant-indexed GEP to the front

William Junda Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 00:15:35 PDT 2022


huangjd added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:1981
 
-  // Note that if our source is a gep chain itself then we wait for that
-  // chain to be resolved before we perform this transformation.  This
----------------
Apparently this statement actually causes a bug, which inhibits merging of constant-index GEP  in vector-reverse-mask4.ll and interleaved-accesses.ll


================
Comment at: llvm/test/Transforms/InstCombine/gep-canonicalize-constant-indices.ll:27
 
-; GEP with the last index being a constant should also be swapped.
-define ptr @partialConstant1(ptr %p, i64 %a, i64 %b) {
----------------
test is no longer relevant since we are swapping constant-indexed GEP to the front


================
Comment at: llvm/test/Transforms/InstCombine/gep-canonicalize-constant-indices.ll:52
 
-; Multiple constant-indexed GEP. Note that the first two cannot be merged at
-; first, but after the second and third are merged, the result can be merged
-; with the first one on the next pass.
-; result = (<3 x i32>*) ((i16*) ((i8*) ptr + a) + (a * b)) + 9
+; Multiple constant-indexed GEP. All constant-index GEP will eventually be
+; swapped to the front and merged.
----------------
Simplified unnecessarily complicated test 


================
Comment at: llvm/test/Transforms/InstCombine/gep-canonicalize-constant-indices.ll:55
+; result = (i16*) (((i8*) p + 25) + a) + b
 define ptr @nested(ptr %p, i64 %a, i64 %b) {
 ; CHECK-LABEL: @nested(
----------------
C


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129734



More information about the llvm-commits mailing list