56 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4; See https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20210412/904154.html5; When replacing an allocation that is only modified by a memcpy/memmove from6; a constant whose alignment is equal to or exceeds that of the allocation,7; we also need to ensure that we actually can replace all uses of an alloca8; with said constant. This matters because it could be e.g. a select between9; two constants, that happens after the first use of an alloca.10 11%t0 = type { ptr, i64 }12 13@g0 = external constant %t014@g1 = external constant %t015define void @test(ptr %out) {16; CHECK-LABEL: @test(17; CHECK-NEXT: [[I0:%.*]] = alloca [[T0:%.*]], align 818; CHECK-NEXT: [[I2:%.*]] = call i1 @get_cond()19; CHECK-NEXT: [[I3:%.*]] = select i1 [[I2]], ptr @g0, ptr @g120; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) [[I0]], ptr noundef nonnull align 8 dereferenceable(16) [[I3]], i64 16, i1 false)21; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) [[OUT:%.*]], ptr noundef nonnull align 8 dereferenceable(16) [[I0]], i64 16, i1 false)22; CHECK-NEXT: ret void23;24 %i0 = alloca %t025 %i2 = call i1 @get_cond()26 %i3 = select i1 %i2, ptr @g0, ptr @g127 call void @llvm.memcpy.p0.p0.i64(ptr %i0, ptr %i3, i64 16, i1 false)28 call void @llvm.memcpy.p0.p0.i64(ptr %out, ptr %i0, i64 16, i1 false)29 ret void30}31 32define void @test2() {33; CHECK-LABEL: @test2(34; CHECK-NEXT: bb:35; CHECK-NEXT: [[I:%.*]] = alloca [[T0:%.*]], align 836; CHECK-NEXT: [[I1:%.*]] = call i32 @func(ptr undef)37; CHECK-NEXT: [[I2:%.*]] = icmp eq i32 [[I1]], 250338; CHECK-NEXT: [[I3:%.*]] = select i1 [[I2]], ptr @g0, ptr @g139; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) [[I]], ptr noundef nonnull align 8 dereferenceable(16) [[I3]], i64 16, i1 false)40; CHECK-NEXT: [[I5:%.*]] = call i32 @func(ptr nonnull byval([[T0]]) [[I]])41; CHECK-NEXT: unreachable42;43bb:44 %i = alloca %t0, align 845 %i1 = call i32 @func(ptr undef)46 %i2 = icmp eq i32 %i1, 250347 %i3 = select i1 %i2, ptr @g0, ptr @g148 call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %i, ptr noundef nonnull align 8 dereferenceable(16) %i3, i64 16, i1 false)49 %i5 = call i32 @func(ptr nonnull byval(%t0) %i)50 unreachable51}52 53declare i32 @func(ptr)54declare i1 @get_cond()55declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)56