History log of /art/compiler/optimizing/nodes.cc
Revision Date Author Comments
18b236e5261d2b1f312e632a4d3bb2273c8bf641 24-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Recompute dominator tree after DCE.

bug:22031382

(cherry picked from commit 1f82ecc6a0c9f88d03d6d1a6d95eeb8707bd06c1)

Change-Id: I9a74edb185cb806045903dfe9695d9cc1a02e86b
1e256bf257e8d97df9b2178ae8658b731ca2d662 19-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Be careful with predecessor/successor index.

When we simplify the CFG, we must preserve things that were already
simplified. For example, the index in the predecessor list or
successor list of a block must be preserved for ensuring the
first block is a loop pre header.

bug:21867463

(cherry picked from commit 8b20f88b0a8d1b374dd5eaae289d19734c77b8f8)

Change-Id: I2581b5a50942290da96cd9ec876f6f2573e0a6c4
25fde612b0df01a086cd4c801b7bd3a10e93a0e9 18-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Fix a bug in optimizing when the null constant has been DCE.

If it has been DCE, we should create a new one, instead of
using the old one.

Also move the first DCE to a place where it could actually
be useful.

bug:21870788

(cherry picked from commit 18e6873c469b48aaed22148451523479eece98e3)

Change-Id: I3b3ab2dafe8ce5fb60868fd1a6ef0eeefe666e0c
bca381a12965a98e3727e93986dd0a195db500a0 20-May-2015 Mingyao Yang <mingyao@google.com> Fix premature deoptimization if the loop body isn't entered.

Add a test between initial_ and end_ to see if the loop body is entered.
If the loop body isn't entered at all, we jump to the loop header. Loop header is
still executed and is going to test the condition again and loop body won't be
entered. This makes sure no deoptimization is triggered if the loop body isn't
even entered.

Bug: 21034044

(cherry picked from commit 3584bce5b1f45e5741d3a6ca24884a36320ecb6b)

Change-Id: I2b6de1f22fbc4568ca419f76382ebd87806d9694
41b175aba41c9365a1c53b8a1afbd17129c87c14 19-May-2015 Vladimir Marko <vmarko@google.com> ART: Clean up arm64 kNumberOfXRegisters usage.

Avoid undefined behavior for arm64 stemming from 1u << 32 in
loops with upper bound kNumberOfXRegisters.

Create iterators for enumerating bits in an integer either
from high to low or from low to high and use them for
<arch>Context::FillCalleeSaves() on all architectures.

Refactor runtime/utils.{h,cc} by moving all bit-fiddling
functions to runtime/base/bit_utils.{h,cc} (together with
the new bit iterators) and all time-related functions to
runtime/base/time_utils.{h,cc}. Improve test coverage and
fix some corner cases for the bit-fiddling functions.

Bug: 13925192

(cherry picked from commit 80afd02024d20e60b197d3adfbb43cc303cf29e0)

Change-Id: I905257a21de90b5860ebe1e39563758f721eab82
e8ff50df01c89e1b5264a5a900cfebdde87a9b44 07-May-2015 David Brazdil <dbrazdil@google.com> ART: Rediscover loops after deleting blocks in DCE

The way DCE currently updates loop information does not cover all
cases. This patch removes the logic, resets loop information of live
blocks to pre-SSA state and reanalyzes the affected loops.

Change-Id: I0b996a70235b95a8db0de9a23a03f71db57a21b8
(cherry picked from commit a4b8c21dae70ae34aee13628632c39a675c06022)
0a23d74dc2751440822960eab218be4cb8843647 07-May-2015 Nicolas Geoffray <ngeoffray@google.com> Add a parent environment to HEnvironment.

This code has no functionality change. It adds a placeholder
for chaining inlined frames.

Change-Id: I5ec57335af76ee406052345b947aad98a6a4423a
8c0c91a845568624815df026cfdac8c42ecccdf6 07-May-2015 Nicolas Geoffray <ngeoffray@google.com> Use a growable array instead of an environment during SSA.

Using an environment was convenient because it contains
a growable array. But there's no need for the environment
abstraction when being used as a temporary holder for values
of locals.

Change-Id: Idf2883fe4b8f97a31ee70b3627c1bdd23ebfff0e
db216f4d49ea1561a74261c29f1264952232728a 05-May-2015 Nicolas Geoffray <ngeoffray@google.com> Relax the only one back-edge restriction.

The rule is in the way for better register allocation, as
it creates an artificial join point between multiple paths.

Change-Id: Ia4392890f95bcea56d143138f28ddce6c572ad58
38f2085e53b22762a83c464d91db59a9c0327580 28-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Update the remaining input index of phis after deleting an input.

