1 ; RUN: llc -mtriple=aarch64 -mcpu=cortex-a53 < %s | FileCheck %s 2 3 ; Tests to check that zero stores which are generated as STP xzr, xzr aren't 4 ; scheduled incorrectly due to incorrect alias information 5 6 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) 7 %struct.tree_common = type { i8*, i8*, i32 } 8 9 ; Original test case which exhibited the bug 10 define void @test1(%struct.tree_common* %t, i32 %code, i8* %type) { 11 ; CHECK-LABEL: test1: 12 ; CHECK-DAG: stp x2, xzr, [x0, #8] 13 ; CHECK-DAG: str w1, [x0, #16] 14 ; CHECK-DAG: str xzr, [x0] 15 entry: 16 %0 = bitcast %struct.tree_common* %t to i8* 17 tail call void @llvm.memset.p0i8.i64(i8* align 8 %0, i8 0, i64 24, i1 false) 18 %code1 = getelementptr inbounds %struct.tree_common, %struct.tree_common* %t, i64 0, i32 2 19 store i32 %code, i32* %code1, align 8 20 %type2 = getelementptr inbounds %struct.tree_common, %struct.tree_common* %t, i64 0, i32 1 21 store i8* %type, i8** %type2, align 8 22 ret void 23 } 24 25 ; Store to each struct element instead of using memset 26 define void @test2(%struct.tree_common* %t, i32 %code, i8* %type) { 27 ; CHECK-LABEL: test2: 28 ; CHECK-DAG: str w1, [x0, #16] 29 ; CHECK-DAG: stp xzr, x2, [x0] 30 entry: 31 %0 = getelementptr inbounds %struct.tree_common, %struct.tree_common* %t, i64 0, i32 0 32 %1 = getelementptr inbounds %struct.tree_common, %struct.tree_common* %t, i64 0, i32 1 33 %2 = getelementptr inbounds %struct.tree_common, %struct.tree_common* %t, i64 0, i32 2 34 store i8* zeroinitializer, i8** %0, align 8 35 store i8* zeroinitializer, i8** %1, align 8 36 store i32 zeroinitializer, i32* %2, align 8 37 store i32 %code, i32* %2, align 8 38 store i8* %type, i8** %1, align 8 39 ret void 40 } 41 42 ; Vector store instead of memset 43 define void @test3(%struct.tree_common* %t, i32 %code, i8* %type) { 44 ; CHECK-LABEL: test3: 45 ; CHECK-DAG: stp x2, xzr, [x0, #8] 46 ; CHECK-DAG: str w1, [x0, #16] 47 ; CHECK-DAG: str xzr, [x0] 48 entry: 49 %0 = bitcast %struct.tree_common* %t to <3 x i64>* 50 store <3 x i64> zeroinitializer, <3 x i64>* %0, align 8 51 %code1 = getelementptr inbounds %struct.tree_common, %struct.tree_common* %t, i64 0, i32 2 52 store i32 %code, i32* %code1, align 8 53 %type2 = getelementptr inbounds %struct.tree_common, %struct.tree_common* %t, i64 0, i32 1 54 store i8* %type, i8** %type2, align 8 55 ret void 56 } 57 58 ; Vector store, then store to vector elements 59 define void @test4(<3 x i64>* %p, i64 %x, i64 %y) { 60 ; CHECK-LABEL: test4: 61 ; CHECK-DAG: stp x2, x1, [x0, #8] 62 ; CHECK-DAG: str xzr, [x0] 63 entry: 64 store <3 x i64> zeroinitializer, <3 x i64>* %p, align 8 65 %0 = bitcast <3 x i64>* %p to i64* 66 %1 = getelementptr inbounds i64, i64* %0, i64 2 67 store i64 %x, i64* %1, align 8 68 %2 = getelementptr inbounds i64, i64* %0, i64 1 69 store i64 %y, i64* %2, align 8 70 ret void 71 } 72