OSDN Git Service

[InstCombine] Simplify pointer difference subtractions (GEP-GEP) where GEPs have...
authorHiroshi Yamauchi <yamauchi@google.com>
Thu, 27 Jul 2017 18:27:11 +0000 (18:27 +0000)
committerHiroshi Yamauchi <yamauchi@google.com>
Thu, 27 Jul 2017 18:27:11 +0000 (18:27 +0000)
commitd3335c2a9e1956563f97d63e8fc2b4309821d899
tree85798df477a5ac68fb701d0b3df073226bdfd135
parent91b875c229dd68e4ee8a8d86c230ed0aeda17a5b
[InstCombine] Simplify pointer difference subtractions (GEP-GEP) where GEPs have other uses and one non-constant index

Summary:
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.

Reviewers: sanjoy, bkramer

Reviewed By: sanjoy

Subscribers: mcrosier, llvm-commits

Differential Revision: https://reviews.llvm.org/D35499

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309304 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/Operator.h
lib/Transforms/InstCombine/InstCombineAddSub.cpp
test/Transforms/InstCombine/sub.ll