- Aug 24, 2023
-
-
Matt Arsenault authored
We were basing the defer the fast case to codegen based on the fdiv itself, and not looking for a foldable sqrt input. https://reviews.llvm.org/D158127
-
Vitaly Buka authored
We can use r11 scratch registers for calculations. It does not result in any performance improvements, as the spill is on the slow path of partial granules. See X86AsmPrinter::LowerASAN_CHECK_MEMACCESS for callers. Reviewed By: kstoimenov Differential Revision: https://reviews.llvm.org/D158525
-
Craig Topper authored
-
Srishti Srivastava authored
Large deep learning models rely on heavy computations. However, not every computation is necessary. And, even when a computation is necessary, it helps if the values needed for the computation are available in registers (which have low-latency) rather than being in memory (which has high-latency). Compilers can use liveness analysis to:- (1) Remove extraneous computations from a program before it executes on hardware, and, (2) Optimize register allocation. Both these tasks help achieve one very important goal: reducing runtime. Recently, liveness analysis was added to MLIR. Thus, this commit uses the recently added liveness analysis utility to try to accomplish task (1). It adds a pass called `remove-dead-values` whose goal is optimization (reducing runtime) by removing unnecessary instructions. Unlike other passes that rely on local information gathered from patterns to accomplish optimization, this pass uses a full analysis of the IR, specifically, liveness analysis, and is thus more powerful. Currently, this pass performs the following optimizations: (A) Removes function arguments that are not live, (B) Removes function return values that are not live across all callers of the function, (C) Removes unneccesary operands, results, region arguments, region terminator operands of region branch ops, and, (D) Removes simple and region branch ops that have all non-live results and don't affect memory in any way, iff the IR doesn't have any non-function symbol ops, non-call symbol user ops and branch ops. Here, a "simple op" refers to an op that isn't a symbol op, symbol-user op, region branch op, branch op, region branch terminator op, or return-like. It is noteworthy that we do not refer to non-live values as "dead" in this file to avoid confusing it with dead code analysis's "dead", which refers to unreachable code (code that never executes on hardware) while "non-live" refers to code that executes on hardware but is unnecessary. Thus, while the removal of dead code helps little in reducing runtime, removing non-live values should theoretically have significant impact (depending on the amount removed). It is also important to note that unlike other passes (like `canonicalize`) that apply op-specific optimizations through patterns, this pass uses different interfaces to handle various types of ops and tries to cover all existing ops through these interfaces. It is because of its reliance on (a) liveness analysis and (b) interfaces that makes it so powerful that it can optimize ops that don't have a canonicalizer and even when an op does have a canonicalizer, it can perform more aggressive optimizations, as observed in the test files associated with this pass. Example of optimization (A):- ``` int add_2_to_y(int x, int y) { return 2 + y } print(add_2_to_y(3, 4)) print(add_2_to_y(5, 6)) ``` becomes ``` int add_2_to_y(int y) { return 2 + y } print(add_2_to_y(4)) print(add_2_to_y(6)) ``` Example of optimization (B):- ``` int, int get_incremented_values(int y) { store y somewhere in memory return y + 1, y + 2 } y1, y2 = get_incremented_values(4) y3, y4 = get_incremented_values(6) print(y2) ``` becomes ``` int get_incremented_values(int y) { store y somewhere in memory return y + 2 } y2 = get_incremented_values(4) y4 = get_incremented_values(6) print(y2) ``` Example of optimization (C):- Assume only `%result1` is live here. Then, ``` %result1, %result2, %result3 = scf.while (%arg1 = %operand1, %arg2 = %operand2) { %terminator_operand2 = add %arg2, %arg2 %terminator_operand3 = mul %arg2, %arg2 %terminator_operand4 = add %arg1, %arg1 scf.condition(%terminator_operand1) %terminator_operand2, %terminator_operand3, %terminator_operand4 } do { ^bb0(%arg3, %arg4, %arg5): %terminator_operand6 = add %arg4, %arg4 %terminator_operand5 = add %arg5, %arg5 scf.yield %terminator_operand5, %terminator_operand6 } ``` becomes ``` %result1, %result2 = scf.while (%arg2 = %operand2) { %terminator_operand2 = add %arg2, %arg2 %terminator_operand3 = mul %arg2, %arg2 scf.condition(%terminator_operand1) %terminator_operand2, %terminator_operand3 } do { ^bb0(%arg3, %arg4): %terminator_operand6 = add %arg4, %arg4 scf.yield %terminator_operand6 } ``` It is interesting to see that `%result2` won't be removed even though it is not live because `%terminator_operand3` forwards to it and cannot be removed. And, that is because it also forwards to `%arg4`, which is live. Example of optimization (D):- ``` int square_and_double_of_y(int y) { square = y ^ 2 double = y * 2 return square, double } sq, do = square_and_double_of_y(5) print(do) ``` becomes ``` int square_and_double_of_y(int y) { double = y * 2 return double } do = square_and_double_of_y(5) print(do) ``` Signed-off-by:Srishti Srivastava <srishtisrivastava.ai@gmail.com> Reviewed By: matthiaskramm, Mogball, jcai19 Differential Revision: https://reviews.llvm.org/D157049
-
Petr Hosek authored
Fuchsia doesn't provide wait4, use waitpid instead. Differential Revision: https://reviews.llvm.org/D155793
-
Matt Arsenault authored
Introducing rsq contract flags is wrong, and also requires some level of approximate functions. AMDGPUCodeGenPrepare already should handle the f32 cases with appropriate flags, and I don't see how new situations to handle would arise during legalization (other than cases involving the rcp intrinsic, which instcombine tries to handle). AMDGPUCodeGenPrepare does need to learn better handling of rcp/rsq for f64 though, which we never bothered to handle well. Removes another obstacle to correctly lowering sqrt. https://reviews.llvm.org/D158099
-
max authored
Just as in https://reviews.llvm.org/D157820, dialect registration is independent of any vendor specific libs having been linked/built/etc. Reviewed By: rkayaith Differential Revision: https://reviews.llvm.org/D158670
-
Matt Arsenault authored
Like the recently added getExactLog2 except ignore the sign bit. https://reviews.llvm.org/D158102
-
Johannes Doerfert authored
When we used to treat the kernel end as as aligned barrier, assertions at the end made sense. Now, they actually cause problems as the "writes" are not ordered with regards to reads within the kernel. We can simply get rid of them.
-
Johannes Doerfert authored
When we remove barriers, we might need to remove llvm.assume assumptions as well. However, doing this early, thus in the module pass, will cause us to miss out on information we might need. There are few situations we can eliminate barriers across functions, for now we simply disable elimination of barriers that require assumptions to be removed during the early module pass.
-
Craig Topper authored
PredicateBitset currently uses std::bitset, but std::bitset doesn't have a constexpr constructor or any constexpr methods until C++23. Each target that supports GlobalIsel has as an array of PredicateBitset objects that currently use a global constructor. SubtargetFeature used by the MC layer for feature bits, has its own implementation of std::bitset that has constexpr constructor and methods that provides all the capabilities that PredicateBitset needs. This patch copies the implementation from SubtargetFeature, makes it a template class, and puts it in ADT. I'll migrate SubtargetFeature in a separate patch. Adapting all existing users to it being a template was distracting from the goal of this patch. This reduces the binary size of llc built with gcc 8.5.0 on my local build by ~15k. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D158576
-
Matt Arsenault authored
Fix "PHI node has multiple entries for the same basic block with different incoming values!" when running operands-to-args. https://reviews.llvm.org/D158422
-
Nitin John Raj authored
We select G_CONSTANT generic opcodes by materializing the constant in a register. G_ANYEXT is replaced with COPY. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D158504
-
Denis Revunov authored
Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D158191
-
Denis Revunov authored
The trap value used by BOLT was assumed to be single-byte instruction. It made some functions unaligned on AArch64(e.g exceptions-instrumentation test) and caused emission failures. Fix that by changing fill value to StringRef. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D158191
-
Tomas Camin authored
Previously the --path-equivalence parameter would allow to specify a single remap pair (coverage data path - local source file path). This patch changes this allowing to pass as many remaps as needed. Reviewed By: keith Differential Revision: https://reviews.llvm.org/D154223
-
Johannes Doerfert authored
When we add an assumption about memory to the AAPointerInfo bins, we should simplify the assumed value, like we do for stores.
-
Johannes Doerfert authored
-
Johannes Doerfert authored
We are having a hard time optimizing some vectorized loads/stores later on which causes this optimization to degrade performance. Differential Revision: https://reviews.llvm.org/D158656
-
Alex Lorenz authored
the CI failure (https://green.lab.llvm.org/green/job/clang-san-iossim/) is being investigated using this issue: https://github.com/llvm/llvm-project/issues/64942 . rdar://113765281
-
Alex Lorenz authored
This reverts commit f24aa691. This change caused these two test failures on Darwin CI: Clang.Tooling.clang-check-mac-libcxx-abspath.cpp Clang.Tooling.clang-check-mac-libcxx-relpath.cpp https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/37169/ More info in https://reviews.llvm.org/D157283
-
David Tellenbach authored
When matching FNEG patterns for the MachineCombiner we need to check for opcodes first, before trying to extract a register from an operand. Otherwise handling of instructions with non-register operands causes the compiler to crash. Differential Revision: https://reviews.llvm.org/D158473
-
Philip Reames authored
Some callers pass in an empty mask to represent "unknown". We should use the generic costs for these cases. We can add VL=1 costing seperately if desired. Reapplying after revert. A new test had been added, and I'd missed updating it when rebasing before. This is a great happy accident as I hadn't figured out how to get SLP to exercise this case, I'd merely noticed it via inspection.
-
Sterling Augustine authored
Previously this was based on target architecture, but that makes very little sense--frame API availability is generally for libgcc compatibility and that is dependent on runtime needs rather than target architecture. Default this to on, so as not to remove the apis from environments that already have them. The functions this macro protects are stubs for libgcc-compatibility. Today, libunwind as a drop-in replacement for libgcc_eh links on x86, x86_64, and powerpc, but not aarch64, which doesn't really make sense. As there is nothing architecture specific about these, they should be provided everywhere or nowhere. The target-specific protection goes all the way back to the original code contribution in 312fcd0e from 2013, so the original reason is lost to history, and probably not relevant today. Differential Revision: https://reviews.llvm.org/D158011
-
Lang Hames authored
Should fix error in https://lab.llvm.org/buildbot/#/builders/84/builds/41540.
-
Philip Reames authored
This reverts commit 2246700e. Seeing buildbot failures; it looks like I rebased over a new test which is effected by the change.
-
Valentin Clement authored
-
Lang Hames authored
By using bootstrap symbols to communicate these addresseses, rather than dlsym lookups, we no longer need them to be exported from the main executable. On ELF, where symbols aren't exported from the main executable by default, this eliminates a common source of missing symbol errors and allows for smaller executables (if exports from the main executable aren't otherwise needed and can be removed).
-
Simon Pilgrim authored
Although we already have fold-and-shift-x86_64.ll - this adds additional test coverage for various and-shift patterns split by sign/zero extensions from i32 index patterns to i64 pointers
-
Philip Reames authored
Some callers pass in an empty mask to represent "unknown". We should use the generic costs for these cases. We can add VL=1 costing seperately if desired.
-
Valentin Clement authored
Lower the acc set directive to the acc.set op. Depends on D158554 Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D158555
-
YunQiang Su authored
Move the code which sets CMake variables for MIPS to compiler-rt/cmake/base-config-ix.cmake from compiler-rt/CMakeLists.txt. compiler-rt/CMakeLists.txt includes compiler-rt/cmake/base-config-ix.cmake very early. If the variables are set in compiler/CMakeLists.txt, compiler-rt/cmake/base-config-ix.cmake cannot use them. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157900
-
Craig Topper authored
This matches the check done by the Reassociate pass that we're trying to reverse. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D158042
-
Fangrui Song authored
This logic from 866faab4 (2012) is no longer needed after D45233 added "Try to match the exact target triple first."
-
Denis Revunov authored
Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D154121
-
Denis Revunov authored
Because indirect call tables use static addresses for call sites, but pc values recorded by runtime may be subject to ASLR in PIE, we couldn't find indirect call descriptions by their runtime address in PIE. It resulted in [unknown] entries in profile for all indirect calls. We need to substract base address of .text from runtime addresses to get the corresponding static addresses. Here we create a getter for base address of .text and substract it's return value from recorded PC values. It converts them to static addresses, which then may be used to find the corresponding indirect call descriptions. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D154121
-
Denis Revunov authored
When a binary is instrumented with --instrumentation-sleep-time and instrumentation-wait-forks options and lauched, the profile is periodically written until all the forks die. The problem is that we cannot wait for the whole process tree, and we have no way to tell when it's safe to read the profile. Hovewer, if we keep profile open throughout the life of the process tree, we can use fuser to determine when writing is finished. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D154436
-
Alexey Bataev authored
-
Florian Hahn authored
Split off mask creation for tail folding and proactively create the mask for the header block. This simplifies createBlockInMask. Reviewed By: Ayal Differential Revision: https://reviews.llvm.org/D157037
-
Peiming Liu authored
We will migrate to a cleaner and more complete implementation. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D158658
-