History log of /art/compiler/optimizing/constant_folding_test.cc
Revision Date Author Comments
fa3db3d377bfaceb51c9a97864b17ce02538b7e0 12-Jan-2018 Mathieu Chartier <mathieuc@google.com> Change compiler tests to have aligned code item

Previously, the code item was not necessarily 32 bit aligned. This
caused bus errors on armv7.

Also create a real dexfile object instead of casting 0 initialized
memory to a dex file pointer. We just got lucky before that the cdex
boolean was false.

Test: test-art-target-gtest
Bug: 63756964
Bug: 71605148

Change-Id: Ic7199f2b97bbd421de1d702efa5c6531ff45c022
ca6fff898afcb62491458ae8bcd428bfb3043da1 03-Oct-2017 Vladimir Marko <vmarko@google.com> ART: Use ScopedArenaAllocator for pass-local data.

Passes using local ArenaAllocator were hiding their memory
usage from the allocation counting, making it difficult to
track down where memory was used. Using ScopedArenaAllocator
reveals the memory usage.

This changes the HGraph constructor which requires a lot of
changes in tests. Refactor these tests to limit the amount
of work needed the next time we change that constructor.

Test: m test-art-host-gtest
Test: testrunner.py --host
Test: Build with kArenaAllocatorCountAllocations = true.
Bug: 64312607
Change-Id: I34939e4086b500d6e827ff3ef2211d1a421ac91a
0ebe0d83138bba1996e9c8007969b5381d972b32 21-Sep-2017 Vladimir Marko <vmarko@google.com> ART: Introduce compiler data type.

Replace most uses of the runtime's Primitive in compiler
with a new class DataType. This prepares for introducing
new types, such as Uint8, that the runtime does not need
to know about.

Test: m test-art-host-gtest
Test: testrunner.py --host
Bug: 23964345
Change-Id: Iec2ad82454eec678fffcd8279a9746b90feb9b0c
a5b09a67034e57a6e10231dd4bd92f4cb50b824c 18-Nov-2016 Andreas Gampe <agampe@google.com> ART: Add dex::TypeIndex

Add abstraction for uint16_t type index.

Test: m test-art-host
Change-Id: I47708741c7c579cbbe59ab723c1e31c5fe71f83a
ca620d7bc03b23a0bcf0ef58df58603ee000dca0 08-Nov-2016 Andreas Gampe <agampe@google.com> ART: Fix tidy warnings

Switch to char versions of find variants.

Add "explicit" constructor variants or refactor and
remove defaults.

Use const references.

Bug: 32619234
Test: m test-art-host
Change-Id: I970cc2f47d6cf8f0c74104b994b075b2fafb3d45
dee58d6bb6d567fcd0c4f39d8d690c3acaf0e432 07-Apr-2016 David Brazdil <dbrazdil@google.com> Revert "Revert "Refactor HGraphBuilder and SsaBuilder to remove HLocals""

This patch merges the instruction-building phases from HGraphBuilder
and SsaBuilder into a single HInstructionBuilder class. As a result,
it is not necessary to generate HLocal, HLoadLocal and HStoreLocal
instructions any more, as the builder produces SSA form directly.

Saves 5-15% of arena-allocated memory (see bug for more data):
GMS 20.46MB => 19.26MB (-5.86%)
Maps 24.12MB => 21.47MB (-10.98%)
YouTube 28.60MB => 26.01MB (-9.05%)

This CL fixed an issue with parsing quickened instructions.

Bug: 27894376
Bug: 27998571
Bug: 27995065

Change-Id: I20dbe1bf2d0fe296377478db98cb86cba695e694
60328910cad396589474f8513391ba733d19390b 04-Apr-2016 David Brazdil <dbrazdil@google.com> Revert "Refactor HGraphBuilder and SsaBuilder to remove HLocals"

Bug: 27995065
This reverts commit e3ff7b293be2a6791fe9d135d660c0cffe4bd73f.

Change-Id: I5363c7ce18f47fd422c15eed5423a345a57249d8
e3ff7b293be2a6791fe9d135d660c0cffe4bd73f 02-Mar-2016 David Brazdil <dbrazdil@google.com> Refactor HGraphBuilder and SsaBuilder to remove HLocals

