[PATCH] D35499: [InstCombine] Simplify pointer difference subtractions (GEP-GEP) where GEPs have other uses and one non-constant index

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 17 12:24:48 PDT 2017


yamauchi created this revision.

Pointer difference simplifications currently happen only if input GEPs don't have other uses or their indexes are all constants, to avoid duplicating indexing arithmetic.

This patch enables cases with exactly one non-constant index among input GEPs to happen where there is no duplicated arithmetic or code size increase even if input GEPs have other uses.

For example, this patch allows "(&A[42][i]-&A[42][0])" --> "i", which didn't happen previously, if the input GEP(s) have other uses.


https://reviews.llvm.org/D35499

Files:
  include/llvm/IR/Operator.h
  lib/Transforms/InstCombine/InstCombineAddSub.cpp
  test/Transforms/InstCombine/sub.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35499.106918.patch
Type: text/x-patch
Size: 6970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170717/1b4998a1/attachment.bin>


More information about the llvm-commits mailing list