History log of /external/llvm/lib/Analysis/InstructionSimplify.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
f89de816ae5cf2d0dad7869882dd626532b934ef 07-Feb-2013 Michael Ilseman <milseman@apple.com> Identify and simplify idempotent intrinsics. Test case included.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174650 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
d9f32c20da9de8798284a8007662c6557560c876 01-Feb-2013 Benjamin Kramer <benny.kra@googlemail.com> InstSimplify: stripAndComputeConstantOffsets can be called with vectors of pointers too.

Prepare it for vectors of pointers and handle simple cases. We don't handle
complicated cases because accumulateConstantOffset bails on pointer vectors.
Fixes selfhost on i386.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174179 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
901261d558d0b41ba75d8aa2b38aac72aaa41bae 01-Feb-2013 Dan Gohman <dan433584@gmail.com> Add a comment explaining an unavailable optimization.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174131 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
fdd1eafe867734df285bbdb01cf1d21f63716798 01-Feb-2013 Dan Gohman <dan433584@gmail.com> Rewrite instsimplify's handling if icmp on pointer values to remove the
remaining use of AliasAnalysis concepts such as isIdentifiedObject to
prove pointer inequality.

@external_compare in test/Transforms/InstSimplify/compare.ll shows a simple
case where a noalias argument can be equal to a global variable address, and
while AliasAnalysis can get away with saying that these pointers don't alias,
instsimplify cannot say that they are not equal.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174122 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
ac08785edaac826afe11a4e596a46fc693848848 01-Feb-2013 Dan Gohman <dan433584@gmail.com> An alloca can be equal to an argument. It can't *alias* an alloca, but it could
be equal, since there's nothing preventing a caller from correctly predicting
the stack location of an alloca.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174119 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
3e3de565e9c7258fb97773b3a64fc091355cb2de 31-Jan-2013 Dan Gohman <dan433584@gmail.com> Change stripAndComputeConstantOffsets to accept a NULL DataLayout pointer
as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174030 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
819f9d6bf91c439967ef623d0c047e7f672683fa 31-Jan-2013 Dan Gohman <dan433584@gmail.com> Add a comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174028 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
5f1686f0b0c38b8b9482fbfec21bf5138c27bd0a 31-Jan-2013 Dan Gohman <dan433584@gmail.com> Minor code simplification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174005 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
f2335dcb17784148c4d8dd23093ab549153cc132 31-Jan-2013 Dan Gohman <dan433584@gmail.com> stripAndComputeConstantOffsets is only called on pointers; check this
with an assert instead of failing and requiring callers to check for failure.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173998 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
0b8c9a80f20772c3793201ab5b251d3520b9cea3 02-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Move all of the header files which are involved in modelling the LLVM IR
into their new header subdirectory: include/llvm/IR. This matches the
directory structure of lib, and begins to correct a long standing point
of file layout clutter in LLVM.

There are still more header files to move here, but I wanted to handle
them in separate commits to make tracking what files make sense at each
layer easier.

The only really questionable files here are the target intrinsic
tablegen files. But that's a battle I'd rather not fight today.

I've updated both CMake and Makefile build systems (I think, and my
tests think, but I may have missed something).

I've also re-sorted the includes throughout the project. I'll be
committing updates to Clang, DragonEgg, and Polly momentarily.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
a84e7508ebcfe2eacdf8153bd83fa63eebe75aea 28-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Nuke some dead code that snuck in some how. I thought I had already
deleted this, but apparantly not. Charmingly, Clang didn't warn on it
but GCC did.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171197 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
e949aa1c91132094a9073c82a8aef729fa8c9eca 28-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Teach instsimplify to use the constant folder where appropriate for
constant folding calls. Add the initial tests for this which show that
now instsimplify can simplify blindingly obvious code patterns expressed
with both intrinsics and library calls.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171194 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c98bd9f1a79adffe73acd337b6f7f9afa6bae078 28-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Add entry points to instsimplify for simplifying calls. The entry points
are nice and decomposed so that we can simplify synthesized calls as
easily as actually call instructions. The internal utility still has the
same behavior, it just now operates on a more generic interface so that
I can extend the set of call simplifications that instsimplify knows
about.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171189 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
dbaa2376f7b3c027e895ff4bee3ae08351f3ea88 13-Dec-2012 Rafael Espindola <rafael.espindola@gmail.com> Rename isPowerOfTwo to isKnownToBeAPowerOfTwo.

In a previous thread it was pointed out that isPowerOfTwo is not a very precise
name since it can return false for powers of two if it is unable to show that
they are powers of two.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170093 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
b09c146b116359616f6cbd4c8b3328607e00ff42 12-Dec-2012 Rafael Espindola <rafael.espindola@gmail.com> The TargetData is not used for the isPowerOfTwo determination. It has never
been used in the first place. It simply was passed to the function and to the
recursive invocations. Simply drop the parameter and update the callers for the
new signature.

Patch by Saleem Abdulrasool!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169988 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
d0a0d221da55f5e2d97909991d77e7ab91e75426 12-Dec-2012 Michael Ilseman <milseman@apple.com> Have SimplifyBinOp call the new FAdd/FSub/FMul helpers, with fast-math flags off


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169943 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
09ee250e728ccdb7afc6354d777f8319c5a0465c 12-Dec-2012 Michael Ilseman <milseman@apple.com> Added a slew of SimplifyInstruction floating-point optimizations, many of which take advantage of fast-math flags. Test cases included.

fsub X, +0 ==> X
fsub X, -0 ==> X, when we know X is not -0
fsub +/-0.0, (fsub -0.0, X) ==> X
fsub nsz +/-0.0, (fsub +/-0.0, X) ==> X
fsub nnan ninf X, X ==> 0.0
fadd nsz X, 0 ==> X
fadd [nnan ninf] X, (fsub [nnan ninf] 0, X) ==> 0
where nnan and ninf have to occur at least once somewhere in this expression
fmul X, 1.0 ==> X



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169940 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
7550f96b2f3a5e187f737ddad45563962fbd509c 11-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Holding my nose and moving the accumulation routine to GEPOperator
instead of the instruction. I've left a forwarding wrapper for the
instruction so users with the instruction don't need to create
a GEPOperator themselves.

This lets us remove the copy of this code in instsimplify.

I've looked at most of the other copies of similar code, and this is the
only one I've found that is actually exactly the same. The one in
InlineCost is very close, but it requires re-mapping non-constant
indices through the cost analysis value simplification map. I could add
direct support for this to the generic routine, but it seems overly
specific.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169853 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
1638b839090a35adcd5a4b4cc0a649352276e703 09-Dec-2012 Michael Ilseman <milseman@apple.com> Reorganize FastMathFlags to be a wrapper around unsigned, and streamline some interfaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169712 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
d04a8d4b33ff316ca4cf961e06c9e312eff8e64f 03-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Use the new script to sort the includes of every file under lib.

Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
eb61c920f12cacee38815bf10821d2f294b66f3a 27-Nov-2012 Michael Ilseman <milseman@apple.com> Fast-math optimization: fold multiply by zero

Added in first optimization using fast-math flags to serve as an example for following optimizations. SimplifyInstruction will now try to optimize an fmul observing its FastMathFlags to see if it can fold multiply by zero when 'nnan' and 'nsz' flags are set.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168648 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
4f0dfbb454ea8110459e2d1ee5f92e74cb3e8a5c 16-Nov-2012 Duncan Sands <baldrick@free.fr> Make this easier to understand, as suggested by Chandler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168196 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
aceb03eb58778ae4a2811d2c2bbd23e0e0cf49b5 16-Nov-2012 Duncan Sands <baldrick@free.fr> InstructionSimplify should be able to simplify A+B==B+A to 'true'
but wasn't due to the same logic bug that caused PR14361.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168186 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
426c2bf5cdd2173e4a33aea8cb92cf684a724f4b 01-Nov-2012 Chandler Carruth <chandlerc@gmail.com> Revert the majority of the next patch in the address space series:

r165941: Resubmit the changes to llvm core to update the functions to
support different pointer sizes on a per address space basis.

Despite this commit log, this change primarily changed stuff outside of
VMCore, and those changes do not carry any tests for correctness (or
even plausibility), and we have consistently found questionable or flat
out incorrect cases in these changes. Most of them are probably correct,
but we need to devise a system that makes it more clear when we have
handled the address space concerns correctly, and ideally each pass that
gets updated would receive an accompanying test case that exercises that
pass specificaly w.r.t. alternate address spaces.

