79c18cacb8dd29ee02717e1e3826521f35a9dde4
[oota-llvm.git] / test / CodeGen / AArch64 / ldst-opt.ll
1 ; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s
2
3 ; This file contains tests for the AArch64 load/store optimizer.
4
5 %struct.A = type { %struct.B, %struct.C }
6 %struct.B = type { i8*, i8*, i8*, i8* }
7 %struct.C = type { i32, i32 }
8
9 ; Check the following transform:
10 ;
11 ; ldr w1, [x0, #32]
12 ;  ...
13 ; add x0, x0, #32
14 ;  ->
15 ; ldr w1, [x0, #32]!
16  
17 define void @foo(%struct.A* %ptr) nounwind {
18 ; CHECK-LABEL: foo
19 ; CHECK: ldr w{{[0-9]+}}, [x{{[0-9]+}}, #32]!
20 entry:
21   %a = getelementptr inbounds %struct.A* %ptr, i64 0, i32 1, i32 0
22   %add = load i32* %a, align 4
23   br label %bar
24 bar:
25   %c = getelementptr inbounds %struct.A* %ptr, i64 0, i32 1
26   tail call void @bar(%struct.C* %c, i32 %add) 
27   ret void
28 }
29
30 declare void @bar(%struct.C*, i32)
31