bug:20715803
bug:20690906

(cherry picked from commit 5d7b7f81ed5455893f984752c00571ef27cc97c5)

Change-Id: Ie55739601b8d6fedc830d6e19d8a053392047d34
6db49a74e8402d3b6c66536ea7ec988144c05d24 28-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Update the remaining input index of phis after deleting an input.

bug:20715803
bug:20690906

(cherry picked from commit 5d7b7f81ed5455893f984752c00571ef27cc97c5)

Change-Id: Ie55739601b8d6fedc830d6e19d8a053392047d34
5d7b7f81ed5455893f984752c00571ef27cc97c5 28-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Update the remaining input index of phis after deleting an input.

bug:20715803
bug:20690906

Change-Id: Iaf08f0c30d629e766be2b04815dc3e38b6e7ff35
3a0163107e34304ff720bcc34b280aca0ea4a0fc 29-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Fix loop information after dead code elimination

Compilation failed when only some blocks of a loop were removed during
dead code elimination.

Bug: 20680703
(cherry picked from commit 69a2804c3bb48cf4fd00a66080f613a4fd96c422)

Change-Id: If9988381236e4d8d8c3b508dfce1376b27c20d75
395086f0a9e0658a2d33eeade7121db55c1f5dc8 29-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Fix loop information after dead code elimination

Compilation failed when only some blocks of a loop were removed during
dead code elimination.

Bug: 20680703
(cherry picked from commit 69a2804c3bb48cf4fd00a66080f613a4fd96c422)

Change-Id: If9988381236e4d8d8c3b508dfce1376b27c20d75
69a2804c3bb48cf4fd00a66080f613a4fd96c422 29-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Fix loop information after dead code elimination

Compilation failed when only some blocks of a loop were removed during
dead code elimination.

Bug: 20680703
Change-Id: If31025169ca493f0d7f7f2788576e98d05f03394
2b1c622d5db941fe06b3ea9c1a5366358fa298c6 27-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Fix removing a Phi with RemoveInstruction

Boolean simplifier might attempt to remove a Phi from the Instruction
list.

(cherry picked from commit c7508e93fa3df3a3890f6b62550cbd5e35bdd8df)

Change-Id: Ic8ad31967aa3e47c1fb1c67553d08681b6063a16
f213e05cef6d38166cfe0cce8f3b0a53225a1b39 27-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Add support for caching float and double constants.

Change-Id: Ib5205bad1006bc5e3c9cc86bc82a6b4b1ce9bef9
c7508e93fa3df3a3890f6b62550cbd5e35bdd8df 27-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Fix removing a Phi with RemoveInstruction

Boolean simplifier might attempt to remove a Phi from the Instruction
list.

Change-Id: I698cc616549bd88dac96395cb2e5d09b5433d157
2967ec6c3dad1c1dc15fc827188bd5ecfa75493b 24-Apr-2015 Guillaume "Vermeille" Sanchez <guillaumesa@google.com> Add InsertInstructionAfter in HBasicBlock.

Change-Id: I56e4e6edb39d1aab747877b7e517e94f0393f296
206d6fd6cae5ba8c4d5f0e230111fe77b9d5c0a5 14-Apr-2015 Mingyao Yang <mingyao@google.com> Deoptimization-based BCE for unknown loop bounds.

For loop like:
for (int i = start; i < end; i++) {
array[i] = 1;
}
We add the following to the loop pre-header:
if (start < 0) deoptimize();
if (end > array.length) deoptimize();
Then we can eliminate bounds-check of array[i] inside the loop.

We also take care of indexing with induction variable plus some offsets,
like array[i - 1]/array[i + 1] inside the loop, and adjust the condition
for deoptimization accordingly.

Change-Id: I9e24c6b5e134ff95eff5b5605ff8f95d6546616f
067cae2c86627d2edcf01b918ee601774bc76aeb 26-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "[optimizing] Replace FP divide by power of 2"

Fails compiling docs.

This reverts commit b0bd8915cb257cdaf46ba663c450a6543bca75af.

Change-Id: I47d32525c83a73118e2163eb58c68bbb7a28bb38
4c0eb42259d790fddcd9978b66328dbb3ab65615 24-Apr-2015 Roland Levillain <rpl@google.com> Ensure inlined static calls perform clinit checks in Optimizing.

Calls to static methods have implicit class initialization
(clinit) checks of the method's declaring class in
Optimizing. However, when such a static call is inlined,
the implicit clinit check vanishes, possibly leading to an
incorrect behavior.