However, from this commit, I have retained the new C API entry points.
Those were an orthogonal change that probably should have been split
apart, but they seem entirely good.

In several places the changes were very obvious cleanups with no actual
multiple address space code added; these I have not reverted when
I spotted them.

In a few other places there were merge conflicts due to a cleaner
solution being implemented later, often not using address spaces at all.
In those cases, I've preserved the new code which isn't address space
dependent.

This is part of my ongoing effort to clean out the partial address space
code which carries high risk and low test coverage, and not likely to be
finished before the 3.2 release looms closer. Duncan and I would both
like to see the above issues addressed before we return to these
changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167222 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
ece6c6bb6329748b92403c06ac87f45c43485911 01-Nov-2012 Chandler Carruth <chandlerc@gmail.com> Revert the series of commits starting with r166578 which introduced the
getIntPtrType support for multiple address spaces via a pointer type,
and also introduced a crasher bug in the constant folder reported in
PR14233.

These commits also contained several problems that should really be
addressed before they are re-committed. I have avoided reverting various
cleanups to the DataLayout APIs that are reasonable to have moving
forward in order to reduce the amount of churn, and minimize the number
of commits that were reverted. I've also manually updated merge
conflicts and manually arranged for the getIntPtrType function to stay
in DataLayout and to be defined in a plausible way after this revert.

Thanks to Duncan for working through this exact strategy with me, and
Nick Lewycky for tracking down the really annoying crasher this
triggered. (Test case to follow in its own commit.)

After discussing with Duncan extensively, and based on a note from
Micah, I'm going to continue to back out some more of the more
problematic patches in this series in order to ensure we go into the
LLVM 3.2 branch with a reasonable story here. I'll send a note to
llvmdev explaining what's going on and why.

Summary of reverted revisions:

r166634: Fix a compiler warning with an unused variable.
r166607: Add some cleanup to the DataLayout changes requested by
Chandler.
r166596: Revert "Back out r166591, not sure why this made it through
since I cancelled the command. Bleh, sorry about this!
r166591: Delete a directory that wasn't supposed to be checked in yet.
r166578: Add in support for getIntPtrType to get the pointer type based
on the address space.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167221 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
b52fb876171e3670e7307fda4459ca005d49d9f5 24-Oct-2012 Micah Villmow <villmow@gmail.com> Add some cleanup to the DataLayout changes requested by Chandler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166607 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
aa76e9e2cf50af190de90bc778b7f7e42ef9ceff 24-Oct-2012 Micah Villmow <villmow@gmail.com> Add in support for getIntPtrType to get the pointer type based on the address space.
This checkin also adds in some tests that utilize these paths and updates some of the
clients.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166578 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
2c39b15073db81d93bb629303915b7d7e5d088dc 15-Oct-2012 Micah Villmow <villmow@gmail.com> Resubmit the changes to llvm core to update the functions to support different pointer sizes on a per address space basis.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165941 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
fb384d61c78b60787ed65475d8403aee65023962 11-Oct-2012 Micah Villmow <villmow@gmail.com> Revert 165732 for further review.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165747 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
f3840d2c16a4ec4c879a8ded402835746de380f8 11-Oct-2012 Micah Villmow <villmow@gmail.com> Add in the first iteration of support for llvm/clang/lldb to allow variable per address space pointer sizes to be optimized correctly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165726 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
3574eca1b02600bac4e625297f4ecf745f4c4f32 08-Oct-2012 Micah Villmow <villmow@gmail.com> Move TargetData to DataLayout.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165402 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
94c22716d60ff5edf6a98a3c67e0faa001be1142 27-Sep-2012 Sylvestre Ledru <sylvestre@debian.org> Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164768 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
7e2c793a2b5c746344652b6579e958ee42fafdcc 27-Sep-2012 Sylvestre Ledru <sylvestre@debian.org> Fix a typo 'iff' => 'if'

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164767 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
961e1acfb275613679c0d00d4a0b4ed394b51a9d 07-Aug-2012 Chandler Carruth <chandlerc@gmail.com> Fix PR13412, a nasty miscompile due to the interleaved
instsimplify+inline strategy.

The crux of the problem is that instsimplify was reasonably relying on
an invariant that is true within any single function, but is no longer
true mid-inline the way we use it. This invariant is that an argument
pointer != a local (alloca) pointer.

The fix is really light weight though, and allows instsimplify to be
resiliant to these situations: when checking the relation ships to
function arguments, ensure that the argumets come from the same
function. If they come from different functions, then none of these
assumptions hold. All credit to Benjamin Kramer for coming up with this
clever solution to the problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161410 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
9133783d5483e38b16af6c10df7a8bbe655d3446 17-May-2012 Bill Wendling <isanbard@gmail.com> Remove extraneous ';'.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157011 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
89e2b318e2266a7e3fe44151642c1850ec9bd275 28-Mar-2012 Chad Rosier <mcrosier@apple.com> Revert r153521 as it's causing large regressions on the nightly testers.
Original commit message for r153521 (aka r153423):
Use the new range metadata in computeMaskedBits and add a new optimization to
instruction simplify that lets us remove an and when loding a boolean value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153587 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
d23a64cc164529739adaedb397e6279269f78efb 27-Mar-2012 Chad Rosier <mcrosier@apple.com> Reapply r153423; the original commit was fine. The failing test, distray, had
undefined behavior, which Rafael was kind enough to fix.

Original commit message for r153423:
Use the new range metadata in computeMaskedBits and add a new optimization to
instruction simplify that lets us remove an and when loding a boolean value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153521 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
cde6650bd05a745e78920e1cd508c3899ebbd644 26-Mar-2012 Chad Rosier <mcrosier@apple.com> Revert r153423 as this is causing failures on our internal nightly testers.

Original commit message:
Use the new range metadata in computeMaskedBits and add a new optimization to
instruction simplify that lets us remove an and when loading a boolean value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153452 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
7ddcd35d6beb99118f0b960329b304f9e9a2bf58 26-Mar-2012 Rafael Espindola <rafael.espindola@gmail.com> Use the new range metadata in computeMaskedBits and add a new optimization to
instruction simplify that lets us remove an and when loding a boolean value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153423 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
58725a66c02865686c70132e8b9bd231eb66da63 25-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Teach instsimplify how to simplify comparisons of pointers which are
constant-offsets of a common base using the generic GEP-walking logic
I added for computing pointer differences in the same situation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153419 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
9d9e29b4a83818b066c09c8f832cec7641aa2115 25-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Switch the pointer-difference simplification logic to only work with
inbounds GEPs. This isn't really necessary for simplifying pointer
differences, but I'm planning to re-use the same code to simplify
pointer comparisons where it is necessary. Since real code almost
exclusively uses inbounds GEPs, it doesn't seem worth it to support the
extra complexity of turning it on and off. If anyone would like that
back, feel free to shout. Note that instcombine will still catch any of
these patterns.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153418 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
6231d5be410e2d7967352b29ad01522fda15680d 24-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Try to harden the recursive simplification still further. This is again
spotted by inspection, and I've crafted no test case that triggers it on
my machine, but some of the windows builders are hitting what looks like
memory corruption, so *something* is amiss here.

This patch takes a more generalized approach to eliminating
double-visits. Imagine code such as:

%x = ...
%y = add %x, 1
%z = add %x, %y

You can imagine that if we simplify %x, we would add %y and %z to the
list. If the use-chain order happens to cause us to add them in reverse
order, we could pull %y off first, and simplify it, adding %z to the
list. We now have %z on the list twice, and will reference it after it
is deleted.

Currently, all my test cases happen to not trigger this, likely due to
the use-chain ordering, but there seems no guarantee that such
a situation could not occur, so we should handle it correctly.

Again, if anyone knows how to craft a testcase that actually triggers
this, please let me know.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153397 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c5b785b91c922bbb3d5adb4b042c976bebe00e4d 24-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Don't add the instruction about to be RAUW'ed and erased to the
worklist. This can happen in theory when an instruction uses itself,
such as a PHI node. This was spotted by inspection, and unfortunately
I've not been able to come up with a test case that would trigger it. If
anyone has ideas, let me know...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153396 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
6b980541df5846ad335c377c8803b517968daee2 24-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Refactor the interface to recursively simplifying instructions to be tad
bit simpler by handling a common case explicitly.