This patch merges the instruction-building phases from HGraphBuilder
and SsaBuilder into a single HInstructionBuilder class. As a result,
it is not necessary to generate HLocal, HLoadLocal and HStoreLocal
instructions any more, as the builder produces SSA form directly.

Saves 5-15% of arena-allocated memory (see bug for more data):
GMS 20.46MB => 19.26MB (-5.86%)
Maps 24.12MB => 21.47MB (-10.98%)
YouTube 28.60MB => 26.01MB (-9.05%)

Bug: 27894376
Change-Id: Iefe28d40600c169c5d306fd2c77034ae19476d90
86ea7eeabe30c98bbe1651a51d03cb89776724e7 16-Feb-2016 David Brazdil <dbrazdil@google.com> Build dominator tree before generating HInstructions

Second CL in the series of merging HGraphBuilder and SsaBuilder. This
patch refactors the builders so that dominator tree can be built
before any HInstructions are generated. This puts the SsaBuilder
removal of HLoadLocals/HStoreLocals straight after HGraphBuilder's
HInstruction generation phase. Next CL will therefore be able to
merge them.

This patch also adds util classes for iterating bytecode and switch
tables which allowed to simplify the code.

Bug: 27894376
Change-Id: Ic425d298b2e6e7980481ed697230b1a0b7904526
d96a246e5b103bfc167acaa6315bd8abca9de493 23-Mar-2016 Vladimir Marko <vmarko@google.com> Optimizing: Do not insert suspend checks on back-edges.

Rely on HGraph::SimplifyLoop() to insert suspend checks.

CodeGenerator's CheckLoopEntriesCanBeUsedForOsr() checks the
dex pcs of suspend checks against branch targets to verify
that we always have an appropriate point for OSR transition.
However, the HSuspendChecks that were added by HGraphBuilder
to support the recently removed "baseline" interfered with
this in a specific case, namely an infinite loop where the
back-branch jumps to a nop. In that case, the HSuspendCheck
added by HGraphBuilder had a dex pc different from the block
and the branch target but its presence would stop the
HGraph::SimplifyLoop() from adding a new HSuspendCheck with
the correct dex pc.

Bug: 27623547
Change-Id: I83566a260210bc05aea0c44509a39bb490aa7003
badd826664896d4a9628a5a89b78016894aa414b 02-Feb-2016 David Brazdil <dbrazdil@google.com> ART: Run SsaBuilder from HGraphBuilder

First step towards merging the two passes, which will later result in
HGraphBuilder directly producing SSA form. This CL mostly just updates
tests broken by not being able to inspect the pre-SSA form.

Using HLocals outside the HGraphBuilder is now deprecated.

Bug: 27150508
Change-Id: I00fb6050580f409dcc5aa5b5aa3a536d6e8d759e
4833f5a1990c76bc2be89504225fb13cca22bedf 16-Dec-2015 David Brazdil <dbrazdil@google.com> ART: Refactor SsaBuilder for more precise typing info

This reverts commit 68289a531484d26214e09f1eadd9833531a3bc3c.

Now uses Primitive::Is64BitType instead of Primitive::ComponentSize
because it was incorrectly optimized by GCC.

Bug: 26208284
Bug: 24252151
Bug: 24252100
Bug: 22538329
Bug: 25786318

Change-Id: Ib39f3da2b92bc5be5d76f4240a77567d82c6bebe
68289a531484d26214e09f1eadd9833531a3bc3c 16-Dec-2015 Alex Light <allight@google.com> Revert "ART: Refactor SsaBuilder for more precise typing info"

This reverts commit d9510dfc32349eeb4f2145c801f7ba1d5bccfb12.

Bug: 26208284

Bug: 24252151
Bug: 24252100
Bug: 22538329
Bug: 25786318

Change-Id: I5f491becdf076ff51d437d490405ec4e1586c010
d9510dfc32349eeb4f2145c801f7ba1d5bccfb12 05-Nov-2015 David Brazdil <dbrazdil@google.com> ART: Refactor SsaBuilder for more precise typing info