To ensure that inlining static methods does not change the
behavior of a program, add explicit class initialization
checks (art::HClinitCheck) as well as load class
instructions (art::HLoadClass) as last input of static
calls (art::HInvokeStaticOrDirect) in Optimizing' control
flow graphs, when the declaring class is reachable and not
known to be already initialized. Then when considering the
inlining of a static method call, proceed only if the method
has no implicit clinit check requirement.

The added explicit clinit checks are already removed by the
art::PrepareForRegisterAllocation visitor. This CL also
extends this visitor to turn explicit clinit checks from
static invokes into implicit ones after the inlining step,
by removing the added art::HLoadClass nodes mentioned
hereinbefore.

Change-Id: I9ba452b8bd09ae1fdd9a3797ef556e3e7e19c651
2d7352ba5311b8f57427b91b7a891e61497373c1 20-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Dead block removal

Adds a new pass which finds all unreachable blocks, typically due to
simplifying an if-condition to a constant, and removes them from the
graph. The patch also slightly generalizes the graph-transforming
operations.

Change-Id: Iff7c97f1d10b52886f3cd7401689ebe1bfdbf456
2cebb24bfc3247d3e9be138a3350106737455918 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
c3d743fa2a26effcb35627d8a1338029c86e582a 22-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Update last_instruction when adding Phis

HBasicBlock::InsertPhiAfter would not update the last_instruction
pointer when adding at the end of the list. This could cause problems
when iterating over phis backwards. Fortunately, we don't do that
anywhere in the existing code.

Change-Id: I4487265bf2cf3d3819623fafd7ce7c359bac190e
7d275379bf490a87805852129e3fe2e8afe961e7 21-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Update loop info of all nested loops when inlining

When inlining into a nested loop, the inliner would only add the new
blocks into the innermost loop info object. This patch fixes that and
modifies SsaChecker to verify the property.

Change-Id: I21d343a6f7d972f5b7420701f816c65ab3f20566
b0bd8915cb257cdaf46ba663c450a6543bca75af 16-Apr-2015 Mark Mendell <mark.p.mendell@intel.com> [optimizing] Replace FP divide by power of 2

Replace a floating point division by a power of two by a multiplication
of the reciprocal. This is guarenteed to have the exact same result as
it is exactly representable.

Add routines to allow generation of float and double constants after the
SSA Builder. I was unsure if float and double caches should be
implemented. Under the assumption that there is probably not a lot of
repetition of FP values. Please let me know.

Change-Id: I3a6c3847b49b4e747a7e7e8843ca32bb174b1584
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
05144f4322eed049f4878015bf1f0381d419b785 16-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Hot fix for an inliner issue

Change 147130 caused a problem with duplicit instruction ids when
inlining methods with constants. This is a hot fix to unblock build.

Change-Id: Ieddadcd94135930a1f29ad64ad57349a384da07f
4a3faecbe4157225a3fe83a9ef7f4992dfc9c19d 16-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Don't duplicate null/int/long constants when inlining

Change-Id: I7e6a3393fcbbcf76b4ba2000915ba6bbbfb7c70e
f776b92a0d52bb522043812dacb9c21ac11858e2 15-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Remove dead blocks for the blocks_ array.

This prevents crashing because of structurally incorrect
blocks. Also we now don't need to remove its instructions.

Test case courtesy of Serguei I Katkov.

Change-Id: Ia3ef9580549fc3546e8cd5f346079b1f0ceb2a61
d43b3ac88cd46b8815890188c9c2b9a3f1564648 01-Apr-2015 Mingyao Yang <mingyao@google.com> Revert "Revert "Deoptimization-based bce.""

This reverts commit 0ba627337274ccfb8c9cb9bf23fffb1e1b9d1430.

Change-Id: I1ca10d15bbb49897a0cf541ab160431ec180a006
8d5b8b295930aaa43255c4f0b74ece3ee8b43a47 24-Mar-2015 David Brazdil <dbrazdil@google.com> ART: Force constants into the entry block

Optimizations such as GVN and BCE make the assumption that all
constants are located in the entry block of the CFG, but not all
passes adhere to this rule.

This patch makes constructors of constants private and only accessible
to friend classes - HGraph for int/long constants and SsaBuilder for
float/double - which ensure that they are placed correctly and not
duplicated.

Note that the ArenaAllocatorAdapter was modified to not increment
the ArenaAllocator's internal reference counter in order to allow
for use of ArenaSafeMap inside an arena-allocated objects. Because
their destructor is not called, the counter does not get decremented.