Also, refactor the implementation to use a worklist based walk of the
recursive users, rather than trying to use value handles to detect and
recover from RAUWs during the recursive descent. This fixes a very
subtle bug in the previous implementation where degenerate control flow
structures could cause mutually recursive instructions (PHI nodes) to
collapse in just such a way that From became equal to To after some
amount of recursion. At that point, we hit the inf-loop that the assert
at the top attempted to guard against. This problem is defined away when
not using value handles in this manner. There are lots of comments
claiming that the WeakVH will protect against just this sort of error,
but they're not accurate about the actual implementation of WeakVHs,
which do still track RAUWs.

I don't have any test case for the bug this fixes because it requires
running the recursive simplification on unreachable phi nodes. I've no
way to either run this or easily write an input that triggers it. It was
found when using instruction simplification inside the inliner when
running over the nightly test-suite.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153393 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
ff739c1575df58f3926c2f3b6e00a6c45f773523 21-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Teach instsimplify to gracefully degrade in the presence of instructions
not attched to a basic block or function. There are conservatively
correct answers in these cases, and this makes the analysis more useful
in contexts where we have a partially formed bit of IR.

I don't have any way to test this directly... suggestions welcome here,
but I'm not seeing anything sadly. I only found this using a subsequent
patch to the inliner which runs instsimplify on partially inlined
instructions, and even then only on a quite large program. I never got
a reasonable testcase out of it, and anything I do get is likely to be
quite fragile due to requiring an interaction of two different passes,
and the only result being a segfault if it goes wrong.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153176 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
f72e0ca71507ab3d8566148e124fe21f4a051cd1 15-Mar-2012 Duncan Sands <baldrick@free.fr> Type sizes and fields offsets inside structs are unsigned. This is a highly
theoretical fix since it only matters for types with >= 2^63 bits (!) and also
only matters if pointers have more than 64 bits, which is not supported anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152831 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
bd0fe5642544d4ec3aee1ede7af60c006bae5cbf 13-Mar-2012 Duncan Sands <baldrick@free.fr> Generalize the "trunc(ptrtoint(x)) - trunc(ptrtoint(y)) ->
trunc(ptrtoint(x-y))" optimization introduced by Chandler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152626 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
0aa85eb231dc76bcabcd35f6dc9a50536f607df3 13-Mar-2012 Duncan Sands <baldrick@free.fr> Uniformize the InstructionSimplify interface by ensuring that all routines
take a TargetLibraryInfo parameter. Internally, rather than passing TD, TLI
and DT parameters around all over the place, introduce a struct for holding
them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152623 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
5b8f0ddc7e5bc3c7ffe1b2226a8316796f18b90e 13-Mar-2012 Eli Friedman <eli.friedman@gmail.com> Fix regression from r151466: an we can't replace uses of an instruction reachable from the entry block with uses of an instruction not reachable from the entry block. PR12231.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152595 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
90c14fcb7ea3436a8b3053f8a9aa529c03011d34 13-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Address some review comments from Duncan. This moves the iterative
offset accumulation to use a boring APInt instead of ConstantExprs.
I didn't go all the way to an 'int64_t' because I wanted APInt to handle
any magic required to properly wrap the arithmetic when the pointer
width is <64 bits. If there is a significant penalty from using APInt
here, first off WTF, and secondly let me know and I'll do the math by
hand.

I've left one layer still operating w/ ConstantExpr because it makes the
interface quite a bit simpler, and that one isn't iterative so has much
lower cost.

I suppose this may potentially speed up some strang compilation
situations, but I don't really expect much. It should have no functional
impact either way.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152590 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
fc72ae613afd7ca2526bb66156bafe8b0054cb3b 12-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Teach instsimplify how to constant fold pointer differences.

Typically instcombine has handled this, but pointer differences show up
in several contexts where we would like to get constant folding, and
cannot afford to run instcombine. Specifically, I'm working on improving
the constant folding of arguments used in inline cost analysis with
instsimplify.

Doing this in instsimplify implies some algorithm changes. We have to
handle multiple layers of all-constant GEPs because instsimplify cannot
fold them into a single GEP the way instcombine can. Also, we're only
interested in all-constant GEPs. The result is that this doesn't really
replace the instcombine logic, it's just complimentary and focused on
constant folding.

Reviewed on IRC by Benjamin Kramer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152555 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
798d013bcba198af628d2dab8448f709b96e4a75 10-Mar-2012 Bill Wendling <isanbard@gmail.com> As Duncan pointed out, pointers tend not to be in floating point format...for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152499 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c17731d65d2c059a71256ee995cbb057ff28a109 10-Mar-2012 Bill Wendling <isanbard@gmail.com> Make this transformation slightly less agressive and more correct.

The 'CmpInst::isFalseWhenEqual' function returns 'false' for values other than
simply equality. For instance, it returns 'false' for <= or >=. This isn't the
correct behavior for this transformation, which is checking for strict equality
and non-equality. It was causing the gcc.c-torture/execute/frame-address.c test
to fail because it would completely (and incorrectly) optimize a whole function
into a 'ret i32 0'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152497 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
84dfc32ff906271c373819595e60a173624e1184 10-Mar-2012 Chandler Carruth <chandlerc@gmail.com> Refactor some methods to look through bitcasts and GEPs on pointers into
a common collection of methods on Value, and share their implementation.
We had two variations in two different places already, and I need the
third variation for inline cost estimation.

Reviewed by Duncan Sands on IRC, but further comments here welcome.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152490 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
f7087ea5088d58e81f08a3eeb39ba46fa18d0fd4 26-Feb-2012 Nick Lewycky <nicholas@mxc.ca> Reinstate the optimization from r151449 with a fix to not turn 'gep %x' into
'gep null' when the icmp predicate is unsigned (or is signed without inbounds).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151467 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
8c727f9200cd54adc4a1b742950e80035bc53a20 26-Feb-2012 Rafael Espindola <rafael.espindola@gmail.com> Don't call dominates on unreachable instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151466 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
6fd3428afa46ace6712f0649bf4a7bd6799cc355 26-Feb-2012 Nick Lewycky <nicholas@mxc.ca> Roll these back to r151448 until I figure out how they're breaking
MultiSource/Applications/lua.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151463 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
28e215ba63164f201292f8c77bf038b4282aa052 25-Feb-2012 Nick Lewycky <nicholas@mxc.ca> An argument and a local identified object (eg. a noalias call) could turn out
equal if both are null. In the test, scope type %t and global @y by adding a
'gep' prefix to them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151452 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
6bfb9d6a13261948c07599922246ac80e2ba66d0 25-Feb-2012 Nick Lewycky <nicholas@mxc.ca> Fix five-letter typo in comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151450 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
1e4e1c768bcbc548345348c062f402967c78c48a 25-Feb-2012 Nick Lewycky <nicholas@mxc.ca> Teach instsimplify to be more aggressive when analyzing comparisons of pointers
by using llvm::isIdentifiedObject. Also teach it to handle GEPs that have
the same base pointer and constant operands. Fixes PR11238!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151449 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
009e2650d69fe93bda1864340c5f000e56c52fb8 24-Feb-2012 Chris Lattner <sabre@nondot.org> fix PR12075, a regression in a recent transform I added. In unreachable code, gep chains can be infinite. Just like "stripPointerCasts", use a set to keep track of visited instructions so we don't recurse infinitely.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151383 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
b053fc1c92b6b81c47d5e2c092b0f3ea04fd5b87 20-Feb-2012 Chris Lattner <sabre@nondot.org> fold comparisons of gep'd alloca points with null to false,
implementing PR12013. We now compile the testcase to:

__Z4testv: ## @_Z4testv
## BB#0: ## %_ZN4llvm15SmallVectorImplIiE9push_backERKi.exit
pushq %rbx
subq $64, %rsp
leaq 32(%rsp), %rbx
movq %rbx, (%rsp)
leaq 64(%rsp), %rax
movq %rax, 16(%rsp)
movl $1, 32(%rsp)
leaq 36(%rsp), %rax
movq %rax, 8(%rsp)
leaq (%rsp), %rdi
callq __Z1gRN4llvm11SmallVectorIiLj8EEE
movq (%rsp), %rdi
cmpq %rbx, %rdi
je LBB0_2
## BB#1:
callq _free
LBB0_2: ## %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit
addq $64, %rsp
popq %rbx
ret