This patch refactors the SsaBuilder to do the following:

1) All phis are constructed live and marked dead if not used or proved
to be conflicting.

2) Primitive type propagation, now not a separate pass, identifies
conflicting types and marks corresponding phis dead.

3) When compiling --debuggable, DeadPhiHandling used to revive phis
which had only environmental uses but did not attempt to resolve
conflicts. This pass was removed as obsolete and is now superseded
by primitive type propagation (identifying conflicting phis) and
SsaDeadPhiEliminiation (keeping phis live if debuggable + env use).

4) Resolving conflicts requires correct primitive type information
on all instructions. This was not the case for ArrayGet instructions
which can have ambiguous types in the bytecode. To this end,
SsaBuilder now runs reference type propagation and types ArrayGets
from the type of the input array.

5) With RTP being run inside the SsaBuilder, it is not necessary to
run it as a separate optimization pass. Optimizations can now assume
that all instructions of type kPrimNot have reference type info after
SsaBuilder (with the exception of NullConstant).

6) Graph now contains a reference type to be assigned to NullConstant.
All reference type instructions therefore have RTI, as now enforced
by the SsaChecker.

Bug: 24252151
Bug: 24252100
Bug: 22538329
Bug: 25786318

Change-Id: I7a3aee1ff66c82d64b4846611c547af17e91d260
96709f17347cb7a6aae15816244d2200ca95a649 29-Oct-2015 Aart Bik <ajcbik@google.com> Simplify unsigned comparisons against zero (with unit tests).

Rationale: Such cases occurs a lot after dynamic
bound check optimization (where the lower bound
is test against upper bound). Removing this
unnecessary test improves quality of code.

Change-Id: I3e4dc9f9d799aad342e1c344013ac60fcc3073ac
58554b7de4b437ddef7ff550e62c8ec0b16f9264 21-Oct-2015 Andreas Gampe <agampe@google.com> ART: Fix left-shift of negative numbers

Shifting negative numbers is undefined.

Change-Id: I0c32a3fcf372eae74507a5f2383edbfaf5c6830c
655e585073ac271cc9afa7c9d6ff5ab4dbe4b72e 12-Oct-2015 Vladimir Marko <vmarko@google.com> Optimizing: Move GraphChecker memory allocations to arena.

Bug: 18120045
Change-Id: I3934158e6ea4868d9baa1dfcc53b603ca6c521e2
ec7802a102d49ab5c17495118d4fe0bcc7287beb 01-Oct-2015 Vladimir Marko <vmarko@google.com> Add DCHECKs to ArenaVector and ScopedArenaVector.

Implement dchecked_vector<> template that DCHECK()s element
access and insert()/emplace()/erase() positions. Change the
ArenaVector<> and ScopedArenaVector<> aliases to use the new
template instead of std::vector<>. Remove DCHECK()s that
have now become unnecessary from the Optimizing compiler.

Change-Id: Ib8506bd30d223f68f52bd4476c76d9991acacadc
c90bc7c07f9bd24b5424cfb1e3f064fbae5334d6 11-Dec-2014 Roland Levillain <rpl@google.com> Add constant folding for long unary operations in opt. compiler.

Add tests to exercise the constant folding of these
instructions.

Also, prevent Java methods from run-tests exercising the
code generation of these instruction from being inlined,
so that they continue to check the generated code (and
not the code produced by the constant folding pass).

Change-Id: I28efca7cdb5142ac2b6d158ba296fb9136d62481
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
8b20f88b0a8d1b374dd5eaae289d19734c77b8f8 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

Change-Id: Ic3fcb3eb2c3fb109d8a57ee2a6b6d4d65fdb9410
1c533c17baff841e383a539fdd3c0a65135181b0 24-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Fix gtests broken by dead block elimination

Change-Id: If5de97f928f9e214d64871eabfbfb3f2d15451b7
862aaefdd63d8058b54a7d956a0229eec9dcbde6 22-Apr-2015 Calin Juravle <calin@google.com> [optimizing] Name the last DCE pass.

This will allow Checker to differentiate between them.