Change-Id: I36a4fa29ae34fb905cdefd482ccbf386cff14166
b2bd1c5f9171f35fa5b71ada42d1a9e11189428d 25-Mar-2015 David Brazdil <dbrazdil@google.com> ART: Formatting and comments in BooleanSimplifier

Change-Id: I9a5aa3f2aa8b0a29d7b0f1e5e247397cf8e9e379
46e2a3915aa68c77426b71e95b9f3658250646b7 16-Mar-2015 David Brazdil <dbrazdil@google.com> ART: Boolean simplifier

The optimization recognizes the negation pattern generated by 'javac'
and replaces it with a single condition. To this end, boolean values
are now consistently assumed to be represented by an integer.

This is a first optimization which deletes blocks from the HGraph and
does so by replacing the corresponding entries with null. Hence,
existing code can continue indexing the list of blocks with the block
ID, but must check for null when iterating over the list.

Change-Id: I7779da69cfa925c6521938ad0bcc11bc52335583
0ba627337274ccfb8c9cb9bf23fffb1e1b9d1430 24-Mar-2015 Andreas Gampe <agampe@google.com> Revert "Deoptimization-based bce."

This breaks compiling the core image:

Error after BCE: art::SSAChecker: Instruction 219 in block 1 does not dominate use 221 in block 1.

This reverts commit e295e6ec5beaea31be5d7d3c996cd8cfa2053129.

Change-Id: Ieeb48797d451836ed506ccb940872f1443942e4e
e295e6ec5beaea31be5d7d3c996cd8cfa2053129 07-Mar-2015 Mingyao Yang <mingyao@google.com> Deoptimization-based bce.

A mechanism is introduced that a runtime method can be called
from code compiled with optimizing compiler to deoptimize into
interpreter. This can be used to establish invariants in the managed code
If the invariant does not hold at runtime, we will deoptimize and continue
execution in the interpreter. This allows to optimize the managed code as
if the invariant was proven during compile time. However, the exception
will be thrown according to the semantics demanded by the spec.

The invariant and optimization included in this patch are based on the
length of an array. Given a set of array accesses with constant indices
{c1, ..., cn}, we can optimize away all bounds checks iff all 0 <= min(ci) and
max(ci) < array-length. The first can be proven statically. The second can be
established with a deoptimization-based invariant. This replaces n bounds
checks with one invariant check (plus slow-path code).

Change-Id: I8c6e34b56c85d25b91074832d13dba1db0a81569
4f1a384762bf49fe8f3ecae8dd2bcb0e19d044a9 12-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Give an expected type to phis created for multiple returns.

When inlining, we used to take the type of the inlined method
for the phi in case of multiple returns. I recently changed the
logic of phi types to only be of int/float/double/ref, so we
need to call ToPhiType when creating the phi.

Change-Id: I960067ca8a8814509c2a7c52c08387d892ebf4a3
b2fd7bca70b580921eebf7c45769c39d2dfd8a5a 11-Mar-2015 Alexandre Rames <alexandre.rames@arm.com> Opt compiler: Basic simplification for arithmetic operations.

The optimisations in this patch do not look further than the
inputs of each operation.

Change-Id: Iddd0ab6b360b9e7bb042db22086d51a31be85530
817bce7658918b7a70c17b70aa5e6a46b1ae8b3d 24-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Fix inlining in the presence of multiple returns.

One return could actually return a phi, so doing a phi check for
knowing if the result phi was already created was bogus.

Bug: 19454010

Change-Id: Iee703a2d1071ae263092354465eda368e5d6770d
1abb4191a2e56d8dbf518efcaeefb266c1acdf2b 17-Feb-2015 David Brazdil <dbrazdil@google.com> Optimizing: Speed up HInstruction use removal

Similarly to a previous commit on HEnvironment use removal, this patch
adds links from instructions to their respective inputs' use lists for
contant-time removal at the cost of doubling the size of input lists
(from one pointer per entry to two). Manual testing shows that this
significantly reduces the time required to transform HGraph to SSA
form for some huge methods.

Change-Id: I8dc3e4b0c48a50ac1481eb55c31093b99f4dc29f
acf735c13998ad2a175f5a17e7bfce220073279d 12-Feb-2015 Calin Juravle <calin@google.com> Reference type propagation

- propagate reference types between instructions
- remove checked casts when possible
- add StackHandleScopeCollection to manage an arbitrary number of stack
handles (see comments)

Change-Id: I31200067c5e7375a5ea8e2f873c4374ebdb5ee60
d6138ef1ea13d07ae555542f8898b30d89e9ac9a 18-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Ensure the graph is correctly typed.

We used to be forgiving because of HIntConstant(0) also being
used for null. We now create a special HNullConstant for such uses.

