summaryrefslogtreecommitdiff
path: root/compiler/optimizing/boolean_simplifier.cc
AgeCommit message (Collapse)Author
2016-01-28ART: Implement HSelect David Brazdil
This patch adds a new HIR instruction to Optimizing. HSelect returns one of two inputs based on the outcome of a condition. This is only initial implementation which: - defines the new instruction, - repurposes BooleanSimplifier to emit it, - extends InstructionSimplifier to statically resolve it, - updates existing code and tests accordingly. Code generators currently emit fallback if/then/else code and will be updated in follow-up CLs to use platform-specific conditional moves when possible. Change-Id: Ib61b17146487ebe6b55350c2b589f0b971dcaaee
2015-11-20Simplify boolean condition compared to 0 Mark Mendell
CaffeineMarkRR Logic has some boolean flipping which can be helped by some simplification. Simplify non-FP (A COND_OP B) != 0 to A OPPOSITE_COND_OP B. This is better than the original code, which would use a HBooleanNot after the condition. Also simplify non-FP (A COND_OP B) == 1 to A OPPOSITE_COND_OP B. Move GetOppositeCondition to nodes.h/nodes.cc to share with Boolean Simplification, renaming it to InsertOppositeCondition, as it inserts the new HInstruction (unless it is a constant). Change-Id: I34ded7758836e375de0d6fdba9239d2d451928d0 Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
2015-10-14Added support for unsigned comparisons Aart Bik
Rationale: even though not directly supported in input graph, having the ability to express unsigned comparisons in HIR is useful for all sorts of optimizations. Change-Id: I4543c96a8c1895c3d33aaf85685afbf80fe27d72
2015-10-08Add DCHECKs to ArenaVector and ScopedArenaVector. Vladimir Marko
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
2015-09-08Optimizing: Tag basic block allocations with their source. Vladimir Marko
Replace GrowableArray with ArenaVector in HBasicBlock and, to track the source of allocations, assign one new and two Quick's arena allocation types to these vectors. Rename kArenaAllocSuccessor to kArenaAllocSuccessors. Bug: 23736311 Change-Id: Ib52e51698890675bde61f007fe6039338cf1a025
2015-09-03Revert "Optimizing: Tag basic block allocations with their source." Vladimir Marko
Reverting so that we can have more discussion about the STL API. This reverts commit 91e11c0c840193c6822e66846020b6647de243d5. Change-Id: I187fe52f2c16b6e7c5c9d49c42921eb6c7063dba
2015-09-03Optimizing: Tag basic block allocations with their source. Vladimir Marko
Replace GrowableArray with ArenaVector in HBasicBlock and, to track the source of allocations, assign one new and two Quick's arena allocation types to these vectors. Rename kArenaAllocSuccessor to kArenaAllocSuccessors. Bug: 23736311 Change-Id: I984aef6e615ae2380a532f5c6726af21015f43f5
2015-07-16ART: Boolean simplifier fix Serguei Katkov
Boolean simplifier should not remove condition instruction if it has side effects. Change-Id: I108b69ec05a49e5543ee956ad9c691b52179cf6c Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
2015-07-07Fuse long and FP compare & condition on x86/x86-64 in Optimizing. Mark Mendell
This is a preliminary implementation of fusing long/float/double compares with conditions to avoid materializing the result from the compare and condition. The information from a HCompare is transferred to the HCondition if it is legal. There must be only a single use of the HCompare, the HCompare and HCondition must be in the same block, the HCondition must not need materialization. Added GetOppositeCondition() to HCondition to return the flipped condition. Bug: 21120453 Change-Id: I1f1db206e6dc336270cd71070ed3232dedc754d6 Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
2015-06-24Recompute dominator tree after DCE. Nicolas Geoffray
bug:22031382 Change-Id: Ifebe169897b76872015e3ce0ed7d0a9662f80cef
2015-04-27ART: Simplify Ifs with BooleanNot condition David Brazdil
If statements with negated condition can be simplified by removing the negation and swapping the true and false branches. Change-Id: I197afbc79fb7344d73b7b85d3611e7ca2519717f
2015-04-27ART: Fix removing a Phi with RemoveInstruction David Brazdil
Boolean simplifier might attempt to remove a Phi from the Instruction list. Change-Id: I698cc616549bd88dac96395cb2e5d09b5433d157
2015-04-24ART: Dead block removal David Brazdil
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
2015-04-23ART: Run BooleanSimplifier after inlining David Brazdil
Inlined methods are currently not simplified. Change-Id: I075130c9df55e2f55032a2c81b08d42cb2cc01f6
2015-04-15ART: Implement HBooleanNot instruction David Brazdil
Optimizations simplifying operations on boolean values (boolean simplifier, instruction simplifier) can benefit from having a special HInstruction for negating booleans in order to perform more transforms and produce faster machine code. This patch implements HBooleanNot as 'x xor 1', assuming that booleans are 1-bit integers and allowing for a single-instruction negation on all supported platforms. Change-Id: I33a2649c1821255b18a86ca68ed16416063c739f
2015-03-31ART: General-case negation in boolean simplifier David Brazdil
Code transformations on the HGraph may optimize out the condition instruction of an If and replace it with a boolean value. In such case, the boolean simplifier would not know how to negate the condition and would fail. This patch implements negation in this general case with 'equals 0' as a substitute for the non-existing boolean Not instruction. Bug: 19992954 Change-Id: I152036fcc6bbecccc767d3024a5c060177597d88
2015-03-30ART: Don't fail on unsupported conditions in boolean simplifier Andreas Gampe
Skip simplification instead of FATALing when an unsupported condition is found. Bug: 19992954 Change-Id: Ie2845bead72da63018734e6dd91ce65824658b39
2015-03-26ART: Force constants into the entry block David Brazdil
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
2015-03-25ART: Formatting and comments in BooleanSimplifier David Brazdil
Change-Id: I9a5aa3f2aa8b0a29d7b0f1e5e247397cf8e9e379
2015-03-24ART: Boolean simplifier David Brazdil
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