Change-Id: I972d452a64f1c19d370567b9ef3d620f9b835a9a
8f20bdb9d3b7516e75a7845e610105d87ce25ae6 21-Apr-2015 Calin Juravle <calin@google.com> Run DCE again after all the other optimizations have run.

On docs this doubles the amount of instructions removed.
b29ea8ca08fb6074f1af503f76751120626d6c1e 21-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "fix optimizing gtests"

This reverts commit 69dcf64251d70f616ae6c435d4788545130d42f0.

Change-Id: I1e01c17a3aa8b001ad5659260802e5f5073bf14e
69dcf64251d70f616ae6c435d4788545130d42f0 21-Apr-2015 Calin Juravle <calin@google.com> fix optimizing gtests

Change-Id: I207398d8a65482650fba87db12a3b51e8b114694
fb8d279bc011b31d0765dc7ca59afea324fd0d0c 01-Apr-2015 Mark Mendell <mark.p.mendell@intel.com> [optimizing] Implement x86/x86_64 math intrinsics

Implement floor/ceil/round/RoundFloat on x86 and x86_64.
Implement RoundDouble on x86_64.

Add support for roundss and roundsd on both architectures. Support them
in the disassembler as well.

Add the instruction set features for x86, as the 'round' instruction is
only supported if SSE4.1 is supported.

Fix the tests to handle the addition of passing the instruction set
features to x86 and x86_64.

Add assembler tests for roundsd and roundss to x86_64 assembler tests.

Change-Id: I9742d5930befb0bbc23f3d6c83ce0183ed9fe04f
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
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
cd6dffedf1bd8e6dfb3fb0c933551f9a90f7de3f 08-Jan-2015 Calin Juravle <calin@google.com> Add implicit null checks for the optimizing compiler

- for backends: arm, arm64, x86, x86_64
- fixed parameter passing for CodeGenerator
- 003-omnibus-opcodes test verifies that NullPointerExceptions work as
expected

Change-Id: I1b302acd353342504716c9169a80706cf3aba2c8
942a3785dca38feaae9d01b35d6bfb09c39315eb 17-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Now that GraphChecker has a state, don't re-use it.

Otherwise, we'll see the same ids twice.

Change-Id: Ic9bb801629ff90cc788248528d5260aaaff73675
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
5e6916cea259897baaca019c5c7a5d05746306ed 18-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Use HOptimization abstraction for running optimizations.

Move existing optimizations to it.

Change-Id: I3b43f9997faf4ed8875162e3a3abdf99375478dd
55dcfb5e0dd626993bb2b7b9f692c1b02b5d955f 24-Oct-2014 Roland Levillain <rpl@google.com> Add support for not-long on ARM64 in the optimizing compiler.

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

Change-Id: I4b77afa2a89f5ad2eedd4d6c0c6c382585419349
75be28332b278cff9039b54bfb228ac72f539ccc 17-Oct-2014 Roland Levillain <rpl@google.com> Revert "Revert "Introduce a class to implement optimization passes.""

This reverts commit 1ddbf6d4b37979a9f11a203c12befd5ae8b65df4.

Change-Id: I110a14668d1564ee0604dc958b91394b40da89fc
1ddbf6d4b37979a9f11a203c12befd5ae8b65df4 01-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Introduce a class to implement optimization passes."

This reverts commit bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8.

Change-Id: I0a483446666c9c24c45925a5fc199debdefd8b3e
bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8 30-Sep-2014 Roland Levillain <rpl@google.com> Introduce a class to implement optimization passes.

- Add art::HOptimization.
- Rename art::ConstantPropagation to art::HConstantFolding in
compiler/optimizing/constant_folding.h to avoid name
clashes with a class of the same name in
compiler/dex/post_opt_passes.h.
- Rename art::DeadCodeElimination to
art::HDeadCodeElimination for consistency reasons.
- Have art::HDeadCodeElimination and art::HConstantFolding
derive from art::HOptimization.
- Start to use these optimizations in
art:OptimizingCompiler::TryCompile.

Change-Id: Iaab350c122d87b2333b3760312b15c0592d7e010