summaryrefslogtreecommitdiff
path: root/compiler/optimizing/optimizing_unit_test.h
AgeCommit message (Collapse)Author
2025-02-18Optimizing: Remove dead Partial LSE test helpers. Vladimir Marko
Test: m test-art-host-gtest Bug: 298176183 Change-Id: I25a047e20dd4b0388c639c90634e74a5a626d2ac
2025-02-17Optimizing: Speed up `HInstruction::Add{,Env}UseAt()`. Vladimir Marko
Avoid three dependent loads to fetch the allocator on the hot paths. Inline the `FixupUserRecordsAfter*UseInsertion()` loop and use the fact that it's known to execute exactly one or two iterations. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I7fd4d48caebc6aeb13fb9a9f8146a06129c72b2e
2025-01-23Optimizing: Generate `HSelect` if there are more phis... Vladimir Marko
... as long as they have identical inputs at the relevant indexes. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I40168de61d2dfe1143786a2e4a27549cc54b0451
2025-01-23Optimizing: Remove `CreateDoWhileLoop()`. Vladimir Marko
And do some other gtest cleanup. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I9d2c3241e5cd9f96722284c4654b8b2fd446b104
2025-01-22Optimizing: Test for `HSelect` in irreducible loop. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I32e0ef7956cabb436a1759934e24a1c0f4b7ea2d
2024-11-06Support all conditions in predicated vectorization Chris Jones
Support all condition types inside the condition when performing diamond loop auto-vectorization. This allows diamond loop auto-vectorization to be performed on a greater variety of loops. To support this change, new vector condition nodes are added to mirror the scalar condition nodes. Also add a new gtest class to test whether predicated vectorization can be performed on different combinations of condition types and data types. Authors: Chris Jones <christopher.jones@arm.com>, Konstantin Baladurin <konstantin.baladurin@arm.com> Test: export ART_FORCE_TRY_PREDICATED_SIMD=true && \ art/test.py --target --optimizing Test: art/test.py --target --host --optimizing Test: 661-checker-simd-cf-loops Test: art/test.py --gtest art_compiler_tests Change-Id: Ic9c925f1a58ada13d9031de3b445dcd4f77764b7
2024-10-15Arm64: fix VecPredToBoolean code generation for SVE Konstantin Baladurin
This patch fixes code generation for VecPredToBoolean so it updates conditional flags itself based on its predicate input. Prior to this patch, code generation for VecPredToBoolean (incorrectly) implicitly assumed that the conditional flags were always updated by its input HIR (VecPredWhile) and that it immediately followed that HIR. Authors: Konstantin Baladurin <konstantin.baladurin@arm.com> Chris Jones <christopher.jones@arm.com> Test: env ART_FORCE_TRY_PREDICATED_SIMD=true art/test.py --target --optimizing Test: art/tools/run-gtests.sh Change-Id: Id4c2494cdefd008509f9039e36081151aaf0e4a6
2024-10-15Arm64: Fix PackedSwitch codegen for large methods. Artem Serov
This patch fixes a bug in arm64 PackedSwitch code generation for very large methods where we exceeded the range of Adr instruction - jump tables were emited in the very end of the method. Instead we now emit the jump table in-place as part of the PackedSwitch visitor - in the same way how it is done in arm32 backend. This patch also removes an incorrect assumption that the size of a method has a linear dependency on the number of its HIR instructions. This was used to choose whether to emit a jump table for a PackedSwitch. Test: art/test.py --target --host --optimizing Test: art/test.py --gtest art_compiler_tests Change-Id: I0795811a6408a25021879ab6be9e23ef5f1f50e4
2024-10-11Move `HCondition` creation function to `HCondition`. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ibf7d27af872bf0bc9a91d1698d66047947b513f3
2024-10-07Reland "Calculate the number of out vregs." Vladimír Marko
This reverts commit 434a327234f74eed3ef4072314d2e2bdb73e4dda. Reason for revert: Relanding with no change. The regressions that were the reason for the revert may reappear. However, these regressions are probably caused by subtle effects that are not directly related to this change. For example, a code size improvement can regress performance simply by moving the start of a loop from an aligned address to an unaligned address, or by splitting a loop across two cache lines. Bug: 358519867 Bug: 359722268 Change-Id: I997b8a4219418f79b3a5fc4e7e50817911f0a737
2024-10-04Reduce memory used by `HEnvironment`. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: Ie05d4001e411a669e11b8edda375414e5da52ae2
2024-08-28Add LSE gtests for inserting type conversions. Vladimir Marko
Add tests for the cases where the LSE correctly inserts the required type conversion instructions as needed, as well as tests for currently broken cases. The latter are guarded by `GTEST_SKIP()` until we fix them in a separate change. Test: m test-art-host-gtest Bug: 341476044 Change-Id: Id6002bc31cef542564b84258defcab45b06e6445
2024-08-27ART: Clean up environment construction in gtests. Vladimir Marko
Create required instruction environments in helper functions that create instructions. Test: m test-art-host-gtest Change-Id: Iacdd3c3717d95bc3e7fc3c1b676bc8eb70f2e6bc
2024-08-21Revert "Calculate the number of out vregs." Vladimír Marko
This reverts commit 3e75615ad25b6af1842b194e78b429b0f585b46a. Reason for revert: Regressed some micro-benchmarks, see bug 359722268. Bug: 358519867 Bug: 359722268 Change-Id: I207cc78c88193564e90c98eda2c96a5ba354a588
2024-08-21Change `MakeCondition()` to take `IfCondition`... Vladimir Marko
... instead of the instruction type argument. And continue with loop construction cleanup in gtests. Test: m test-art-host-gtest Change-Id: I8cb83ae0c6d3cdb2a2ee4da0608cfeb69df722eb
2024-08-16ART: Clean up loop construction in gtests. Vladimir Marko
Define and use helper functions for creating loops and linear loop variables. Also remove a dead `HAdd` from one BCE test and change a copy-pasted BCE test for `a[i %200]` to actually test that case (which also reverses the expectation). This change adds extra blocks to some tests, for example empty loop pre-headers, additional return blocks with `HReturnVoid` and a single-goto block to split a critical edge (in `BubbleSortArrayBoundsElimination`). It also adds some extra `HGoto` and `HReturnVoid` instructions and reorders some instructions (linear loop variable increments are added earlier). LSE test helper function `CreateTestControlFlowGraph()` was changed to reorder successors, effectively changing i = 0; do { ... } while (i++ >=128); to i = 0; do { ... } while (i++ < 128); with no impact on the tests using it. `SuperblockClonerTest.IndividualInstrCloner` now clones one additional `HGoto`. Test: m test-art-host-gtest Change-Id: Ie53b07429e62159dee7bfc719c59e06d2609a70e
2024-08-14Clean up condition simplification. Vladimir Marko
Leave condition construction in the `HGraph` but move the rest of the condition simplification code to the simplifier where it belongs. Also clean up simplifier tests and a few other gtests. Note that `SuperblockClonerTest.IndividualInstrCloner` now clones an additional `HGoto` from the entry block. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I73ee8c227c1c100ac7eb9d4a3813c61ad928b6dd
2024-08-13Calculate the number of out vregs. Vladimir Marko
Determine the number of out vregs needed by invokes that actually make a call, and by `HStringBuilderAppend`s. This can yield smaller frame sizes of compiled methods when some calls are inlined or fully intrinsified. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 358519867 Change-Id: I4930a9bd811b1de14658f5ef44e65eadea6a7961
2024-08-12ART: Clean up HIR construction in gtests. Vladimir Marko
Make `OptimizingUnitTestHelper::Make*()` functions add the the new instruction to the block. If the block already ends with a control flow instruction, the new instruction is inserted before the control flow instruction (some tests create the control flow before adding instruction). Add new helper functions for additional instruction types, rename and clean up existing helpers. Test: m test-art-host-gtest Change-Id: I0bb88bc4d2ff6ce98ddbec25990a1ae68f582042
2024-03-25Rename MallocAllocator to CallocAllocator Santiago Aboy Solanes
It was a misnomer since MallocAllocator was internally calling calloc. The difference is that calloc sets the memory to zero which malloc does not. Bug: 329037671 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I77f44df2681b64a25e1d06773b2a2ed150748e00
2024-01-29Optimizing: Remove block reachability information. Vladimir Marko
This code is dead after Partial LSE removal. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 298176183 Change-Id: If67efa9d1df908232b6c2f32f3d2c64fb91759ae
2023-10-16Revert^2 "Remove size argument from DexFile constructors." David Srbecky
This reverts commit 26b99c916496abf14a2fd87290720742328462fa. Reason for revert: Reland Change-Id: Ifc9418a5c76d9d4252c661efe7c13d45ae8810a2
2023-10-13Revert "Remove size argument from DexFile constructors." Nicolas Geoffray
This reverts commit e49ab4d6d4f8226db09803458250f2b9f41abf43. Bug: 305203031 Reason for revert: b/305203031 Change-Id: I7109fcd07b691141f5a67a096688def3b2d6e57e
2023-10-11Remove size argument from DexFile constructors. David Srbecky
We know the DEX size from the DEX header, and we know the range of valid underlying memory from DexFileContainer, so it is redundant. Test: ./art/test.py -b --host 001 Change-Id: I0bd0fe25797ead4df864d97a2bfa8608f75bd694
2023-04-27Optimizing: Add `HInstruction::As##type()`. Vladimir Marko
After the old implementation was renamed in https://android-review.googlesource.com/2526708 , we introduce a new function with the old name but new behavior, just `DCHECK()`-ing the instruction kind before casting down the pointer. We change appropriate calls from `As##type##OrNull()` to `As##type()` to avoid unncessary run-time checks and reduce the size of libart-compiler.so. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 181943478 Change-Id: I025681612a77ca2157fed4886ca47f2053975d4e
2023-04-27Optimizing: Rename `As##type` to `As##type##OrNull`. Vladimir Marko
The null type check in the current implementation of `HInstruction::As##type()` often cannot be optimized away by clang++. It is therefore beneficial to have two functions HInstruction::As##type() HInstruction::As##type##OrNull() where the first function never returns null but the second one can return null. The additional text "OrNull" shall also flag the possibility of yielding null to the developer which may help avoid bugs similar to what we have seen previously. This requires renaming the existing function that can return null and introducing new function that cannot. However, defining the new function `HInstruction::As##type()` in the same change as renaming the old one would risk introducing bugs by missing a rename. Therefore we simply rename the old function here and the new function shall be introduced in a separate change with all behavioral changes being explicit. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: buildbot-build.sh --target Bug: 181943478 Change-Id: I4defd85038e28fe3506903ba3f33f723682b3298
2023-04-27Reland "Don't enable intrinsic optimizations in debuggable runtime"" Mythri Alle
This reverts commit b5fcab944b3786f27ab6b698685109bfc7f785fd. Reason for revert: test/988 is a CTS test and we shouldn't modify the Main to do any real work other than calling run. Also there's no way to call ensureJitCompiled from atests, so restoring 988 to original and adding another test for testing JIT tracing Bug: 279547861 Test: test.py -t 988, 2263 Change-Id: I0908c29996a550b93ba6c38f99460ff0d51a2964
2023-04-25Revert "Don't enable intrinsic optimizations in debuggable runtime" Mythri Alle
This reverts commit cb008914fbc5a2334e3c00366afdb5f8af5a23ba. Reason for revert: Failures on some configs https://buganizer.corp.google.com/issues/279562617 Change-Id: I4d26cd00e76d8ec4aef76ab26987418eab24d217
2023-04-25Don't enable intrinsic optimizations in debuggable runtime Mythri Alle
We have optimizations that generate code inline for intrinsics instead of leaving them as invoke for better performance. Some debug features like method entry / exit or setting a breakpoint on intrinsics wouldn't work if intrinsics are inlined. So disable those optimizations in debuggable runtimes. Also update 988-method-trace test to test intrinsics on JITed code. Test: art/test.py -t 988 Bug: 279547861 Change-Id: Ic7c61d1b1541ff534faa24ccec5c2d0b574b0537
2023-04-05Mark graph visitor classes as final. Vladimir Marko
This should improve optimization opportunities for clang++. Test: buildbot-build.sh Change-Id: Ib0c1ebfb157176a9063cca2ed465cff6fb280442
2023-03-06Add DexFileContainer for all DexFiles. David Srbecky
Ensure that all DexFiles have a container for consistency. Enforce that the container shall contain exactly one dex file, as specified the by file_size entry in the de header (that is, the memory range should not be truncated or too big). Bug: 266950186 Test: test.py -b --host --optimizing --64 Change-Id: I73ff074a980f9a9d5a0f4a9b51ac1a496971374f
2023-02-20Add a handle cache for gtests Santiago Aboy Solanes
ReferenceTypePropagation's BoundTypeForIfNotNull needs the handle cache to exist and could lead to crashes otherwise. Test: m test-art-host-gtest Change-Id: Ic51dc0859a7057107ab600040fb52dfc55469564
2023-02-15Remove RTI validation from our checks Santiago Aboy Solanes
It is possible to have untyped RTI in valid graphs due to e.g. dead code, redundant phis not replaced yet. By removing this validation, we shift the burden of the validation to the user of the RTI. Bug: 252799892 Fixes: 252799892 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: dex2oat compiling the apps in the bug Change-Id: I112497bf10c180b651fd5b6e268799bc3abb27b3
2022-11-07Reland "Make compiler/optimizing/ symbols hidden." Vladimír Marko
This reverts commit 0a51605ddd81635135463dab08b6f7c21b58ffb0. Reason for revert: Reland after some of the required work was merged in other CLs. Also address a TODO from the original CL to mark required symbols with EXPORT in `intrinsic_objects.h`. Also mark symbols in new files as HIDDEN. Bug: 186902856 Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I936d448983928af23614ca82c2d0bf9a645e2c52
2022-06-28Fix bugprone-argument-comment clang-tidy issues Stefano Cianciulli
Test: m tidy-art Bug: 213953102 Change-Id: I5c703033db4fefd1cb3f1dd2dc95126930e28d53
2022-06-20Fix modernize-use-using clang-tidy issues Stefano Cianciulli
All the // NOLINT comments introduced in this CL were meant to disable only the modernize-use-using checks, but changing the comment to be // NOLINT(modernize-use-using) as explained in https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics will make cpplint throw an error, as also cpplint uses the // NOLINT(...) notation to suppress unwanted warnings. Test: m tidy-art Test: art/libnativebridge/tests/runtests.sh Bug: 213953102 Change-Id: I9a992e0f0ecd06f7e64fd0bbf473bec4582370f6
2022-01-10Remove operator<< from HGraph. Nicolas Geoffray
It needs access to a code generator. Test: observe a bogus graph at the point of register allocator, and see that the Dump method crashes. Change-Id: I09a847246428fd3bd0938f9f457773c465da253d
2021-04-26Fix issue with Partial LSE and casts/instanceof Alex Light
If PartialLSE encounters an instanceof or check-cast before the escapes it could not correctly handle it. Due to how java language code is typically developed and compiled this is generally not a problem but could lead to incorrect codegen on release builds or DCHECK failures on debug builds. This fixes the issues by (1) causing partial LSE to consider check-cast and instance-ofs to be escaping. This also updates the instruction simplifier to be much more aggressive in removing instance-of and check-casts. Test: ./test.py --host Bug: 186041085 Change-Id: Ia513c4210a87a0dfa92f10adc530e17ee631d006
2021-03-30Fix simplifier issue with predicated ifield get Alex Light
In cases where all targets of a HPredicatedInstanceFieldGet instruction are known to not be null the simplifier would attempt to replace the default value with a null instruction. This would cause a null-pointer dereference. Correct the simplifier to handle this case correctly. Moved some LSE test helper functions to CommonCompilerTestHelper to avoid duplicating code. Fixed an incorrect (though until now unused) constructor for HPredicatatedInstanceFieldGet (the default value and target we swapped). Test: ./test.py --host Test: ./art/tools/compile_jars.py --profile-file bad-compile.txt ~/imgur.apk Bug: 183942773 Change-Id: I66f4ce37d768d5e457047a3f80bd4cb9aa4546a3
2021-01-25Revert^4 "Partial Load Store Elimination" Alex Light
This reverts commit 791df7a161ecfa28eb69862a4bc285282463b960. This unreverts commit fc1ce4e8be0d977e3d41699f5ec746d68f63c024. This unreverts commit b8686ce4c93eba7192ed7ef89e7ffd9f3aa6cd07. We incorrectly failed to include PredicatedInstanceFieldGet in a few conditions, including a DCHECK. This caused tests to fail under the read-barrier-table-lookup configuration. Reason for revert: Fixed 2 incorrect checks Bug: 67037140 Test: ./art/test/testrunner/run_build_test_target.py -j70 art-gtest-read-barrier-table-lookup Change-Id: I32b01b29fb32077fb5074e7c77a0226bd1fcaab4
2021-01-24Revert "Revert^2 "Partial Load Store Elimination"" Nicolas Geoffray
This reverts commit fc1ce4e8be0d977e3d41699f5ec746d68f63c024. Bug: 67037140 Reason for revert: Fails read-barrier-table-lookup tests. Change-Id: I373867c728789bc14a4370b93a045481167d5f76
2021-01-22Revert^2 "Partial Load Store Elimination" Alex Light
This reverts commit 47ac53100303e7e864b7f6d65f17b23088ccf1d6. There was a bug in LSE where we would incorrectly record the shadow$_monitor_ field as not having a default initial value. This caused partial LSE to be unable to compile the Object.identityHashCode function, causing crashes. This issue was fixed in a parent CL. Also updated all Offsets in LSE_test to be outside of the object header regardless of configuration. Test: ./test.py --host Bug: 67037140 Reason for revert: Fixed issue with shadow$_monitor_ field and offsets Change-Id: I4fb2afff4d410da818db38ed833927dfc0f6be33
2021-01-22Revert "Partial Load Store Elimination" Nicolas Geoffray
This reverts commit b8686ce4c93eba7192ed7ef89e7ffd9f3aa6cd07. Bug: 67037140 Reason for revert: Fails a few tests. Change-Id: Icf0635bffbfbba93bf0a5b854a9582c418198136
2021-01-21Partial Load Store Elimination Alex Light
Add partial load-store elimination to the LSE pass. Partial LSE will move object allocations which only escape along certain execution paths closer to the escape point and allow more values to be eliminated. It does this by creating new predicated load and store instructions that are used when an object has only escaped some of the time. In cases where the object has not escaped a default value will be used. Test: ./test.py --host Test: ./test.py --target Bug: 67037140 Change-Id: Idde67eb59ec90de79747cde17b552eec05b58497
2020-11-18Revert^4 "Partial LSE analysis & store removal" Alex Light
We incorrectly handled merging unknowns in some situations. Specifically in cases where we are unable to materialize loop-phis we could end up with PureUnknowns which could end up hiding stores that need to be kept. In an unrelated issue we were incorrectly considering some values as escapes when live at the point of an invoke. Since SearchPhiPlaceholdersForKeptStores used a more precise notion of escapes we could end up removing stores without being able to replace the values. This reverts commit 2316b3a0779f3721a78681f5c70ed6624ecaebef. This unreverts commit b6837f0350ff66c13582b0e94178dd5ca283ff0a This reverts commit fe270426c8a2a69a8f669339e83b86fbf40e25a1. This unreverts commit bb6cda60e4418c0ab557ea4090e046bed8206763. Bug: 67037140 Bug: 173120044 Reason for revert: Fixed issue causing incorrect store elimination Test: ./test.py --host Test: Boot cuttlefish atest FrameworksServicesTests:com.android.server.job.BackgroundRestrictionsTest#testPowerWhiteList Change-Id: I2ebae9ccfaf5169d551c5019b547589d0fce1dc9
2020-11-14Revert^3 "Partial LSE analysis & store removal" Alex Light
This reverts commit b6837f0350ff66c13582b0e94178dd5ca283ff0a This unreverts commit fe270426c8a2a69a8f669339e83b86fbf40e25a1. This rereverts commit bb6cda60e4418c0ab557ea4090e046bed8206763. Bug: 67037140 Bug: 173120044 Reason for revert: Git-blame seems to point to the CL as cause of b/173120044. Revert during investigation. Change-Id: I46f557ce79c15f07f4e77aacded1926b192754c3
2020-11-13Revert^2 "Partial LSE analysis & store removal" Alex Light
A ScopedArenaAllocator in a single test was accidentally loaded using operator new which is not supported. This caused a memory leak. This reverts commit fe270426c8a2a69a8f669339e83b86fbf40e25a1. This unreverts commit bb6cda60e4418c0ab557ea4090e046bed8206763. Bug: 67037140 Reason for revert: Fixed memory leak in LoadStoreAnalysisTest.PartialEscape test case Test: SANITIZE_HOST=address ASAN_OPTIONS=detect_leaks=0 m test-art-host-gtest-dependencies Run art_compiler_tests Change-Id: I34fa2079df946ae54b8c91fa771a44d56438a719
2020-11-12Revert "Partial LSE analysis & store removal" Nicolas Geoffray
This reverts commit bb6cda60e4418c0ab557ea4090e046bed8206763. Bug: 67037140 Reason for revert: memory leak detected in the test. Change-Id: I81cc2f61494e96964d8be40389eddcd7c66c9266
2020-11-12Partial LSE analysis & store removal Alex Light
This is the first piece of partial LSE for art. This CL adds analysis tools needed to implement partial LSE. More immediately, it improves LSE so that it will remove stores that are provably non-observable based on the location they occur. For example: ``` Foo o = new Foo(); if (xyz) { check(foo); foo.x++; } else { foo.x = 12; } return foo.x; ``` The store of 12 can be removed because the only escape in this method is unreachable and was not executed by the point we reach the store. The main purpose of this CL is to add the analysis tools needed to implement partial Load-Store elimination. Namely it includes tracking of which blocks are escaping and the groups of blocks that we cannot remove allocations from. The actual impact of this change is incredibly minor, being triggered only once in a AOSP code. go/lem shows only minor effects to compile-time and no effect on the compiled code. See go/lem-allight-partial-lse-2 for numbers. Compile time shows an average of 1.4% regression (max regression is 7% with 0.2 noise). This CL adds a new 'reachability' concept to the HGraph. If this has been calculated it allows one to quickly query whether there is any execution path containing two blocks in a given order. This is used to define a notion of sections of graph from which the escape of some allocation is inevitable. Test: art_compiler_tests Test: treehugger Bug: 67037140 Change-Id: I0edc8d6b73f7dd329cb1ea7923080a0abe913ea6
2020-09-16Fix LSE-array overlap issue Alex Light
In cases where an array has overlapping accesses on separate iterations LSE could get confused and incorrectly believe removing array stores is safe even when later iterations rely on the store occurring. For example consider the following code: ``` int do_cal(int len) { if (len < 5) { return -1; } int w[] = new w[len]; int t = 0; for (int i = 5; i < w.length; i++) { w[i] = please_interleave(w[i - 1], w[i - 5]); t = please_select(w[i], i); } return t; } ``` We would either need to materialize 5 PHIs to hold the values `w[i - 1], ..., w[i - 5]` or avoid removing the write to `w[i]`. Our LSE pass is unable to do the former and would (incorrectly) fail to recognize that, by not being able to determine the values of `w[i - 1]` and `w[i-5]` that the later store to `w[i]` must be preserved. Bug: 168446366 Test: ./test.py --host Change-Id: I89772c8bf49ebf6de70f86bd68484e14bd189406