llvm-project/llvm/test/CodeGen/AArch64/argument-blocks.ll

198 lines
6.1 KiB
LLVM
Raw Normal View History

; RUN: llc -mtriple=aarch64-apple-ios7.0 -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-DARWINPCS
; RUN: llc -mtriple=aarch64-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-AAPCS
declare void @callee(...)
define float @test_hfa_regs(float, [2 x float] %in) {
; CHECK-LABEL: test_hfa_regs:
; CHECK: fadd s0, s1, s2
%lhs = extractvalue [2 x float] %in, 0
%rhs = extractvalue [2 x float] %in, 1
%sum = fadd float %lhs, %rhs
ret float %sum
}
; Check that the array gets allocated to a contiguous block on the stack (rather
; than the default of 2 8-byte slots).
define float @test_hfa_block([7 x float], [2 x float] %in) {
; CHECK-LABEL: test_hfa_block:
; CHECK: ldp [[LHS:s[0-9]+]], [[RHS:s[0-9]+]], [sp]
; CHECK: fadd s0, [[LHS]], [[RHS]]
%lhs = extractvalue [2 x float] %in, 0
%rhs = extractvalue [2 x float] %in, 1
%sum = fadd float %lhs, %rhs
ret float %sum
}
; Check that an HFA prevents backfilling of VFP registers (i.e. %rhs must go on
; the stack rather than in s7).
define float @test_hfa_block_consume([7 x float], [2 x float] %in, float %rhs) {
; CHECK-LABEL: test_hfa_block_consume:
; CHECK-DAG: ldr [[LHS:s[0-9]+]], [sp]
; CHECK-DAG: ldr [[RHS:s[0-9]+]], [sp, #8]
; CHECK: fadd s0, [[LHS]], [[RHS]]
%lhs = extractvalue [2 x float] %in, 0
%sum = fadd float %lhs, %rhs
ret float %sum
}
define float @test_hfa_stackalign([8 x float], [1 x float], [2 x float] %in) {
; CHECK-LABEL: test_hfa_stackalign:
; CHECK-AAPCS: ldp [[LHS:s[0-9]+]], [[RHS:s[0-9]+]], [sp, #8]
; CHECK-DARWINPCS: ldp [[LHS:s[0-9]+]], [[RHS:s[0-9]+]], [sp, #4]
; CHECK: fadd s0, [[LHS]], [[RHS]]
%lhs = extractvalue [2 x float] %in, 0
%rhs = extractvalue [2 x float] %in, 1
%sum = fadd float %lhs, %rhs
ret float %sum
}
; An HFA that ends up on the stack should not have any effect on where
; integer-based arguments go.
define i64 @test_hfa_ignores_gprs([7 x float], [2 x float] %in, i64, i64 %res) {
; CHECK-LABEL: test_hfa_ignores_gprs:
; CHECK: mov x0, x1
ret i64 %res
}
; [2 x float] should not be promoted to double by the Darwin varargs handling,
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled. Recommiting with compiler time improvements Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner. * Simplify Consecutive Merge Store Candidate Search Now that address aliasing is much less conservative, push through simplified store merging search and chain alias analysis which only checks for parallel stores through the chain subgraph. This is cleaner as the separation of non-interfering loads/stores from the store-merging logic. When merging stores search up the chain through a single load, and finds all possible stores by looking down from through a load and a TokenFactor to all stores visited. This improves the quality of the output SelectionDAG and the output Codegen (save perhaps for some ARM cases where we correctly constructs wider loads, but then promotes them to float operations which appear but requires more expensive constant generation). Some minor peephole optimizations to deal with improved SubDAG shapes (listed below) Additional Minor Changes: 1. Finishes removing unused AliasLoad code 2. Unifies the chain aggregation in the merged stores across code paths 3. Re-add the Store node to the worklist after calling SimplifyDemandedBits. 4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is arbitrary, but seems sufficient to not cause regressions in tests. 5. Remove Chain dependencies of Memory operations on CopyfromReg nodes as these are captured by data dependence 6. Forward loads-store values through tokenfactors containing {CopyToReg,CopyFromReg} Values. 7. Peephole to convert buildvector of extract_vector_elt to extract_subvector if possible (see CodeGen/AArch64/store-merge.ll) 8. Store merging for the ARM target is restricted to 32-bit as some in some contexts invalid 64-bit operations are being generated. This can be removed once appropriate checks are added. This finishes the change Matt Arsenault started in r246307 and jyknight's original patch. Many tests required some changes as memory operations are now reorderable, improving load-store forwarding. One test in particular is worth noting: CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store forwarding converts a load-store pair into a parallel store and a memory-realized bitcast of the same value. However, because we lose the sharing of the explicit and implicit store values we must create another local store. A similar transformation happens before SelectionDAG as well. Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle llvm-svn: 297695
2017-03-14 08:34:14 +08:00
; but should go in an 8-byte aligned slot and can be merged as integer stores.
define void @test_varargs_stackalign() {
; CHECK-LABEL: test_varargs_stackalign:
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled. Recommiting with compiler time improvements Recommitting after fixup of 32-bit aliasing sign offset bug in DAGCombiner. * Simplify Consecutive Merge Store Candidate Search Now that address aliasing is much less conservative, push through simplified store merging search and chain alias analysis which only checks for parallel stores through the chain subgraph. This is cleaner as the separation of non-interfering loads/stores from the store-merging logic. When merging stores search up the chain through a single load, and finds all possible stores by looking down from through a load and a TokenFactor to all stores visited. This improves the quality of the output SelectionDAG and the output Codegen (save perhaps for some ARM cases where we correctly constructs wider loads, but then promotes them to float operations which appear but requires more expensive constant generation). Some minor peephole optimizations to deal with improved SubDAG shapes (listed below) Additional Minor Changes: 1. Finishes removing unused AliasLoad code 2. Unifies the chain aggregation in the merged stores across code paths 3. Re-add the Store node to the worklist after calling SimplifyDemandedBits. 4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is arbitrary, but seems sufficient to not cause regressions in tests. 5. Remove Chain dependencies of Memory operations on CopyfromReg nodes as these are captured by data dependence 6. Forward loads-store values through tokenfactors containing {CopyToReg,CopyFromReg} Values. 7. Peephole to convert buildvector of extract_vector_elt to extract_subvector if possible (see CodeGen/AArch64/store-merge.ll) 8. Store merging for the ARM target is restricted to 32-bit as some in some contexts invalid 64-bit operations are being generated. This can be removed once appropriate checks are added. This finishes the change Matt Arsenault started in r246307 and jyknight's original patch. Many tests required some changes as memory operations are now reorderable, improving load-store forwarding. One test in particular is worth noting: CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store forwarding converts a load-store pair into a parallel store and a memory-realized bitcast of the same value. However, because we lose the sharing of the explicit and implicit store values we must create another local store. A similar transformation happens before SelectionDAG as well. Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle llvm-svn: 297695
2017-03-14 08:34:14 +08:00
; CHECK-DARWINPCS: str {{x[0-9]+}}, [sp, #16]
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction See r230786 and r230794 for similar changes to gep and load respectively. Call is a bit different because it often doesn't have a single explicit type - usually the type is deduced from the arguments, and just the return type is explicit. In those cases there's no need to change the IR. When that's not the case, the IR usually contains the pointer type of the first operand - but since typed pointers are going away, that representation is insufficient so I'm just stripping the "pointerness" of the explicit type away. This does make the IR a bit weird - it /sort of/ reads like the type of the first operand: "call void () %x(" but %x is actually of type "void ()*" and will eventually be just of type "ptr". But this seems not too bad and I don't think it would benefit from repeating the type ("void (), void () * %x(" and then eventually "void (), ptr %x(") as has been done with gep and load. This also has a side benefit: since the explicit type is no longer a pointer, there's no ambiguity between an explicit type and a function that returns a function pointer. Previously this case needed an explicit type (eg: a function returning a void() function was written as "call void () () * @x(" rather than "call void () * @x(" because of the ambiguity between a function returning a pointer to a void() function and a function returning void). No ambiguity means even function pointer return types can just be written alone, without writing the whole function's type. This leaves /only/ the varargs case where the explicit type is required. Given the special type syntax in call instructions, the regex-fu used for migration was a bit more involved in its own unique way (as every one of these is) so here it is. Use it in conjunction with the apply.sh script and associated find/xargs commands I've provided in rr230786 to migrate your out of tree tests. Do let me know if any of this doesn't cover your cases & we can iterate on a more general script/regexes to help others with out of tree tests. About 9 test cases couldn't be automatically migrated - half of those were functions returning function pointers, where I just had to manually delete the function argument types now that we didn't need an explicit function type there. The other half were typedefs of function types used in calls - just had to manually drop the * from those. import fileinput import sys import re pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)') addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$") func_end = re.compile("(?:void.*|\)\s*)\*$") def conv(match, line): if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)): return line return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():] for line in sys.stdin: sys.stdout.write(conv(re.search(pat, line), line)) llvm-svn: 235145
2015-04-17 07:24:18 +08:00
call void(...) @callee([3 x float] undef, [2 x float] [float 1.0, float 2.0])
ret void
}
define i64 @test_smallstruct_block([7 x i64], [2 x i64] %in) {
; CHECK-LABEL: test_smallstruct_block:
; CHECK: ldp [[LHS:x[0-9]+]], [[RHS:x[0-9]+]], [sp]
; CHECK: add x0, [[LHS]], [[RHS]]
%lhs = extractvalue [2 x i64] %in, 0
%rhs = extractvalue [2 x i64] %in, 1
%sum = add i64 %lhs, %rhs
ret i64 %sum
}
; Check that a small struct prevents backfilling of registers (i.e. %rhs
; must go on the stack rather than in x7).
define i64 @test_smallstruct_block_consume([7 x i64], [2 x i64] %in, i64 %rhs) {
; CHECK-LABEL: test_smallstruct_block_consume:
; CHECK-DAG: ldr [[LHS:x[0-9]+]], [sp]
; CHECK-DAG: ldr [[RHS:x[0-9]+]], [sp, #16]
; CHECK: add x0, [[LHS]], [[RHS]]
%lhs = extractvalue [2 x i64] %in, 0
%sum = add i64 %lhs, %rhs
ret i64 %sum
}
define <1 x i64> @test_v1i64_blocked([7 x double], [2 x <1 x i64>] %in) {
; CHECK-LABEL: test_v1i64_blocked:
; CHECK: ldr d0, [sp]
%val = extractvalue [2 x <1 x i64>] %in, 0
ret <1 x i64> %val
}
define <1 x double> @test_v1f64_blocked([7 x double], [2 x <1 x double>] %in) {
; CHECK-LABEL: test_v1f64_blocked:
; CHECK: ldr d0, [sp]
%val = extractvalue [2 x <1 x double>] %in, 0
ret <1 x double> %val
}
define <2 x i32> @test_v2i32_blocked([7 x double], [2 x <2 x i32>] %in) {
; CHECK-LABEL: test_v2i32_blocked:
; CHECK: ldr d0, [sp]
%val = extractvalue [2 x <2 x i32>] %in, 0
ret <2 x i32> %val
}
define <2 x float> @test_v2f32_blocked([7 x double], [2 x <2 x float>] %in) {
; CHECK-LABEL: test_v2f32_blocked:
; CHECK: ldr d0, [sp]
%val = extractvalue [2 x <2 x float>] %in, 0
ret <2 x float> %val
}
define <4 x i16> @test_v4i16_blocked([7 x double], [2 x <4 x i16>] %in) {
; CHECK-LABEL: test_v4i16_blocked:
; CHECK: ldr d0, [sp]
%val = extractvalue [2 x <4 x i16>] %in, 0
ret <4 x i16> %val
}
define <4 x half> @test_v4f16_blocked([7 x double], [2 x <4 x half>] %in) {
; CHECK-LABEL: test_v4f16_blocked:
; CHECK: ldr d0, [sp]
%val = extractvalue [2 x <4 x half>] %in, 0
ret <4 x half> %val
}
define <8 x i8> @test_v8i8_blocked([7 x double], [2 x <8 x i8>] %in) {
; CHECK-LABEL: test_v8i8_blocked:
; CHECK: ldr d0, [sp]
%val = extractvalue [2 x <8 x i8>] %in, 0
ret <8 x i8> %val
}
define <2 x i64> @test_v2i64_blocked([7 x double], [2 x <2 x i64>] %in) {
; CHECK-LABEL: test_v2i64_blocked:
; CHECK: ldr q0, [sp]
%val = extractvalue [2 x <2 x i64>] %in, 0
ret <2 x i64> %val
}
define <2 x double> @test_v2f64_blocked([7 x double], [2 x <2 x double>] %in) {
; CHECK-LABEL: test_v2f64_blocked:
; CHECK: ldr q0, [sp]
%val = extractvalue [2 x <2 x double>] %in, 0
ret <2 x double> %val
}
define <4 x i32> @test_v4i32_blocked([7 x double], [2 x <4 x i32>] %in) {
; CHECK-LABEL: test_v4i32_blocked:
; CHECK: ldr q0, [sp]
%val = extractvalue [2 x <4 x i32>] %in, 0
ret <4 x i32> %val
}
define <4 x float> @test_v4f32_blocked([7 x double], [2 x <4 x float>] %in) {
; CHECK-LABEL: test_v4f32_blocked:
; CHECK: ldr q0, [sp]
%val = extractvalue [2 x <4 x float>] %in, 0
ret <4 x float> %val
}
define <8 x i16> @test_v8i16_blocked([7 x double], [2 x <8 x i16>] %in) {
; CHECK-LABEL: test_v8i16_blocked:
; CHECK: ldr q0, [sp]
%val = extractvalue [2 x <8 x i16>] %in, 0
ret <8 x i16> %val
}
define <8 x half> @test_v8f16_blocked([7 x double], [2 x <8 x half>] %in) {
; CHECK-LABEL: test_v8f16_blocked:
; CHECK: ldr q0, [sp]
%val = extractvalue [2 x <8 x half>] %in, 0
ret <8 x half> %val
}
define <16 x i8> @test_v16i8_blocked([7 x double], [2 x <16 x i8>] %in) {
; CHECK-LABEL: test_v16i8_blocked:
; CHECK: ldr q0, [sp]
%val = extractvalue [2 x <16 x i8>] %in, 0
ret <16 x i8> %val
}
define half @test_f16_blocked([7 x double], [2 x half] %in) {
; CHECK-LABEL: test_f16_blocked:
; CHECK: ldr h0, [sp]
%val = extractvalue [2 x half] %in, 0
ret half %val
}