llvm-project/llvm/test/CodeGen/SystemZ/int-sub-11.ll

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
566 B
LLVM
Raw Normal View History

[SystemZ, RegAlloc] Favor 3-address instructions during instruction selection. This patch aims to reduce spilling and register moves by using the 3-address versions of instructions per default instead of the 2-address equivalent ones. It seems that both spilling and register moves are improved noticeably generally. Regalloc hints are passed to increase conversions to 2-address instructions which are done in SystemZShortenInst.cpp (after regalloc). Since the SystemZ reg/mem instructions are 2-address (dst and lhs regs are the same), foldMemoryOperandImpl() can no longer trivially fold a spilled source register since the reg/reg instruction is now 3-address. In order to remedy this, new 3-address pseudo memory instructions are used to perform the folding only when the dst and lhs virtual registers are known to be allocated to the same physreg. In order to not let MachineCopyPropagation run and change registers on these transformed instructions (making it 3-address), a new target pass called SystemZPostRewrite.cpp is run just after VirtRegRewriter, that immediately lowers the pseudo to a target instruction. If it would have been possibe to insert a COPY instruction and change a register operand (convert to 2-address) in foldMemoryOperandImpl() while trusting that the caller (e.g. InlineSpiller) would update/repair the involved LiveIntervals, the solution involving pseudo instructions would not have been needed. This is perhaps a potential improvement (see Phabricator post). Common code changes: * A new hook TargetPassConfig::addPostRewrite() is utilized to be able to run a target pass immediately before MachineCopyPropagation. * VirtRegMap is passed as an argument to foldMemoryOperand(). Review: Ulrich Weigand, Quentin Colombet https://reviews.llvm.org/D60888 llvm-svn: 362868
2019-06-08 14:19:15 +08:00
; Test of subtraction that involves a constant as the first operand
;
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
; Check highest 16-bit signed int immediate value.
define i64 @f1(i64 %a) {
; CHECK-LABEL: f1:
; CHECK: lghi %r0, 32767
; CHECK: sgrk %r2, %r0, %r2
; CHECK: br %r14
%sub = sub i64 32767, %a
ret i64 %sub
}
; Check highest 32-bit signed int immediate value.
define i64 @f2(i64 %a) {
; CHECK-LABEL: f2:
; CHECK: lgfi %r0, 2147483647
; CHECK: sgrk %r2, %r0, %r2
; CHECK: br %r14
%sub = sub i64 2147483647, %a
ret i64 %sub
}