instead of:

__Z4testv: ## @_Z4testv
## BB#0:
pushq %rbx
subq $64, %rsp
xorl %eax, %eax
leaq (%rsp), %rbx
addq $32, %rbx
movq %rbx, (%rsp)
movq %rbx, 8(%rsp)
leaq 64(%rsp), %rcx
movq %rcx, 16(%rsp)
je LBB0_2
## BB#1:
movl $1, 32(%rsp)
movq %rbx, %rax
LBB0_2: ## %_ZN4llvm15SmallVectorImplIiE9push_backERKi.exit
addq $4, %rax
movq %rax, 8(%rsp)
leaq (%rsp), %rdi
callq __Z1gRN4llvm11SmallVectorIiLj8EEE
movq (%rsp), %rdi
cmpq %rbx, %rdi
je LBB0_4
## BB#3:
callq _free
LBB0_4: ## %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit
addq $64, %rsp
popq %rbx
ret

This doesn't shrink clang noticably though.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150944 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
2c3acb0e273a50a9b4eeaf9d5544f6168bda85a6 18-Feb-2012 Eli Friedman <eli.friedman@gmail.com> Fix a rather nasty regression from r150690: LHS != RHS does not imply LHS->stripPointerCasts() != RHS->stripPointerCasts().



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150863 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
ea79b8e03ca7c7be72832c11e9d4d78f11b728b3 16-Feb-2012 Benjamin Kramer <benny.kra@googlemail.com> Revert "InstSimplify: Strip pointer casts early."

Turns out this isn't safe, because the code below depends on LHS and RHS having
the same type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150695 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
475ebf5a74c0c5d0faf37b943ac871ad0f5d5677 16-Feb-2012 Benjamin Kramer <benny.kra@googlemail.com> InstSimplify: Strip pointer casts early.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150694 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
fd8779a94be48aba47569dd28cb56563d4cbbfa4 16-Feb-2012 Benjamin Kramer <benny.kra@googlemail.com> InstSimplify: Ignore pointer casts when constant folding compares between pointers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150690 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
aa97bb54f02784abefa0ae170af5937915bdb329 10-Feb-2012 Duncan Sands <baldrick@free.fr> Fix PR11948: the result type of an icmp may be a vector of boolean -
don't assume it is a boolean.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150247 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
858143816d43e58b17bfd11cb1b57afbd7f0f893 07-Feb-2012 Craig Topper <craig.topper@gmail.com> Convert assert(0) to llvm_unreachable

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149967 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
55c6d57734cd2f141dc2d6912fc22746d5eeae54 01-Jan-2012 Benjamin Kramer <benny.kra@googlemail.com> PatternMatch: Introduce a matcher for instructions with the "exact" bit. Use it to simplify a few matchers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147403 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
1608769abeb1430dc34f31ffac0d9850f99ae36a 05-Dec-2011 Nadav Rotem <nadav.rotem@intel.com> Add support for vectors of pointers.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145801 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
618c1dbd293d15ee19f61b1156ab8086ad28311a 01-Dec-2011 Chad Rosier <mcrosier@apple.com> Propagate TargetLibraryInfo throughout ConstantFolding.cpp and
InstructionSimplify.cpp. Other fixups as needed.
Part of rdar://10500969

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145559 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
66d004ef708642bbdc38fd761507f2e9ee3970cd 01-Dec-2011 Nick Lewycky <nicholas@mxc.ca> Make use of "getScalarType()". No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145556 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
7781ae5be570940178295f6f808215089a3fe411 08-Nov-2011 Eli Friedman <eli.friedman@gmail.com> Fix code to match comment. Fixes PR11340, a regression from r143209.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144121 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
71d050315704c23b235594d3fad5268c12d825e3 04-Nov-2011 Dan Gohman <gohman@apple.com> Teach instsimplify to simplify calls to undef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143719 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
6dc9e2bf7455fa1494078d5d52f1363b05183f20 30-Oct-2011 Duncan Sands <baldrick@free.fr> Reapply commit 143214 with a fix: m_ICmp doesn't match conditions
with the given predicate, it matches any condition and returns the
predicate - d'oh! Original commit message:
The expression icmp eq (select (icmp eq x, 0), 1, x), 0 folds to false.
Spotted by my super-optimizer in 186.crafty and 450.soplex. We really
need a proper infrastructure for handling generalizations of this kind
of thing (which occur a lot), however this case is so simple that I decided
to go ahead and implement it directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143318 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
09c3253d3034ac8ed31f04d21181004827224d47 29-Oct-2011 Eli Friedman <eli.friedman@gmail.com> Revert r143214; it's breaking a bunch of stuff.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143265 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
012f8547f70c7cefe552282f28581a434ebe7324 28-Oct-2011 Duncan Sands <baldrick@free.fr> The expression icmp eq (select (icmp eq x, 0), 1, x), 0 folds to false.
Spotted by my super-optimizer in 186.crafty and 450.soplex. We really
need a proper infrastructure for handling generalizations of this kind
of thing (which occur a lot), however this case is so simple that I decided
to go ahead and implement it directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143214 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c65c747bc4ee7d3ca8463d33708bbb2aed38a809 28-Oct-2011 Duncan Sands <baldrick@free.fr> Fold icmp ugt (udiv X, Y), X to false. Spotted by my super-optimizer
in 186.crafty.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143209 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
32a43cc0fc3cd42702d7859eaa58dd42f561a54d 27-Oct-2011 Duncan Sands <baldrick@free.fr> Reapply commit 143028 with a fix: the problem was casting a ConstantExpr Mul
using BinaryOperator (which only works for instructions) when it should have
been a cast to OverflowingBinaryOperator (which also works for constants).
While there, correct a few other dubious looking uses of BinaryOperator.
Thanks to Chad Rosier for the testcase. Original commit message:
My super-optimizer noticed that we weren't folding this expression to
true: (x *nsw x) sgt 0, where x = (y | 1). This occurs in 464.h264ref.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143125 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
dd3149d57977d0632cfaf24290dd93416fb2a0ef 26-Oct-2011 Duncan Sands <baldrick@free.fr> The maximum power of 2 dividing a power of 2 is itself. This occurs
in 403.gcc and was spotted by my super-optimizer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143054 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
ae707bd5594e52a8b385760f99ff58aa8fede948 05-Sep-2011 Benjamin Kramer <benny.kra@googlemail.com> InstSimplify: Don't try to replace an extractvalue/insertvalue pair with the original value if types don't match.

