1*9880d681SAndroid Build Coastguard Worker; RUN: opt -memcpyopt -S < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; RUN: opt -passes=memcpyopt -S < %s | FileCheck %s 3*9880d681SAndroid Build Coastguard Worker; rdar://8875553 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker; Memcpyopt shouldn't optimize the second memcpy using the first 6*9880d681SAndroid Build Coastguard Worker; because the first has a smaller size. 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Worker; CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp, i8* getelementptr inbounds (%struct.s, %struct.s* @cell, i32 0, i32 0, i32 0), i32 16, i32 4, i1 false) 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:32:32:32" 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard Worker%struct.s = type { [11 x i8], i32 } 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker@.str = private constant [11 x i8] c"0123456789\00" 15*9880d681SAndroid Build Coastguard Worker@cell = external global %struct.s 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Workerdeclare void @check(%struct.s* byval %p) nounwind 18*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Workerdefine void @foo() nounwind { 21*9880d681SAndroid Build Coastguard Workerentry: 22*9880d681SAndroid Build Coastguard Worker %agg.tmp = alloca %struct.s, align 4 23*9880d681SAndroid Build Coastguard Worker store i32 99, i32* getelementptr inbounds (%struct.s, %struct.s* @cell, i32 0, i32 1), align 4 24*9880d681SAndroid Build Coastguard Worker call void @llvm.memcpy.p0i8.p0i8.i32(i8* getelementptr inbounds (%struct.s, %struct.s* @cell, i32 0, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 11, i32 1, i1 false) 25*9880d681SAndroid Build Coastguard Worker %tmp = getelementptr inbounds %struct.s, %struct.s* %agg.tmp, i32 0, i32 0, i32 0 26*9880d681SAndroid Build Coastguard Worker call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp, i8* getelementptr inbounds (%struct.s, %struct.s* @cell, i32 0, i32 0, i32 0), i32 16, i32 4, i1 false) 27*9880d681SAndroid Build Coastguard Worker call void @check(%struct.s* byval %agg.tmp) 28*9880d681SAndroid Build Coastguard Worker ret void 29*9880d681SAndroid Build Coastguard Worker} 30