History log of /art/compiler/optimizing/instruction_simplifier.cc
Revision Date Author Comments
f2ea71cdb3ee4f5198bc0298aa8be1f9e945ee1c 05-Aug-2015 Serguei Katkov <serguei.i.katkov@intel.com> ART: Fix the simplifier for add/sub

Instruction simplifier for add/sub should not proceed with floats
because that might cause the incorrect behavior with signed zero.

Bug: 23001681

Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>

(cherry picked from commit 115b53f609e74672fa93eea1845bb17340d5112a)

Change-Id: I9928724c4158b3961e32e376b9203fe01ba2e442
0bc614dfaff593d77eb698c279044db44bad4a4b 19-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Do not expect 0 or 1 only when comparing a boolean.

bug:21866529

(cherry picked from commit 3c4ab80c102ff1bfc0e74d4abddbf5454bf4008d)

Change-Id: Ibdc0d4a9730bfc6e7307282276f084dae5ac55c1
ba56d060116d6e145be348fa575314654c6b0572 06-May-2015 Mark Mendell <mark.p.mendell@intel.com> [optimizing] Improve 32 bit long shift by 1.

Also change FOO << 1 to FOO+FOO in the instruction simplifier. This is
an architecture independent simplification, which helps 'long << 1' for
32 bit architectures.

Generate an add/adc for long << 1 in x86, in case something is generated
after the simplifier.

Add test cases for the simplification.

Change-Id: I0d512331ef13cc4ccf10c80f11c370a10ed02294
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
0d22184ec9e5b1e958c031ac92c7f053de3a13a2 27-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "[optimizing] Replace FP divide by power of 2""

This reverts commit 067cae2c86627d2edcf01b918ee601774bc76aeb.

Change-Id: Iaaa8772500ea7d3dce6ae0829dc0dc3bbc9c14ca
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
af88835231c2508509eb19aa2d21b92879351962 20-Apr-2015 Guillaume "Vermeille" Sanchez <guillaumesa@google.com> Remove unnecessary null checks in CheckCast and InstanceOf

Change-Id: I6fd81cabd8673be360f369e6318df0de8b18b634
538491967d1514a263e99d78379d743fcc896eef 20-Apr-2015 Serguei Katkov <serguei.i.katkov@intel.com> Mul simplification should expect zero operand

It is possible that zero constant can appear due to
simplification of other instructions, so we cannot expect
zero handling from constant optimizations.

Change-Id: I084126fd0c106ac2683c4f10a451960d9807f4f6
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
943136fd031f4fe18f6e8a956c72171d7cf78da0 22-Apr-2015 Calin Juravle <calin@google.com> Remove warning when we do too many simplifications

This happens pretty often and pollutes the logs.

Change-Id: I074783d3cf3519a5186d2dd81c821d97071302e7
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>
339dfc209ad93482269eea1386e79973abc313cf 19-Apr-2015 Serguei Katkov <serguei.i.katkov@intel.com> Incorrect transformation of (sub,neg) to (sub) for fp

A pair (sub,neg) should not be transformed to (sub) for
floating point operations, otherwise we can lose the sign of
zero for instructions like this:
- (A - B) != B - A if B == A

Change-Id: I4d612612d4dc0a067fac5721ad206f74168bcd36
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
0d13fee6f4330cc9cb100c43135490a34c11d7a5 17-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Simplify more bool operations

Now that we have the HBooleanNot instruction, the instruction
simplifier can optimize out more conditions comparing a boolean
against a constant, as well as sequences of Boolean negations.

Change-Id: I7f634f6428a3984dd97b27b3d6362491346f1ff6
188d4316a880ae24aed315aa52dc503c4fcb1ec7 09-Apr-2015 Alexandre Rames <alexandre.rames@arm.com> Opt compiler: Instruction simplification for HAdd, HNeg, HNot, HSub.

Under assumptions for the 'cost' of each IR (eg. neither HAdd nor HSub
are faster than the other), transformations are only applied if they
(locally) cannot degrade the quality of the graph. The code could be
extended to look at uses of the IRs and detect more opportunities for
optimisations. The optimisations in this patch do not look at other
uses for their inputs.

Change-Id: Ib60dab007af30f43421ef5bb55db2ec32fb8fc0c
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
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
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
0304e182adee81be32c744fd3c0d28add29974ff 31-Jan-2015 Mingyao Yang <mingyao@google.com> Improve bce so that more bounds checks can be eliminated.

For pattern like "int[] array = new int[size+1]", we record this range
for size:
[-1, array.length-1]
This can eliminate more bounds checks.

Also simplify overflow/underflow handling and make it more solid.

Enhance instruction simplifier such that if array is a result of
NewArray with a constant size, replace array.length with that constant.

Plan to move all bce gtests to checker in another change.

Change-Id: Ibe7cc7940b68fb6465dc3e0ff3ebdb0fd6487aa9
10e244f9e7f6d96a95c910a2bedef5bd3810c637 26-Jan-2015 Calin Juravle <calin@google.com> optimizing: NullCheck elimination

How it works:
- run a type analysis to propagate null information on instructions
- during the last instruction simplifier remove null checks for which
the input is known to be not null

The current type analysis is actually a nullability analysis but it will
be reused in follow up CLs to propagate type information: so it keeps
the more convenient name.

Change-Id: I54bb1d32ab24604b4d677d1ecdaf8d60a5ff5ce9
fa93b504b324784dd9a96e28e6e8f3f1b1ac456a 21-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Do not use HNot for creating !bool.

HNot folds to ~, not !.

Change-Id: I681f968449a2ade7110b2f316146ad16ba5da74c
01fcc9ee556f98d0163cc9b524e989760826926f 01-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Remove type conversion nodes converting to the same type.

When optimizing, we ensure these conversions do not reach the
code generators. When not optimizing, we cannot get such situations.

Change-Id: I717247c957667675dc261183019c88efa3a38452
5e6916cea259897baaca019c5c7a5d05746306ed 18-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Use HOptimization abstraction for running optimizations.

Move existing optimizations to it.

Change-Id: I3b43f9997faf4ed8875162e3a3abdf99375478dd
af07bc121121d7bd7e8329c55dfe24782207b561 12-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Minor object store optimizations.

- Avoid emitting write barrier when the value is null.
- Do not do a typecheck on an arraystore when storing something that
was loaded from the same array.

Change-Id: I902492928692e4553b5af0fc99cce3c2186c442a
1cc5f251df558b0e22cea5000626365eb644c727 22-Oct-2014 Roland Levillain <rpl@google.com> Implement int bit-wise not operation in the optimizing compiler.

- Add support for the not-int (integer one's complement
negate) instruction in the optimizing compiler.
- Extend the HNot control-flow graph node type and make it
inherit from HUnaryOperation.
- Generate ARM, x86 and x86-64 code for integer HNeg nodes.
- Exercise these additions in the codegen_test gtest, as there
is not direct way to assess the support of not-int from a
Java source. Indeed, compiling a Java expression such as
`~a' using javac and then dx generates an xor-int/lit8 Dex
instruction instead of the expected not-int Dex instruction.
This is probably because the Java bytecode has an `ixor'
instruction, but there's not instruction directly
corresponding to a bit-wise not operation.

Change-Id: I223aed75c4dac5785e04d99da0d22e8d699aee2b
01ef345767ea609417fc511e42007705c9667546 01-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Add trivial register hints to the register allocator.

- Add hints for phis, same as first input, and expected registers.
- Make the if instruction accept non-condition instructions.

Change-Id: I34fa68393f0d0c19c68128f017b7a05be556fbe5
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