Also, we need to run the dead phi elimination twice during ssa
building to ensure the correctness.

Change-Id: If479efa3680d3358800aebb1cca692fa2d94f6e5
be31ff94d66a0037c445eb57dc82f2a51bb46d9e 04-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Fix a bug in the inliner.

Code did not work in the presence of multiple returns.
Spotted by Mark P. Mendell.

Change-Id: I237050a0d79c0cfaa479e9b886f7450879e84713
276d9daaedfbff716339f94d55e6eff98b7434c6 02-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Inline methods with multiple blocks.

Change-Id: I3431af60e97fae230e0b6e98bcf0acc0ee9abf8c
82091dad38f3e5bfaf3b6984c9ab73069fb68310 26-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Implement LICM in optimizing compiler.

Change-Id: I9c8afb0a58ef45e568576015473cbfd5f011c242
ed59619b370ef23ffbb25d1d01f615e60a9262b6 23-Jan-2015 David Brazdil <dbrazdil@google.com> Optimizing: Speed up HEnvironment use removal

Removal of use records from HEnvironment vregs involved iterating over
potentially large linked lists which made compilation of huge methods
very slow. This patch turns use lists into doubly-linked lists, stores
pointers to the relevant nodes inside HEnvironment and subsequently
turns the removals into constant-time operations.

Change-Id: I0e1d4d782fd624e7b8075af75d4adf0a0634a1ee
0ada95d8de4b04b5f201b4b7e9c3c2fd2cc321ae 04-Dec-2014 Jean Christophe Beyler <jean.christophe.beyler@intel.com> ART: Replace NULL to nullptr in the optimizing compiler

Replace macro NULL to the nullptr variation for C++.

Change-Id: Ib6e48dd4bb3c254343383011b67372622578ca76
Signed-off-by: Jean Christophe Beyler <jean.christophe.beyler@intel.com>
6c2dff8ff8e1440fa4d9e1b2ba2a44d036882801 21-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Fully support pairs in the register allocator.""

This reverts commit c399fdc442db82dfda66e6c25518872ab0f1d24f.

Change-Id: I19f8215c4b98f2f0827e04bf7806c3ca439794e5
77520bca97ec44e3758510cebd0f20e3bb4584ea 12-Jan-2015 Calin Juravle <calin@google.com> Record implicit null checks at the actual invoke time.

ImplicitNullChecks are recorded only for instructions directly (see NB
below) preceeded by NullChecks in the graph. This way we avoid recording
redundant safepoints and minimize the code size increase.

NB: ParallalelMoves might be inserted by the register allocator between
the NullChecks and their uses. These modify the environment and the
correct action would be to reverse their modification. This will be
addressed in a follow-up CL.

Change-Id: Ie50006e5a4bd22932dcf11348f5a655d253cd898
c399fdc442db82dfda66e6c25518872ab0f1d24f 21-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Fully support pairs in the register allocator."

Libcore tests fail.

This reverts commit 41aedbb684ccef76ff8373f39aba606ce4cb3194.

Change-Id: I2572f120d4bbaeb7a4d4cbfd47ab00c9ea39ac6c
41aedbb684ccef76ff8373f39aba606ce4cb3194 14-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Fully support pairs in the register allocator.

Enabled on ARM for longs and doubles.

Change-Id: Id8792d08bd7ca9fb049c5db8a40ae694bafc2d8b
9ee66183d8e046ea661f642ba884626f16b46e06 16-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Constant fold after inlining.

- Inlining opens up new opportunities for constant folding.
- Fix a bug in constant folder where the result type was not
correctly set for the folding of a HCompare.
- Improve graph checker's coverage.

Change-Id: I0943bf8ff65505c4addc4a555a526b55e00b5268
7c5367badfe61b96c5836d495d286cee64861579 17-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Fix ids and remove invoke when inlining.

Bugs found by Razvan Lupusoru.

Change-Id: I3a5a9af280d8700d18f52abb4a2cff0e3a9aac74
53d9da8507a1b68f036ce8669ad3f2ae9fc3d225 04-Dec-2014 Jean Christophe Beyler <jean.christophe.beyler@intel.com> ART: Create a RemoveBlock method

The RemoveDeadBlocks should be separated into a utility function to remove
a single block so that it can be used as a future utility method.

Change-Id: I4c67113fff24e92a66a81bc0e8edf9fbdda08cdf
Signed-off-by: Jean Christophe Beyler <jean.christophe.beyler@intel.com>
e53798a7e3267305f696bf658e418c92e63e0834 01-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Inlining support in optimizing.