Fixes clang selfhost.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139120 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
dabc2806726a286b00313419fac8461ebe0f774c 05-Sep-2011 Duncan Sands <baldrick@free.fr> Add some simple insertvalue simplifications, for the purpose of cleaning
up do-nothing exception handling code produced by dragonegg.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139113 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
f23d4adbfaf870d5fa67c6bff0da7891d3a98f9d 17-Aug-2011 Eli Friedman <eli.friedman@gmail.com> Revert r137781; I agree with Duncan's comment that the situation in question is clearly impossible given the current structure of the code.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137853 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
207634263c6a5271d6a10f802c4970ffcd34d271 17-Aug-2011 Eli Friedman <eli.friedman@gmail.com> Extend the undef ^ undef idiom once more. No testcase: I can't figure out how to actually trigger the codepath in question at the moment, but it might get exposed in the future.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137781 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c9d904ee2ca36ab6238ed93c7ad2ea67b5fd0a23 04-Aug-2011 Duncan Sands <baldrick@free.fr> Fix what seems an obvious typo. Patch by Ivan Krasin. Problem
reported at http://habrahabr.ru/blogs/compilers/125626/.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136865 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
f56138d4aeb6d271cb353d70a794fa1525d892c3 26-Jul-2011 Duncan Sands <baldrick@free.fr> Add helper function for getting true/false constants in a uniform
way for i1 and vector of i1 types. Use these to make some code
more self-documenting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136079 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
a9203109f4ac95aa7e9624f2838e3d89623ec902 25-Jul-2011 Jay Foad <jay.foad@gmail.com> Convert GetElementPtrInst to use ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135904 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
dab3d29605a5c83db41b28176273ef55961120c1 21-Jul-2011 Jay Foad <jay.foad@gmail.com> Convert ConstantExpr::getGetElementPtr and
ConstantExpr::getInBoundsGetElementPtr to use ArrayRef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135673 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
b9b54ebfed02f0654897d37e8a4448d3f8087558 19-Jul-2011 Jay Foad <jay.foad@gmail.com> Convert SimplifyGEPInst to use ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135482 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
1d2f569c3428d70d0cf690c9adb459ad4a3ecff2 19-Jul-2011 Jay Foad <jay.foad@gmail.com> Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135477 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
db125cfaf57cc83e7dd7453de2d509bc8efd0e5e 18-Jul-2011 Chris Lattner <sabre@nondot.org> land David Blaikie's patch to de-constify Type, with a few tweaks.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
68c0dbc14fb7599987fb3e27be4e12c1ac36535e 01-Jul-2011 Dan Gohman <gohman@apple.com> Improve constant folding of undef for cmp and select operators.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134223 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
e864b5b840c58d0b04324082ec94a7156743ed60 07-May-2011 Duncan Sands <baldrick@free.fr> The comparision "max(x,y)==x" is equivalent to "x>=y". Since the max is
often expressed as "x >= y ? x : y", there is a good chance we can extract
the existing "x >= y" from it and use that as a replacement for "max(x,y)==x".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131049 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
b6e7cd655c6ee119dbeacc321ee92387f983edb0 05-May-2011 Eli Friedman <eli.friedman@gmail.com> PR9838: Fix transform introduced in r127064 to not trigger when only one side of the icmp is an exact shift.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130954 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
8140ad32ce45281ed2bc4f6ca388a6ed9f806550 04-May-2011 Duncan Sands <baldrick@free.fr> Add variations on: max(x,y) >= min(x,z) folds to true. This isn't that common,
but according to my super-optimizer there are only two missed simplifications
of -instsimplify kind when compiling bzip2, and this is one of them. It amuses
me to have bzip2 be perfectly optimized as far as instsimplify goes!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130840 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
ad20681cdeaf72383891b153b925624aa585be4d 03-May-2011 Duncan Sands <baldrick@free.fr> Implement some basic simplifications involving min/max, for example
max(a,b) >= a -> true. According to my super-optimizer, these are
by far the most common simplifications (of the -instsimplify kind)
that occur in the testsuite and aren't caught by -std-compile-opts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130780 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
448a6d3cc23f2a249778bb341ae26589568efdf8 02-May-2011 Duncan Sands <baldrick@free.fr> Fix PR9579: when simplifying a compare to "true" or "false", and it was
a vector compare, generate a vector result rather than i1 (and crashing).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130706 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
f24ed77d2416b66178d8ff1d807858dfab37ca18 02-May-2011 Duncan Sands <baldrick@free.fr> Move some rem transforms out of instcombine and into instsimplify.
This automagically provides a transform noticed by my super-optimizer
as occurring quite often: "rem x, (select cond, x, 1)" -> 0.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130694 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
562b84b3aea359d1f918184e355da82bf05eb290 11-Apr-2011 Jay Foad <jay.foad@gmail.com> Don't include Operator.h from InstrTypes.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129271 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
a0e2f38b25ce7c51c22ed40d8a315fe1dd98926d 09-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Fix two cases I forgot to update when doing a mental "getSwappedPredicate".
Thanks Duncan Sands!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127323 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
84dd4fa2e36f72050f5c46577359f5df0467e3e4 09-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Add another micro-optimization. Apologies for the lack of refactoring, but I
gave up when I realized I couldn't come up with a good name for what the
refactored function would be, to describe what it does.

This is PR9343 test12, which is test3 with arguments reordered. Whoops!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127318 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
58bfcdbcf6a7c1cac0187f7c6beb3afe9d8f5411 05-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Thread comparisons over udiv/sdiv/ashr/lshr exact and lshr nuw/nsw whenever
possible. This goes into instcombine and instsimplify because instsimplify
doesn't need to check hasOneUse since it returns (almost exclusively) constants.

This fixes PR9343 #4 #5 and #8!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127064 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
e2ee753bc440d373717b8fd06c062d50f1005268 04-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Revert broken srem logic from r126991.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127021 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
786792784e898f29febb3e7270d54b0e21e3c904 04-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Fold "icmp pred (srem X, Y), Y" like we do for urem. Handle signed comparisons
in the urem case, though not the other way around. This is enough to get #3 from
PR9343!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126991 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
3a73e343d02ba3a00adf03311183cc0ccc960978 04-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Teach instruction simplify to use constant ranges to solve problems of the form
"icmp pred %X, CI" and a number of examples where "%X = binop %Y, CI2".

Some of these cases (div and rem) used to make it through opt -O2, but the
others are probably now making code elsewhere redundant (probably instcombine).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126988 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
88cd0aadb2849a259e8656b0ff8439ef660db7c5 01-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Optimize "icmp pred (urem X, Y), Y" --> true/false depending on pred. There's
more work to do here, "icmp ult (urem X, 10), 11" doesn't optimize away yet.
Fixes example 3 from PR9343!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126741 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
38f7f66fcc6ed5e43be4d9c96c782d4eabdb7342 20-Feb-2011 Benjamin Kramer <benny.kra@googlemail.com> Move "A | ~(A & ?) -> -1" from InstCombine to InstructionSimplify.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126082 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
5380d280702423990e37d0dac05c76a35ad31baa 13-Feb-2011 Duncan Sands <baldrick@free.fr> Remove pointless blank line.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125463 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
52fb846578714d14bbde9b28884a6a8729217677 13-Feb-2011 Duncan Sands <baldrick@free.fr> Teach instsimplify that X+Y>=X+Z is the same as Y>=Z if neither side overflows,
plus some variations of this. According to my auto-simplifier this occurs a lot
but usually in combination with max/min idioms. Because max/min aren't handled
yet this unfortunately doesn't have much effect in the testsuite.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125462 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
ffeb98ad3becfbb8e26270ef8751e37e4b6b0cd1 09-Feb-2011 Duncan Sands <baldrick@free.fr> Formatting and comment tweaks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125200 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
81a0dc911586c77421c2255aa417dc9b350b9e20 09-Feb-2011 Chris Lattner <sabre@nondot.org> Teach instsimplify some tricks about exact/nuw/nsw shifts.
improve interfaces to instsimplify to take this info.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125196 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
aeaf3d484b4d4c35e8794378c4b6cfbbde718dd1 09-Feb-2011 Chris Lattner <sabre@nondot.org> Rework InstrTypes.h so to reduce the repetition around the NSW/NUW/Exact
versions of creation functions. Eventually, the "insertion point" versions
of these should just be removed, we do have IRBuilder afterall.

Do a massive rewrite of much of pattern match. It is now shorter and less
redundant and has several other widgets I will be using in other patches.
Among other changes, m_Div is renamed to m_IDiv (since it only matches
integer divides) and m_Shift is gone (it used to match all binops!!) and
we now have m_LogicalShift for the one client to use.

