llvm-project/llvm/test/CodeGen/AArch64/shrink-constant-multiple-users.ll
Momchil Velikov c649fd34e9 [MachineSink][AArch64] Sink instruction copies when they can replace copy into hard register or folded into addressing mode
This patch adds a new code transformation to the `MachineSink` pass,
that tries to sink copies of an instruction, when the copies can be folded
into the addressing modes of load/store instructions, or
replace another instruction (currently, copies into a hard register).

The criteria for performing the transformation is that:
* the register pressure at the sink destination block must not
  exceed the register pressure limits
* the latency and throughput of the load/store or the copy must not deteriorate
* the original instruction must be deleted

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D152828
2023-09-25 10:49:44 +01:00

20 lines
506 B
LLVM

; RUN: llc -mtriple arm64-ios- -aarch64-enable-sink-fold=true %s -o - | FileCheck %s
; Check the -8 constant is shrunk if there are multiple users of the AND instruction.
; CHECK-LABEL: _test:
; CHECK: and x19, x0, #0xfffffff8
; CHECK-NEXT: mov x0, x19
; CHECK-NEXT: bl _user
; CHECK: add x0, x19, #10
define i64 @test(i32 %a) {
%ext = zext i32 %a to i64
%v1 = and i64 %ext, -8
%v2 = add i64 %v1, 10
call void @user(i64 %v1)
ret i64 %v2
}
declare void @user(i64)