1 ; RUN: opt < %s -basicaa -dse -S | FileCheck %s 2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 3 4 %struct.vec2 = type { <4 x i32>, <4 x i32> } 5 %struct.vec2plusi = type { <4 x i32>, <4 x i32>, i32 } 6 7 @glob1 = global %struct.vec2 zeroinitializer, align 16 8 @glob2 = global %struct.vec2plusi zeroinitializer, align 16 9 10 define void @write24to28(i32* nocapture %p) nounwind uwtable ssp { 11 ; CHECK-LABEL: @write24to28( 12 entry: 13 %arrayidx0 = getelementptr inbounds i32, i32* %p, i64 1 14 %p3 = bitcast i32* %arrayidx0 to i8* 15 ; CHECK: call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 24, i32 4, i1 false) 16 call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 28, i32 4, i1 false) 17 %arrayidx1 = getelementptr inbounds i32, i32* %p, i64 7 18 store i32 1, i32* %arrayidx1, align 4 19 ret void 20 } 21 22 define void @write28to32(i32* nocapture %p) nounwind uwtable ssp { 23 ; CHECK-LABEL: @write28to32( 24 entry: 25 %p3 = bitcast i32* %p to i8* 26 ; CHECK: call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 28, i32 4, i1 false) 27 call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 32, i32 4, i1 false) 28 %arrayidx1 = getelementptr inbounds i32, i32* %p, i64 7 29 store i32 1, i32* %arrayidx1, align 4 30 ret void 31 } 32 33 define void @dontwrite28to32memset(i32* nocapture %p) nounwind uwtable ssp { 34 ; CHECK-LABEL: @dontwrite28to32memset( 35 entry: 36 %p3 = bitcast i32* %p to i8* 37 ; CHECK: call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 32, i32 16, i1 false) 38 call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 32, i32 16, i1 false) 39 %arrayidx1 = getelementptr inbounds i32, i32* %p, i64 7 40 store i32 1, i32* %arrayidx1, align 4 41 ret void 42 } 43 44 define void @write32to36(%struct.vec2plusi* nocapture %p) nounwind uwtable ssp { 45 ; CHECK-LABEL: @write32to36( 46 entry: 47 %0 = bitcast %struct.vec2plusi* %p to i8* 48 ; CHECK: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2plusi* @glob2 to i8*), i64 32, i32 16, i1 false) 49 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2plusi* @glob2 to i8*), i64 36, i32 16, i1 false) 50 %c = getelementptr inbounds %struct.vec2plusi, %struct.vec2plusi* %p, i64 0, i32 2 51 store i32 1, i32* %c, align 4 52 ret void 53 } 54 55 define void @write16to32(%struct.vec2* nocapture %p) nounwind uwtable ssp { 56 ; CHECK-LABEL: @write16to32( 57 entry: 58 %0 = bitcast %struct.vec2* %p to i8* 59 ; CHECK: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 16, i32 16, i1 false) 60 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 32, i32 16, i1 false) 61 %c = getelementptr inbounds %struct.vec2, %struct.vec2* %p, i64 0, i32 1 62 store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %c, align 4 63 ret void 64 } 65 66 define void @dontwrite28to32memcpy(%struct.vec2* nocapture %p) nounwind uwtable ssp { 67 ; CHECK-LABEL: @dontwrite28to32memcpy( 68 entry: 69 %0 = bitcast %struct.vec2* %p to i8* 70 ; CHECK: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 32, i32 16, i1 false) 71 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 32, i32 16, i1 false) 72 %arrayidx1 = getelementptr inbounds %struct.vec2, %struct.vec2* %p, i64 0, i32 0, i64 7 73 store i32 1, i32* %arrayidx1, align 4 74 ret void 75 } 76 77 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind 78 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind 79 80 %struct.trapframe = type { i64, i64, i64 } 81 82 ; bugzilla 11455 - make sure negative GEP's don't break this optimisation 83 ; CHECK-LABEL: @cpu_lwp_fork( 84 define void @cpu_lwp_fork(%struct.trapframe* %md_regs, i64 %pcb_rsp0) nounwind uwtable noinline ssp { 85 entry: 86 %0 = inttoptr i64 %pcb_rsp0 to %struct.trapframe* 87 %add.ptr = getelementptr inbounds %struct.trapframe, %struct.trapframe* %0, i64 -1 88 %1 = bitcast %struct.trapframe* %add.ptr to i8* 89 %2 = bitcast %struct.trapframe* %md_regs to i8* 90 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* %2, i64 24, i32 1, i1 false) 91 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* %2, i64 24, i32 1, i1 false) 92 %tf_trapno = getelementptr inbounds %struct.trapframe, %struct.trapframe* %0, i64 -1, i32 1 93 store i64 3, i64* %tf_trapno, align 8 94 ret void 95 } 96