Enhance IRBuilder to have "isExact" arguments to things like CreateUDiv
and reduce redundancy within IRbuilder by having these methods chain to
each other more instead of duplicating code.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125194 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
163a84bbce69947aa314760e6068c704fc0df7a0 07-Feb-2011 Duncan Sands <baldrick@free.fr> Add an m_Div pattern for matching either a udiv or an sdiv and use it
to simplify the "(X/Y)*Y->X when the division is exact" transform.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125004 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c6ee9181a51fdfa3c07e1e53695681c55aa98ce4 06-Feb-2011 Chris Lattner <sabre@nondot.org> teach instsimplify to transform (X / Y) * Y to X
when the div is an exact udiv.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124994 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
479b4b9ef06dd84097202ffa6aea07913cdf651c 05-Feb-2011 Anders Carlsson <andersca@mac.com> Fix another warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124961 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
50ca4d37f7f3b460c6441eb5ad14625a7d86b5d9 03-Feb-2011 Duncan Sands <baldrick@free.fr> Improve threading of comparisons over select instructions (spotted by my
auto-simplifier). This has a big impact on Ada code, but not much else.
Unfortunately the impact is mostly negative! This is due to PR9004 (aka
SCCP failing to resolve conditional branch conditions in the destination
blocks of the branch), in which simple correlated expressions are not
resolved but complicated ones are, so simplifying has a bad effect!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124788 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
4b720718fbda1194f925e0a9d931bc220e8b0e3a 02-Feb-2011 Duncan Sands <baldrick@free.fr> Reenable the transform "(X*Y)/Y->X" when the multiplication is known not to
overflow (nsw flag), which was disabled because it breaks 254.gap. I have
informed the GAP authors of the mistake in their code, and arranged for the
testsuite to use -fwrapv when compiling this benchmark.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124746 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
f9e4a986c03fe3af7dbc9de0b0a9251280fbdf41 01-Feb-2011 Duncan Sands <baldrick@free.fr> Add a m_Undef pattern for convenience. This is so that code that uses
pattern matching can also pattern match undef, creating a more uniform
style.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124657 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
7681c6da606efcc392f76b8acea8301cb5fc7a0a 01-Feb-2011 Duncan Sands <baldrick@free.fr> Have m_One also match constant vectors for which every element is 1.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124655 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
7af00c0f6e4a5612a2438269a6f8a71b0ae9190e 30-Jan-2011 Duncan Sands <baldrick@free.fr> Commit 124487 broke 254.gap. See if disabling the part that might be triggered
by PR9088 fixes things.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124561 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
1895e98ef38afbe011575cc25f4889d96e37421b 30-Jan-2011 Duncan Sands <baldrick@free.fr> Transform (X/Y)*Y into X if the division is exact. Instcombine already knows how
to do this and more, but would only do it if X/Y had only one use. Spotted as the
most common missed simplification in SPEC by my auto-simplifier, now that it knows
about nuw/nsw/exact flags. This removes a bunch of multiplications from 447.dealII
and 483.xalancbmk. It also removes a lot from tramp3d-v4, which results in much
more inlining.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124560 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
5413880654585f01ea9880f24f07f27c8da56ba8 29-Jan-2011 Nick Lewycky <nicholas@mxc.ca> Fix comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124544 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
1fca2c32cc99197215d3fd32a4ad05214c74edd1 29-Jan-2011 Frits van Bommel <fvbommel@gmail.com> Move InstCombine's knowledge of fdiv to SimplifyInstruction().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124534 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
79f4eea7a3375aef93bf0d9fb1785ffee801eb84 28-Jan-2011 Duncan Sands <baldrick@free.fr> This dyn_cast should be a cast. Pointed out by Frits van Bommel.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124497 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
a3e292c7e85efb33899f08238f57a85996a05a0b 28-Jan-2011 Duncan Sands <baldrick@free.fr> Thread divisions over selects and phis. This doesn't fire much and has basically
zero effect on the testsuite (it improves two Ada testcases).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124496 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
593faa53fa6d89841e601cc4571d143a6a05f0b4 28-Jan-2011 Duncan Sands <baldrick@free.fr> My auto-simplifier noticed that ((X/Y)*Y)/Y occurs several times in SPEC
benchmarks, and that it can be simplified to X/Y. (In general you can only
simplify (Z*Y)/Y to Z if the multiplication did not overflow; if Z has the
form "X/Y" then this is the case). This patch implements that transform and
moves some Div logic out of instcombine and into InstructionSimplify.
Unfortunately instcombine gets in the way somewhat, since it likes to change
(X/Y)*Y into X-(X rem Y), so I had to teach instcombine about this too.
Finally, thanks to the NSW/NUW flags, sometimes we know directly that "Z*Y"
does not overflow, because the flag says so, so I added that logic too. This
eliminates a bunch of divisions and subtractions in 447.dealII, and has good
effects on some other benchmarks too. It seems to have quite an effect on
tramp3d-v4 but it's hard to say if it's good or bad because inlining decisions
changed, resulting in massive changes all over.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124487 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
d70d1a5c44609af091f6fc3e29193f9f4756a74f 25-Jan-2011 Duncan Sands <baldrick@free.fr> According to my auto-simplifier the most common missed simplifications in
optimized code are:
(non-negative number)+(power-of-two) != 0 -> true
and
(x | 1) != 0 -> true
Instcombine knows about the second one of course, but only does it if X|1
has only one use. These fire thousands of times in the testsuite.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124183 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
9d32f60a6f7dbd8e83187481cd2ae0a2f3e726ce 20-Jan-2011 Duncan Sands <baldrick@free.fr> At -O123 the early-cse pass is run before instcombine has run. According to my
auto-simplier the transform most missed by early-cse is (zext X) != 0 -> X != 0.
This patch adds this transform and some related logic to InstructionSimplify
and removes some of the logic from instcombine (unfortunately not all because
there are several situations in which instcombine can improve things by making
new instructions, whereas instsimplify is not allowed to do this). At -O2 this
often results in more than 15% more simplifications by early-cse, and results in
hundreds of lines of bitcode being eliminated from the testsuite. I did see some
small negative effects in the testsuite, for example a few additional instructions
in three programs. One program, 483.xalancbmk, got an additional 35 instructions,
which seems to be due to a function getting an additional instruction and then
being inlined all over the place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123911 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
b2f3c383ec62b959ee27d0a5fb890894c4e49e86 18-Jan-2011 Duncan Sands <baldrick@free.fr> For completeness, generalize the (X + Y) - Y -> X transform and add X - (X + 1) -> -1.
These were not recommended by my auto-simplifier since they don't fire often enough.
However they do fire from time to time, for example they remove one subtraction from
the final bitcode for 483.xalancbmk.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123755 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
fe02c69f84ad52d42be934e4fe702f03e4991a6a 18-Jan-2011 Duncan Sands <baldrick@free.fr> Simplify (X<<1)-X into X. According to my auto-simplier this is the most common missed
simplification in fully optimized code. It occurs sporadically in the testsuite, and
many times in 403.gcc: the final bitcode has 131 fewer subtractions after this change.
The reason that the multiplies are not eliminated is the same reason that instcombine
did not catch this: they are used by other instructions (instcombine catches this with
a more general transform which in general is only profitable if the operands have only
one use).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123754 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c087e20331c8a4c3b77d96a73588e80c06d89e3d 14-Jan-2011 Duncan Sands <baldrick@free.fr> Turn X-(X-Y) into Y. According to my auto-simplifier this is the most common
simplification present in fully optimized code (I think instcombine fails to
transform some of these when "X-Y" has more than one use). Fires here and
there all over the test-suite, for example it eliminates 8 subtractions in
the final IR for 445.gobmk, 2 subs in 447.dealII, 2 in paq8p etc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123442 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
cf80bc1d4ac741620641c2bf48c25993bd478bd0 14-Jan-2011 Duncan Sands <baldrick@free.fr> Factorize common code out of the InstructionSimplify shift logic. Add in
threading of shifts over selects and phis while there. This fires here and
there in the testsuite, to not much effect. For example when compiling spirit
it fires 5 times, during early-cse, resulting in 6 more cse simplifications,
and 3 more terminators being folded by jump threading, but the final bitcode
doesn't change in any interesting way: other optimizations would have caught
the opportunity anyway, only later.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123441 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c43cee3fbb3098f0647e50dd2c13bc55b027a228 14-Jan-2011 Duncan Sands <baldrick@free.fr> Move some shift transforms out of instcombine and into InstructionSimplify.
While there, I noticed that the transform "undef >>a X -> undef" was wrong.
For example if X is 2 then the top two bits must be equal, so the result can
not be anything. I fixed this in the constant folder as well. Also, I made
the transform for "X << undef" stronger: it now folds to undef always, even
though X might be zero. This is in accordance with the LangRef, but I must
admit that it is fairly aggressive. Also, I added "i32 X << 32 -> undef"
following the LangRef and the constant folder, likewise fairly aggressive.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123417 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
53ad861193e44454cd3051ddb34fae398827ab6c 13-Jan-2011 Duncan Sands <baldrick@free.fr> Remove some wrong code which fortunately was never executed (as explained in
the comment I added): an extern weak global may have a null address.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123373 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
6dc91253ab1872e118b08511a09d5c934988354e 13-Jan-2011 Duncan Sands <baldrick@free.fr> The most common simplification missed by instsimplify in unoptimized bitcode
is "X != 0 -> X" when X is a boolean. This occurs a lot because of the way
llvm-gcc converts gcc's conditional expressions. Add this, and a few other
similar transforms for completeness.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123372 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
124708d9b47cc53cb11d8bfed75b241b6eec86d4 01-Jan-2011 Duncan Sands <baldrick@free.fr> Revert commit 122654 at the request of Chris, who reckons that instsimplify
is the wrong hammer for this nail, and is probably right.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122661 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
7cf85e74e3885005ca8e5fdb155fa5351e255b85 01-Jan-2011 Duncan Sands <baldrick@free.fr> Fix a README item by having InstructionSimplify do a mild form of value
numbering, in which it considers (for example) "%a = add i32 %x, %y" and
"%b = add i32 %x, %y" to be equal because the operands are equal and the
result of the instructions only depends on the values of the operands.
This has almost no effect (it removes 4 instructions from gcc-as-one-file),
and perhaps slows down compilation: I measured a 0.4% slowdown on the large
gcc-as-one-file testcase, but it wasn't statistically significant.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122654 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
e21083aa3a79506f896d95d7147c3c4627a77ef0 28-Dec-2010 Benjamin Kramer <benny.kra@googlemail.com> Cast away "comparison between signed and unsigned integer" warnings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122598 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
1cd05bb605e3c3eee9197d3f10b628c60d0cc07a 22-Dec-2010 Duncan Sands <baldrick@free.fr> When determining whether the new instruction was already present in
the original instruction, half the cases were missed (making it not
wrong but suboptimal). Also correct a typo (A <-> B) in the second
chunk.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122414 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
a3c44a5280042dbc0cde995675c225ede4528c6e 22-Dec-2010 Duncan Sands <baldrick@free.fr> Add some statistics, good for understanding how much more powerful
instcombine is compared to instsimplify.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122397 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
07f30fbd734069b80b90c6aeea0ae645ce3880c0 21-Dec-2010 Duncan Sands <baldrick@free.fr> While I don't think any later transforms can fire, it seems cleaner to
not assume this (for example in case more transforms get added below
it). Suggested by Frits van Bommel.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122332 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
75d289ed6201e82718343d7a36d2a2fa082f6217 21-Dec-2010 Duncan Sands <baldrick@free.fr> Fix inverted condition noticed by Frits van Bommel.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122331 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
82fdab335881cd90f8f7ab3ad1f1ca0bb3ee886a 21-Dec-2010 Duncan Sands <baldrick@free.fr> Pull a few more simplifications out of instcombine (there are still
plenty left though!), in particular for multiplication.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122330 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
3421d908539cc489d2b1dac67d8cbc07160b01db 21-Dec-2010 Duncan Sands <baldrick@free.fr> Teach InstructionSimplify about distributive laws. These transforms fire
quite often, but don't make much difference in practice presumably because
instcombine also knows them and more.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122328 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
0312a93693abc2eb682b2b101c889959888fd883 21-Dec-2010 Duncan Sands <baldrick@free.fr> Move checking of the recursion limit into the various Thread methods.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122327 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
566edb04b890cebca8f2eefa37af7371a1e756c9 21-Dec-2010 Duncan Sands <baldrick@free.fr> Add generic simplification of associative operations, generalizing
a couple of existing transforms. This fires surprisingly often, for
example when compiling gcc "(X+(-1))+1->X" fires quite a lot as well
as various "and" simplifications (usually with a phi node operand).
Most of the time this doesn't make a real difference since the same
thing would have been done elsewhere anyway, eg: by instcombine, but
there are a few places where this results in simplifications that we
were not doing before.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122326 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
ee9a2e322af96accc9e55ed6373c0057453714b1 20-Dec-2010 Duncan Sands <baldrick@free.fr> Have SimplifyBinOp dispatch Xor, Add and Sub to the corresponding methods
(they had just been forgotten before). Adding Xor causes "main" in the
existing testcase 2010-11-01-lshr-mask.ll to be hugely more simplified.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122245 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
fea3b218d61708ea3577f4ef14c8f7677a94db95 15-Dec-2010 Duncan Sands <baldrick@free.fr> Move Sub simplifications and additional Add simplifications out of
instcombine and into InstructionSimplify.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121861 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
f8b1a5ea9602bb65a5cf59d3d34f2851a08cdc3e 15-Dec-2010 Duncan Sands <baldrick@free.fr> If we detect that the instruction we are simplifying is unreachable, arrange for
it to be replaced by undef rather than not replaced at all, the idea being that
this may reduce the amount of work done by whoever called InstructionSimplify.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121860 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
e89ada98a6ed803ca865843678c4dd4cf77b14ee 29-Nov-2010 Chandler Carruth <chandlerc@gmail.com> Add some dead stores to pacify my least favorite GCC warning: may be
uninitialized. The warning is terrible, has incorrect source locations, and has
a huge false positive rate such as *all* of these.