Currently only inlines simple things that don't require an
environment, such as:
- Returning a constant.
- Returning a parameter.
- Returning an arithmetic operation.

Change-Id: Ie844950cb44f69e104774a3cf7a8dea66bc85661
fc600dccd7797a9a10cdd457034ea8e148ccd631 02-Dec-2014 Roland Levillain <rpl@google.com> Fix a compiler bug related to a catch-less try-finally statement.

Ensure a dead basic block produced in this case is properly
removed.

Change-Id: I7c88e26aaa6c6378892f7c7c299494fa42312db2
f537012ceb6cba8a78b36a5065beb9588451a250 02-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Treat SSA transformation special, as we may have to bailout.

We forgot to bailout when we found a non-natural loop (on which
our optimizations don't work).

Change-Id: I11976b5af4c98f4f29267a74c74d34b5ad81e20c
6a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866f 31-Oct-2014 Ian Rogers <irogers@google.com> Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.

Fix associated errors about unused paramenters and implict sign conversions.
For sign conversion this was largely in the area of enums, so add ostream
operators for the effected enums and fix tools/generate-operator-out.py.
Tidy arena allocation code and arena allocated data types, rather than fixing
new and delete operators.
Remove dead code.

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
b762d2ebf9dc604561d9915c96b377235c94960c 22-Oct-2014 Roland Levillain <rpl@google.com> Various fixes related to integer negate operations.

- Emit an RSB instruction for HNeg nodes in the ARM code
generator instead of RSBS, as we do not need to update the
condition code flags in this case.
- Simply punt when trying to statically evaluate a long
unary operation, instead of aborting.
- Move a test case to the right place.

Change-Id: I35eb8dea58ed35258d4d8df77181159c3ab07b6f
102cbed1e52b7c5f09458b44903fe97bb3e14d5f 15-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Implement register allocator for floating point registers.

Also:
- Fix misuses of emitting the rex prefix in the x86_64 assembler.
- Fix movaps code generation in the x86_64 assembler.

Change-Id: Ib6dcf6e7c4a9c43368cfc46b02ba50f69ae69cbe
9240d6a2baa9ed1e18ee08744b461fe49a1ee269 20-Oct-2014 Roland Levillain <rpl@google.com> Constant folding on unary operations in the optimizing compiler.

Change-Id: I4b77afa2a89f5ad2eedd4d6c0c6c382585419349
6c82d40eb142771086f5531998de2273ba5cc08c 13-Oct-2014 Roland Levillain <rpl@google.com> Have HInstruction::StrictlyDominates compute strict dominance.

Change-Id: I3a4fa133268615fb4ce54a0bcb43e0c2458cc865
633021e6ff6b9a57a374a994e74cfd69275ce100 01-Oct-2014 Roland Levillain <rpl@google.com> Implement default traversals in CFG & SSA graph checkers.

- Check CFG graphs using an insertion order traversal.
- Check SSA form graphs using a reverse post-order traversal.

Change-Id: Ib9062599bdbf3c17b9f213b743274b2d71a9fa90
476df557fed5f0b3f32f8d11a654674bb403a8f8 09-Oct-2014 Roland Levillain <rpl@google.com> Use Is*() helpers to shorten code in the optimizing compiler.

Change-Id: I79f31833bc9a0aa2918381aa3fb0b05d45f75689
360231a056e796c36ffe62348507e904dc9efb9b 08-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Fix code generation of materialized conditions.

Move the logic for knowing if a condition needs to be materialized
in an optimization pass (so that the information does not change
as a side effect of another optimization).

Also clean-up arm and x86_64 codegen:
- arm: ldr and str are for power-users when a constant is
in play. We should use LoadFromOffset and StoreToOffset.
- x86_64: fix misuses of movq instead of movl.

Change-Id: I01a03b91803624be2281a344a13ad5efbf4f3ef3
191c4b1372aef7c0272f8fa3985b55513029e728 07-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Inserting a node must also update its inputs users.

Change-Id: I55357564b81efcc0cf52fffdf23289696fe27dd1
3c04974a90b0e03f4b509010bff49f0b2a3da57f 24-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Optimize suspend checks in optimizing compiler.

- Remove the ones added during graph build (they were added
for the baseline code generator).
- Emit them at loop back edges after phi moves, so that the test
can directly jump to the loop header.
- Fix x86 and x86_64 suspend check by using cmpw instead of cmpl.

Change-Id: I6fad5795a55705d86c9e1cb85bf5d63dadfafa2a
6b46923ff0197c95f1e7ea0bc730961df6725cc9 25-Sep-2014 Roland Levillain <rpl@google.com> Optimizing compiler: check inputs & uses definitions in CFG.

Ensure each input and each use of an instruction is defined
in a block of the control-flow graph.

Change-Id: If4a83b02825230329b0b4fd84255dcb7c3219684
18efde5017369e005f1e8bcd3bbfb04e85053640 22-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Fix code generation with materialized conditions.

Change-Id: I8630af3c13fc1950d3fa718d7488407b00898796
724c96326dea6ec33287a0076279c136abb0208a 22-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Also remove environment links to removed instructions.

Change-Id: I505163fb8683269c7d3fe21b34df92337d244552
d31cf3d55a0847c018c4eaa2b349b8eea509de64 08-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> First optimization in new compiler: simple GVN.

Change-Id: Ibe0efa4e84fd020a53ded310a92e0b4363f91b12
556c3d193134f6461f3e1fe17c032b087c5931a0 18-Sep-2014 Roland Levillain <rpl@google.com> Initiate a constant propagation pass in the optimizing compiler.

- Perform constant folding on int and long additions and subtractions in
the optimizing compiler.
- Apply constant folding to conditions and comparisons.

Change-Id: Ic88783a3c975fda777c74c531e257fa777be42eb
ccc07a9579c554443cd03a306ca9b4f943fd2a93 16-Sep-2014 Roland Levillain <rpl@google.com> Add CFG and SSA form checkers in the optimizing compiler.

Checks performed on control-flow graphs:
- Ensure that the predecessors and successors of a basic block are
consistent within a control-flow graph.
- Ensure basic blocks end with a branch instruction.
- Detect phi functions listed in non-phi instruction lists and vice
versa.
- Ensure a block's instructions (and phi functions) are associated
with this very block.

Checks performed on SSA form graphs:
- Ensure an instruction dominates all its uses.
- Ensure there are no critical edges.

Change-Id: I1c12b4a61ecf608682152c897980ababa7eca847
604c6e4764edb2fd244e9f47626868cda5644a7a 17-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Ensure the first predecessor of a loop is the pre header.

Note that the check in ssa_phi_elimination.cc was very defensive:
it does not affect the outcome of the algorithm whether the
loop phi takes itself as the first input.

It makes things consistent to always have the pre header as first
input.

Change-Id: Ic86248c1f38af67f7432782f6deefae1f4bf1ab6
065bf77b43c39da315b974ea08a5ed25e9049681 03-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Add (simple) side effects flags and equality methods on nodes.

This is in preparation of doing GVN and LICM.

Change-Id: I43050ff846755f9387a62b893d548ecdb54e7e95
3946844c34ad965515f677084b07d663d70ad1b8 02-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Runtime support for the new stack maps for the opt compiler.

Now most of the methods supported by the compiler can be optimized,
instead of using the baseline.

Change-Id: I80ab36a34913fa4e7dd576c7bf55af63594dc1fa
20dfc797dc631bf8d655dcf123f46f13332d3074 17-Jun-2014 Dave Allison <dallison@google.com> Add some more instruction support to optimizing compiler.

This adds a few more DEX instructions to the optimizing compiler's
builder (constants, moves, if_xx, etc).

Also:
* Changes the codegen for IF_XX instructions to use a condition
rather than comparing a value against 0.
* Fixes some instructions in the ARM disassembler.
* Fixes PushList and PopList in the thumb2 assembler.
* Switches the assembler for the optimizing compiler to thumb2
rather than ARM.

Change-Id: Iaafcd02243ccc5b03a054ef7a15285b84c06740f
ec7e4727e99aa1416398ac5a684f5024817a25c7 06-Jun-2014 Nicolas Geoffray <ngeoffray@google.com> Fix some bugs in graph construction/simplification methods.

Also fix a brano during SSA construction. The code should
not have been commented out. Added a test to cover what the code
intends.

Change-Id: Ia00ae79dcf75eb0d412f07649d73e7f94dbfb6f0
ffddfdf6fec0b9d98a692e27242eecb15af5ead2 03-Jun-2014 Tim Murray <timmurray@google.com> DO NOT MERGE

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
a7062e05e6048c7f817d784a5b94e3122e25b1ec 22-May-2014 Nicolas Geoffray <ngeoffray@google.com> Add a linear scan register allocator to the optimizing compiler.

This is a "by-the-book" implementation. It currently only deals
with allocating registers, with no hint optimizations.

The changes remaining to make it functional are:
- Allocate spill slots.
- Resolution and placements of Move instructions.
- Connect it to the code generator.

Change-Id: Ie0b2f6ba1b98da85425be721ce4afecd6b4012a4
4e3d23aa1523718ea1fdf3a32516d2f9d81e84fe 22-May-2014 Nicolas Geoffray <ngeoffray@google.com> Import Dart's parallel move resolver.

And write a few tests while at it.

A parallel move resolver will be needed for performing multiple moves
that are conceptually parallel, for example moves at a block
exit that branches to a block with phi nodes.

Change-Id: Ib95b247b4fc3f2c2fcab3b8c8d032abbd6104cd7
f635e63318447ca04731b265a86a573c9ed1737c 14-May-2014 Nicolas Geoffray <ngeoffray@google.com> Add a compilation tracing mechanism to the new compiler.

Code mostly imported from: https://android-review.googlesource.com/#/c/81653/.

Change-Id: I150fe942be0fb270e03fabb19032180f7a065d13
622d9c31febd950255b36a48b47e1f630197c5fe 12-May-2014 Nicolas Geoffray <ngeoffray@google.com> Add loop recognition and CFG simplifications in new compiler.

We do three simplifications:
- Split critical edges, for code generation from SSA (new).
- Ensure one back edge per loop, to simplify loop recognition (new).
- Ensure only one pre header for a loop, to simplify SSA creation (existing).

Change-Id: I9bfccd4b236a00486a261078627b091c8a68be33
804d09372cc3d80d537da1489da4a45e0e19aa5d 02-May-2014 Nicolas Geoffray <ngeoffray@google.com> Build live-in, live-out and kill sets for each block.

This information will be used when computing live ranges of
instructions.

Change-Id: I345ee833c1ccb4a8e725c7976453f6d58d350d74
c32e770f21540e4e9eda6dc7f770e745d33f1b9f 24-Apr-2014 Nicolas Geoffray <ngeoffray@google.com> Add a Transform to SSA phase to the optimizing compiler.

Change-Id: Ia9700756a0396d797a00b529896487d52c989329
43c86422e210a3883729ab90997711e79f26bccc 18-Mar-2014 Nicolas Geoffray <ngeoffray@google.com> Fix lint error, and Makefile that could be confused with local files.

Change-Id: I780cc0d6593eadd6f82e1126d7ad445894af666c
787c3076635cf117eb646c5a89a9014b2072fb44 17-Mar-2014 Nicolas Geoffray <ngeoffray@google.com> Plug new optimizing compiler in compilation pipeline.

Also rename accessors to ART's conventions.

Change-Id: I344807055b98aa4b27215704ec362191464acecc
bab4ed7057799a4fadc6283108ab56f389d117d4 11-Mar-2014 Nicolas Geoffray <ngeoffray@google.com> More code generation for the optimizing compiler.

- Add HReturn instruction
- Generate code for locals/if/return
- Setup infrastructure for register allocation. Currently
emulate a stack.

Change-Id: Ib28c2dba80f6c526177ed9a7b09c0689ac8122fb
3ff386aafefd5282bb76c8a50506a70a4321e698 04-Mar-2014 Nicolas Geoffray <ngeoffray@google.com> Add register support to the optimizing compiler.

Also make if take an input and build the use list for instructions.

Change-Id: I1938cee7dce5bd4c66b259fa2b431d2c79b3cf82
d4dd255db1d110ceb5551f6d95ff31fb57420994 28-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Add codegen support to the optimizing compiler.

Change-Id: I9aae76908ff1d6e64fb71a6718fc1426b67a5c28
be9a92aa804c0d210f80966b74ef8ed3987f335a 25-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Add conditional branches, and build dominator tree.

Change-Id: I4b151a07b72692961235a1419b54b6b45cf54e63
818f2107e6d2d9e80faac8ae8c92faffa83cbd11 18-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Re-apply: Initial check-in of an optimizing compiler.

The classes and the names are very much inspired by V8/Dart.
It currently only supports the RETURN_VOID dex instruction,
and there is a pretty printer to check if the building of the
graph is correct.

Change-Id: I28e125dfee86ae6ec9b3fec6aa1859523b92a893
1af0c0b88a956813eb0ad282664cedc391e2938f 19-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Initial check-in of an optimizing compiler."

g++ warnings turned into errors.

This reverts commit 68a5fefa90f03fdf5a238ac85c9439c6b03eae96.

Change-Id: I09bb95d9cc13764ca8a266c41af04801a34b9fd0
68a5fefa90f03fdf5a238ac85c9439c6b03eae96 18-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Initial check-in of an optimizing compiler.

The classes and the names are very much inspired by V8/Dart.
It currently only supports the RETURN_VOID dex instruction,
and there is a pretty printer to check if the building of the
graph is correct.

Change-Id: Id5ef1b317ab997010d4e3888e456c26bef1ab9c0