[PATCH] D125070: [InstCombine] Simplify chain of GEP with constant indices

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 13:39:17 PDT 2022


davidxl added a comment.

Perhaps split out part of the patch that handles the following and then work on a patch to do reassociation (nikic's comment)

; result = (struct.C*) p + 3
define %struct.C* @offsetDivisible(i64* %p) {
; CHECK-LABEL: @offsetDivisible(
; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 3
; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr inbounds [[STRUCT_C:%.*]], ptr [[TMP1]], i64 1
; CHECK-NEXT:    ret ptr [[TMP2]]
;

  %1 = getelementptr inbounds i64, i64* %p, i64 3
  %2 = getelementptr inbounds %struct.C, %struct.C* %1, i64 1
  ret %struct.C* %2

}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125070



More information about the llvm-commits mailing list