Go to file
Silviu Baranga f29dfd36bb Re-commit r257064, after it was reverted in r257340.
This contains a fix for the issue that caused the revert:
we no longer assume that we can insert instructions after the
instruction that produces the base pointer. We previously
assumed that this would be ok, because the instruction produces
a value and therefore is not a terminator. This is false for invoke
instructions. We will now insert these new instruction directly
at the location of the users.

Original commit message:

[InstCombine] Look through PHIs, GEPs, IntToPtrs and PtrToInts to expose more constants when comparing GEPs

Summary:
When comparing two GEP instructions which have the same base pointer
and one of them has a constant index, it is possible to only compare
indices, transforming it to a compare with a constant. This removes
one use for the GEP instruction with the constant index, can reduce
register pressure and can sometimes lead to removing the comparisson
entirely.

InstCombine was already doing this when comparing two GEPs if the base
pointers were the same. However, in the case where we have complex
pointer arithmetic (GEPs applied to GEPs, PHIs of GEPs, conversions to
or from integers, etc) the value of the original base pointer will be
hidden to the optimizer and this transformation will be disabled.

This change detects when the two sides of the comparison can be
expressed as GEPs with the same base pointer, even if they don't
appear as such in the IR. The transformation will convert all the
pointer arithmetic to arithmetic done on indices and all the relevant
uses of GEPs to GEPs with a common base pointer. The GEP comparison
will be converted to a comparison done on indices.

Reviewers: majnemer, jmolloy

Subscribers: hfinkel, jevinskie, jmolloy, aadg, llvm-commits

Differential Revision: http://reviews.llvm.org/D15146

llvm-svn: 257897
2016-01-15 15:52:05 +00:00
clang [analyzer] Provide .def-files and visitors for SVal/SymExpr/MemRegion, v2. 2016-01-15 15:22:05 +00:00
clang-tools-extra Teach clang-tidy how to upgrade warnings into errors. 2016-01-13 17:36:41 +00:00
compiler-rt [tsan] Fix some tiny errors. 2016-01-15 06:21:46 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc AMDGPU: Add aliases for all VI targets 2015-12-15 18:37:04 +00:00
libcxx Tame a -Wunknown-attributes warning 2016-01-13 23:27:08 +00:00
libcxxabi Revert r256322 (and follow-up 256323), the test it added does not pass on OS X. 2016-01-15 15:44:14 +00:00
libunwind Replace cmake check for printf with a check for fopen. 2015-12-10 00:47:08 +00:00
lld Reapply r257753 with fix: 2016-01-15 13:34:52 +00:00
lldb The ASAN report fetching code had two latent bugs: 2016-01-15 01:03:50 +00:00
llgo [llgo] Force exporting __morestack from llgoi 2015-11-27 04:46:46 +00:00
llvm Re-commit r257064, after it was reverted in r257340. 2016-01-15 15:52:05 +00:00
openmp Don't use __DATE__ or __TIME__; it breaks release builds (PR26145) 2016-01-14 23:18:20 +00:00
polly Add option to update-isl.sh for specific commit 2016-01-15 15:41:59 +00:00