This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by hjyamauchi on Jul 14 2017, 6:39 PM.

Details

Reviewers
None
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.

Diff Detail

Event Timeline

hjyamauchi created this revision.Jul 14 2017, 6:39 PM
hjyamauchi edited the summary of this revision. (Show Details)Jul 14 2017, 6:42 PM