If anyone has a better solution, please let me know. Alternatively, I'll
happily add -Wno-uninitialized to the -Werror build mode. Maybe I can even do
it *only* when building with GCC instead of Clang.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120281 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
4cd2ad15b43f21d641330b4b09961af08646445e 23-Nov-2010 Duncan Sands <baldrick@free.fr> Expand a little on the description of what InstructionSimplify does.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120016 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
a63395a30f9227bde826749d3480046301b47332 22-Nov-2010 Duncan Sands <baldrick@free.fr> If a GEP index simply advances by multiples of a type of zero size,
then replace the index with zero.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119974 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
85bbff6c94695f07cc1a9765b4d384ed18d2fd7c 22-Nov-2010 Duncan Sands <baldrick@free.fr> Move the "gep undef" -> "undef" transform from instcombine to
InstructionSimplify.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119970 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
e60d79faf7ef7bc4847f9e5d067af00b98dced7b 21-Nov-2010 Duncan Sands <baldrick@free.fr> Add a rather pointless InstructionSimplify transform, inspired by recent constant
folding improvements: if P points to a type of size zero, turn "gep P, N" into "P".
More generally, if a gep index type has size zero, instcombine could replace the
index with zero, but that is not done here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119942 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
87689cfc54993959adb20b89a56bc58aad18ca56 19-Nov-2010 Duncan Sands <baldrick@free.fr> Remove threading of Xor over selects and phis, with an explanation
of why such threading is pointless.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119798 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
2b749870d0488c3b049edf5d0c8875f56f5b1bed 17-Nov-2010 Duncan Sands <baldrick@free.fr> Move some those Xor simplifications which don't require creating new
instructions out of InstCombine and into InstructionSimplify. While
there, introduce an m_AllOnes pattern to simplify matching with integers
and vectors with all bits equal to one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119536 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
d261dc650a01ac5c51ab10f97f1e35aa6a770721 17-Nov-2010 Duncan Sands <baldrick@free.fr> Previously SimplifyInstruction could report that an instruction
simplified to itself (this can only happen in unreachable blocks).
Change it to return null instead. Hopefully this will fix some
buildbot failures.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119490 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
ff10341183adf74760e6118a55cbd1debf50f90f 17-Nov-2010 Duncan Sands <baldrick@free.fr> Fix a layering violation: hasConstantValue, which is part of the PHINode
class, uses DominatorTree which is an analysis. This change moves all of
the tricky hasConstantValue logic to SimplifyInstruction, and replaces it
with a very simple literal implementation. I already taught users of
hasConstantValue that need tricky stuff to use SimplifyInstruction instead.
I didn't update InlineFunction because the IR looks like it might be in a
funky state at the point it calls hasConstantValue, which makes calling
SimplifyInstruction dangerous since it can in theory do a lot of tricky
reasoning. This may be a pessimization, for example in the case where
all phi node operands are either undef or a fixed constant.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119459 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
1845009290e4d804ad377927bd8a08cca3036adc 16-Nov-2010 Duncan Sands <baldrick@free.fr> In which I discover the existence of loops. Threading an operation
over a phi node by applying it to each operand may be wrong if the
operation and the phi node are mutually interdependent (the testcase
has a simple example of this). So only do this transform if it would
be correct to perform the operation in each predecessor of the block
containing the phi, i.e. if the other operands all dominate the phi.
This should fix the FFMPEG snow.c regression reported by İsmail Dönmez.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119347 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
552008946530e01efdad15044e1f621883d14a3a 15-Nov-2010 Duncan Sands <baldrick@free.fr> Teach InstructionSimplify the trick of skipping incoming phi
values that are equal to the phi itself.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119161 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
eff0581583ef10e2872e9baf537a04b67d992101 14-Nov-2010 Duncan Sands <baldrick@free.fr> If dom tree information is available, make it possible to pass
it to get better phi node simplification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119055 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
cd6636c737a82949ad13db2d0d918af6424fb78b 14-Nov-2010 Duncan Sands <baldrick@free.fr> Teach InstructionSimplify about phi nodes. I chose to have it simply
offload the work to hasConstantValue rather than do something more
complicated (such handling mutually recursive phis) because (1) it is
not clear it is worth it; and (2) if it is worth it, maybe such logic
would be better placed in hasConstantValue. Adjust some GVN tests
which are now cleaned up much further (eg: all phi nodes are removed).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119043 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
12a86f5b3199e72e6d967781acc76340f5920e46 14-Nov-2010 Duncan Sands <baldrick@free.fr> Strip trailing whitespace.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119038 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
bc68d71d2a858c748dbb1539201010bbc5758dc6 10-Nov-2010 Duncan Sands <baldrick@free.fr> Reduce the maximum recursion depth, 5 seems pointlessly too much.
Probably it should just be 1, but compromise with 3.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118718 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
a74a58c83be492b7d5b7383656f049909394cff4 10-Nov-2010 Duncan Sands <baldrick@free.fr> Teach InstructionSimplify how to look through PHI nodes. Since PHI
nodes can be used in loops, this could result in infinite looping
if there is no recursion limit, so add such a limit. It is also
used for the SelectInst case because in theory there could be an
infinite loop there too if the basic block is unreachable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118694 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
b2cbdc35ba85c04df15b0e991d9be371691ab08c 10-Nov-2010 Duncan Sands <baldrick@free.fr> Simplify binary operations where one operand is a select instruction.
The simplifications performed here never create new instructions, they
only return existing instructions (or a constant), and so are always a
win. In theory they should transform (for example)
%z = and i32 %x, %y
%s = select i1 %cond, i32 %y, i32 %z
%r = and i32 %x, %s
into
%r = and i32 %x, y
but in practice they get into a fight with instcombine, and lose.
Unfortunately instcombine does a poor job in this case. Nonetheless
I'm committing this transform to make it easier to discuss what to
do to make peace with instcombine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118679 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
3bbb0cc42b67b4bf2c488285666999963bab0f7e 09-Nov-2010 Duncan Sands <baldrick@free.fr> Factorize code, no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118516 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
92826def593df7a422c7b07f09342febce81ddd3 07-Nov-2010 Duncan Sands <baldrick@free.fr> Add simplification of floating point comparisons with the result
of a select instruction, the same as already exists for integer
comparisons.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118379 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
1ac7c9979a2d723ff4649ffad58df02732872a5f 07-Nov-2010 Duncan Sands <baldrick@free.fr> Fix a README item: when doing a comparison with the result
of a select instruction, see if doing the compare with the
true and false values of the select gives the same result.
If so, that can be used as the value of the comparison.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118378 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
4e282decf3960bfa6b1fe3fd77bb51ff96121515 16-Sep-2010 Owen Anderson <resistor@mac.com> Revert r114097, adding back in the assertion against replacing an Instruction by itself. Now that CorrelatedValuePropagation is
more careful not to call SimplifyInstructionsInBlock() on an unreachable block, the issue has been fixed at a higher level. Add
a big warning to SimplifyInstructionsInBlock() to hopefully prevent this in the future.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114117 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
4b91c3ac96fd93c7e9794d427787c29c68c25f68 16-Sep-2010 Owen Anderson <resistor@mac.com> Fix PR8161, in which an unreachable loop causes recursive instruction simplification to try
to replace an instruction with itself. Add a predicate to the simplifier to prevent this case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114097 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
6844c8ea5a67e551be7106d6b7b9e1a64eecbe51 11-Sep-2010 Benjamin Kramer <benny.kra@googlemail.com> Teach InstructionSimplify to fold (A & B) & A -> A & B and (A | B) | A -> A | B.

