From 3390e6c4a83b8df00a4e3d22972ba92fce4600ca Mon Sep 17 00:00:00 2001 From: Tilmann Scheller Date: Mon, 26 May 2014 12:15:51 +0000 Subject: [PATCH] [AArch64] Add more regression tests for the load/store optimization pass. Cover the following cases: ldr X, [x0, #32] ... add x0, x0, #32 -> ldr X, [x0, #32]! with X being either w1, x1, s0, d0 or q0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209624 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/AArch64/ldst-opt.ll | 92 ++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 11 deletions(-) diff --git a/test/CodeGen/AArch64/ldst-opt.ll b/test/CodeGen/AArch64/ldst-opt.ll index b2855f38a63..9eeb938cec7 100644 --- a/test/CodeGen/AArch64/ldst-opt.ll +++ b/test/CodeGen/AArch64/ldst-opt.ll @@ -2,30 +2,100 @@ ; This file contains tests for the AArch64 load/store optimizer. -%struct.A = type { %struct.B, %struct.C } -%struct.B = type { i8*, i8*, i8*, i8* } -%struct.C = type { i32, i32 } +%padding = type { i8*, i8*, i8*, i8* } +%s.word = type { i32, i32 } +%s.doubleword = type { i64, i32 } +%s.quadword = type { fp128, i32 } +%s.float = type { float, i32 } +%s.double = type { double, i32 } +%struct.word = type { %padding, %s.word } +%struct.doubleword = type { %padding, %s.doubleword } +%struct.quadword = type { %padding, %s.quadword } +%struct.float = type { %padding, %s.float } +%struct.double = type { %padding, %s.double } ; Check the following transform: ; -; ldr w1, [x0, #32] +; ldr X, [x0, #32] ; ... ; add x0, x0, #32 ; -> -; ldr w1, [x0, #32]! +; ldr X, [x0, #32]! +; +; with X being either w1, x1, s0, d0 or q0. + +declare void @bar_word(%s.word*, i32) -define void @foo(%struct.A* %ptr) nounwind { -; CHECK-LABEL: foo +define void @load-pre-indexed-word(%struct.word* %ptr) nounwind { +; CHECK-LABEL: load-pre-indexed-word ; CHECK: ldr w{{[0-9]+}}, [x{{[0-9]+}}, #32]! entry: - %a = getelementptr inbounds %struct.A* %ptr, i64 0, i32 1, i32 0 + %a = getelementptr inbounds %struct.word* %ptr, i64 0, i32 1, i32 0 %add = load i32* %a, align 4 br label %bar bar: - %c = getelementptr inbounds %struct.A* %ptr, i64 0, i32 1 - tail call void @bar(%struct.C* %c, i32 %add) + %c = getelementptr inbounds %struct.word* %ptr, i64 0, i32 1 + tail call void @bar_word(%s.word* %c, i32 %add) ret void } -declare void @bar(%struct.C*, i32) +declare void @bar_doubleword(%s.doubleword*, i64) + +define void @load-pre-indexed-doubleword(%struct.doubleword* %ptr) nounwind { +; CHECK-LABEL: load-pre-indexed-doubleword +; CHECK: ldr x{{[0-9]+}}, [x{{[0-9]+}}, #32]! +entry: + %a = getelementptr inbounds %struct.doubleword* %ptr, i64 0, i32 1, i32 0 + %add = load i64* %a, align 4 + br label %bar +bar: + %c = getelementptr inbounds %struct.doubleword* %ptr, i64 0, i32 1 + tail call void @bar_doubleword(%s.doubleword* %c, i64 %add) + ret void +} + +declare void @bar_quadword(%s.quadword*, fp128) + +define void @load-pre-indexed-quadword(%struct.quadword* %ptr) nounwind { +; CHECK-LABEL: load-pre-indexed-quadword +; CHECK: ldr q{{[0-9]+}}, [x{{[0-9]+}}, #32]! +entry: + %a = getelementptr inbounds %struct.quadword* %ptr, i64 0, i32 1, i32 0 + %add = load fp128* %a, align 4 + br label %bar +bar: + %c = getelementptr inbounds %struct.quadword* %ptr, i64 0, i32 1 + tail call void @bar_quadword(%s.quadword* %c, fp128 %add) + ret void +} + +declare void @bar_float(%s.float*, float) + +define void @load-pre-indexed-float(%struct.float* %ptr) nounwind { +; CHECK-LABEL: load-pre-indexed-float +; CHECK: ldr s{{[0-9]+}}, [x{{[0-9]+}}, #32]! +entry: + %a = getelementptr inbounds %struct.float* %ptr, i64 0, i32 1, i32 0 + %add = load float* %a, align 4 + br label %bar +bar: + %c = getelementptr inbounds %struct.float* %ptr, i64 0, i32 1 + tail call void @bar_float(%s.float* %c, float %add) + ret void +} + +declare void @bar_double(%s.double*, double) + +define void @load-pre-indexed-double(%struct.double* %ptr) nounwind { +; CHECK-LABEL: load-pre-indexed-double +; CHECK: ldr d{{[0-9]+}}, [x{{[0-9]+}}, #32]! +entry: + %a = getelementptr inbounds %struct.double* %ptr, i64 0, i32 1, i32 0 + %add = load double* %a, align 4 + br label %bar +bar: + %c = getelementptr inbounds %struct.double* %ptr, i64 0, i32 1 + tail call void @bar_double(%s.double* %c, double %add) + ret void +} -- 2.34.1