Reassociate does this but it doesn't catch all cases (e.g. if the operands are i1).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113651 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
d2bfe54b0a9f28c021d4f0790bdb5224d5579447 15-Jul-2010 Chris Lattner <sabre@nondot.org> Fix PR7647, handling the case when 'To' ends up being
mutated by recursive simplification. This also enhances
ReplaceAndSimplifyAllUses to actually do a real RAUW
at the end of it, which updates any value handles
pointing to "From" to start pointing to "To". This
seems useful for debug info and random other VH users.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108415 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
e2f93131fb78cf5650db9ca78b4aec3cc45f00be 15-Jul-2010 Eli Friedman <eli.friedman@gmail.com> Revert r108401; it breaks bootstrap :(



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108407 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
3ed60a2a2253fd519a2b2e48cacce10856198b62 15-Jul-2010 Eli Friedman <eli.friedman@gmail.com> Add AssertingVH which makes PR7647 break consistently.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108401 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
047542669a20505fc7c5f2d93caa5610aa3db2c5 20-Apr-2010 Chris Lattner <sabre@nondot.org> move some select simplifications out out instcombine into
inst simplify. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101873 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c8e14b3d37b80abb6adb4b831af0452d9ecbf2b2 03-Mar-2010 Chris Lattner <sabre@nondot.org> fix incorrect folding of icmp with undef, PR6481.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97659 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
6b617a7213e159097a7e5c7216ed9b04921de4e1 22-Feb-2010 Dan Gohman <gohman@apple.com> Constant-fold certain comparisons with infinity and negative infinity.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96777 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
8aee8efc0c2e387faa7dae39fdf613a22889b566 27-Nov-2009 Chris Lattner <sabre@nondot.org> factor some logic out of instcombine into a new SimplifyAddInst method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90011 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
c514c1f5218b8fe7499a0b9a4737860344cf4c43 27-Nov-2009 Chris Lattner <sabre@nondot.org> factor some instcombine simplifications for getelementptr out to a new
SimplifyGEPInst method in InstructionSimplify.h. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89980 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
40d8c28b27377199b7465ba2c5a2c59c6fd12fa9 10-Nov-2009 Chris Lattner <sabre@nondot.org> move some generally useful functions out of jump threading
into libanalysis and transformutils.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86735 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
70ce6d0819ffd5822bb176fffe94bcf29a1deda4 10-Nov-2009 Chris Lattner <sabre@nondot.org> I misread the parens, not so redundant after all.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86648 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
9f3ce36d7e58ec76442a2545782c69fcbac2a757 10-Nov-2009 Chris Lattner <sabre@nondot.org> remove some redundant parens.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86645 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
e34537856a544c83513e390ac9552a8bc3823346 10-Nov-2009 Chris Lattner <sabre@nondot.org> add a new SimplifyInstruction API, which is like ConstantFoldInstruction,
except that the result may not be a constant. Switch jump threading to
use it so that it gets things like (X & 0) -> 0, which occur when phi preds
are deleted and the remaining phi pred was a zero.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86637 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
d06094f0682f2ede03caff4892b1a57469896d48 10-Nov-2009 Chris Lattner <sabre@nondot.org> factor simplification logic for AND and OR out to InstSimplify from instcombine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86635 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
210c5d4880b525e064088b6fec713260128c16eb 10-Nov-2009 Chris Lattner <sabre@nondot.org> pull a bunch of logic out of instcombine into instsimplify for compare
simplification, this handles the foldable fcmp x,x cases among many others.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86627 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
9dbb42944c4d7caddab21016b24cca31019a3faf 10-Nov-2009 Chris Lattner <sabre@nondot.org> rename SimplifyCompare -> SimplifyCmpInst and split it into
Simplify[IF]Cmp pieces. Add some predicates to CmpInst to
determine whether a predicate is fp or int.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86624 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
8f73deaa8732a556046bf4ac6207be55972e3b74 10-Nov-2009 Chris Lattner <sabre@nondot.org> fix ConstantFoldCompareInstOperands to take the LHS/RHS as
individual operands instead of taking a temporary array


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86619 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp
9f3c25aeb3df77a336693308dc0f19a4983c99af 09-Nov-2009 Chris Lattner <sabre@nondot.org> stub out a new libanalysis "instruction simplify" interface that
takes decimated instructions and applies identities to them. This
is pretty minimal at this point, but I plan to pull some instcombine
logic out into these and similar routines.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86613 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/InstructionSimplify.cpp