brintos

brintos / llvm-project-archived public Read only

0
0
Text · 20.3 KiB · f10ba1e Raw
441 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"4@C.0.1248 = internal constant [128 x float] [ float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00 ], align 32		; <ptr> [#uses=1]5 6define float @test1(i32 %hash, float %x, float %y, float %z, float %w) {7; CHECK-LABEL: @test1(8; CHECK-NEXT:  entry:9; CHECK-NEXT:    [[T3:%.*]] = shl i32 [[HASH:%.*]], 210; CHECK-NEXT:    [[T5:%.*]] = and i32 [[T3]], 12411; CHECK-NEXT:    [[TMP0:%.*]] = zext nneg i32 [[T5]] to i6412; CHECK-NEXT:    [[T753:%.*]] = getelementptr float, ptr @C.0.1248, i64 [[TMP0]]13; CHECK-NEXT:    [[T9:%.*]] = load float, ptr [[T753]], align 414; CHECK-NEXT:    [[T11:%.*]] = fmul float [[T9]], [[X:%.*]]15; CHECK-NEXT:    [[T13:%.*]] = fadd float [[T11]], 0.000000e+0016; CHECK-NEXT:    [[TMP1:%.*]] = zext nneg i32 [[T5]] to i6417; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr float, ptr @C.0.1248, i64 [[TMP1]]18; CHECK-NEXT:    [[T1851:%.*]] = getelementptr i8, ptr [[TMP2]], i64 419; CHECK-NEXT:    [[T19:%.*]] = load float, ptr [[T1851]], align 420; CHECK-NEXT:    [[T21:%.*]] = fmul float [[T19]], [[Y:%.*]]21; CHECK-NEXT:    [[T23:%.*]] = fadd float [[T21]], [[T13]]22; CHECK-NEXT:    [[TMP3:%.*]] = zext nneg i32 [[T5]] to i6423; CHECK-NEXT:    [[TMP4:%.*]] = getelementptr float, ptr @C.0.1248, i64 [[TMP3]]24; CHECK-NEXT:    [[T2849:%.*]] = getelementptr i8, ptr [[TMP4]], i64 825; CHECK-NEXT:    [[T29:%.*]] = load float, ptr [[T2849]], align 426; CHECK-NEXT:    [[T31:%.*]] = fmul float [[T29]], [[Z:%.*]]27; CHECK-NEXT:    [[T33:%.*]] = fadd float [[T31]], [[T23]]28; CHECK-NEXT:    [[TMP5:%.*]] = zext nneg i32 [[T5]] to i6429; CHECK-NEXT:    [[TMP6:%.*]] = getelementptr float, ptr @C.0.1248, i64 [[TMP5]]30; CHECK-NEXT:    [[T3847:%.*]] = getelementptr i8, ptr [[TMP6]], i64 1231; CHECK-NEXT:    [[T39:%.*]] = load float, ptr [[T3847]], align 432; CHECK-NEXT:    [[T41:%.*]] = fmul float [[T39]], [[W:%.*]]33; CHECK-NEXT:    [[T43:%.*]] = fadd float [[T41]], [[T33]]34; CHECK-NEXT:    ret float [[T43]]35;36entry:37  %lookupTable = alloca [128 x float], align 1638  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %lookupTable, ptr align 16 @C.0.1248, i64 512, i1 false)39 40 41  %t3 = shl i32 %hash, 242  %t5 = and i32 %t3, 12443  %t753 = getelementptr [128 x float], ptr %lookupTable, i32 0, i32 %t544  %t9 = load float, ptr %t75345  %t11 = fmul float %t9, %x46  %t13 = fadd float %t11, 0.000000e+0047  %t17.sum52 = or i32 %t5, 148  %t1851 = getelementptr [128 x float], ptr %lookupTable, i32 0, i32 %t17.sum5249  %t19 = load float, ptr %t185150  %t21 = fmul float %t19, %y51  %t23 = fadd float %t21, %t1352  %t27.sum50 = or i32 %t5, 253  %t2849 = getelementptr [128 x float], ptr %lookupTable, i32 0, i32 %t27.sum5054  %t29 = load float, ptr %t284955  %t31 = fmul float %t29, %z56  %t33 = fadd float %t31, %t2357  %t37.sum48 = or i32 %t5, 358  %t3847 = getelementptr [128 x float], ptr %lookupTable, i32 0, i32 %t37.sum4859  %t39 = load float, ptr %t384760  %t41 = fmul float %t39, %w61  %t43 = fadd float %t41, %t3362  ret float %t4363}64 65declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind66declare void @llvm.memcpy.p1.p0.i64(ptr addrspace(1) nocapture, ptr nocapture, i64, i1) nounwind67declare void @llvm.memcpy.p0.p1.i64(ptr nocapture, ptr addrspace(1) nocapture, i64, i1) nounwind68declare void @llvm.memcpy.p1.p1.i64(ptr addrspace(1) nocapture, ptr addrspace(1) nocapture, i64, i1) nounwind69 70%T = type { i8, [123 x i8] }71%U = type { i32, i32, i32, i32, i32 }72 73@G = constant %T {i8 1, [123 x i8] zeroinitializer }74@H = constant [2 x %U] zeroinitializer, align 1675@I = internal addrspace(1) constant [4 x float] zeroinitializer , align 476 77define void @test2() {78; CHECK-LABEL: @test2(79; CHECK-NEXT:    [[B:%.*]] = alloca [[T:%.*]], align 880; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(124) [[B]], ptr noundef nonnull align 16 dereferenceable(124) @G, i64 124, i1 false)81; CHECK-NEXT:    call void @bar(ptr nonnull [[B]])82; CHECK-NEXT:    ret void83;84  %A = alloca %T85  %B = alloca %T86 87 88; %A alloca is deleted89 90; use @G instead of %A91  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @G, i64 124, i1 false)92  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %B, ptr align 4 %A, i64 124, i1 false)93  call void @bar(ptr %B)94  ret void95}96 97define void @test2_no_null_opt() #0 {98; CHECK-LABEL: @test2_no_null_opt(99; CHECK-NEXT:    [[B:%.*]] = alloca [[T:%.*]], align 8100; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(124) [[B]], ptr noundef nonnull align 16 dereferenceable(124) @G, i64 124, i1 false)101; CHECK-NEXT:    call void @bar(ptr nonnull [[B]])102; CHECK-NEXT:    ret void103;104  %A = alloca %T105  %B = alloca %T106 107 108; %A alloca is deleted109 110; use @G instead of %A111  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @G, i64 124, i1 false)112  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %B, ptr align 4 %A, i64 124, i1 false)113  call void @bar(ptr %B)114  ret void115}116 117define void @test2_addrspacecast() {118; CHECK-LABEL: @test2_addrspacecast(119; CHECK-NEXT:    [[B:%.*]] = alloca [[T:%.*]], align 8120; CHECK-NEXT:    [[B_CAST:%.*]] = addrspacecast ptr [[B]] to ptr addrspace(1)121; CHECK-NEXT:    call void @llvm.memcpy.p1.p1.i64(ptr addrspace(1) noundef align 4 dereferenceable(124) [[B_CAST]], ptr addrspace(1) noundef align 4 dereferenceable(124) addrspacecast (ptr @G to ptr addrspace(1)), i64 124, i1 false)122; CHECK-NEXT:    call void @bar_as1(ptr addrspace(1) [[B_CAST]])123; CHECK-NEXT:    ret void124;125  %A = alloca %T126  %B = alloca %T127  %a.cast = addrspacecast ptr %A to ptr addrspace(1)128  %b.cast = addrspacecast ptr %B to ptr addrspace(1)129 130 131; %A alloca is deleted132; This doesn't exactly match what test2 does, because folding the type133; cast into the alloca doesn't work for the addrspacecast yet.134 135; use @G instead of %A136  call void @llvm.memcpy.p1.p0.i64(ptr addrspace(1) align 4 %a.cast, ptr align 4 @G, i64 124, i1 false)137  call void @llvm.memcpy.p1.p1.i64(ptr addrspace(1) align 4 %b.cast, ptr addrspace(1) align 4 %a.cast, i64 124, i1 false)138  call void @bar_as1(ptr addrspace(1) %b.cast)139  ret void140}141 142declare void @bar(ptr nocapture)143declare void @bar_may_capture(ptr)144declare void @bar_as1(ptr addrspace(1) nocapture)145 146 147;; Should be able to eliminate the alloca.148define void @test3_nocapture() {149; CHECK-LABEL: @test3_nocapture(150; CHECK-NEXT:    call void @bar(ptr nonnull @G) #[[ATTR3:[0-9]+]]151; CHECK-NEXT:    ret void152;153  %A = alloca %T154  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @G, i64 124, i1 false)155  call void @bar(ptr %A) readonly156  ret void157}158 159; Can not eliminate the alloca, as the function may capture its address.160define void @test3_may_capture() {161; CHECK-LABEL: @test3_may_capture(162; CHECK-NEXT:    [[A:%.*]] = alloca [[T:%.*]], align 8163; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(124) [[A]], ptr noundef nonnull align 16 dereferenceable(124) @G, i64 124, i1 false)164; CHECK-NEXT:    call void @bar_may_capture(ptr nonnull [[A]]) #[[ATTR3]]165; CHECK-NEXT:    ret void166;167  %A = alloca %T168  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @G, i64 124, i1 false)169  call void @bar_may_capture(ptr %A) readonly170  ret void171}172 173define void @test3_addrspacecast() {174; CHECK-LABEL: @test3_addrspacecast(175; CHECK-NEXT:    call void @bar(ptr nonnull @G) #[[ATTR3]]176; CHECK-NEXT:    ret void177;178  %A = alloca %T179  call void @llvm.memcpy.p0.p1.i64(ptr align 4 %A, ptr addrspace(1) align 4 addrspacecast (ptr @G to ptr addrspace(1)), i64 124, i1 false)180  call void @bar(ptr %A) readonly181  ret void182}183 184 185define void @test4() {186; CHECK-LABEL: @test4(187; CHECK-NEXT:    call void @baz(ptr nonnull byval(i8) @G)188; CHECK-NEXT:    ret void189;190  %A = alloca %T191  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @G, i64 124, i1 false)192  call void @baz(ptr byval(i8) %A)193  ret void194}195 196declare void @llvm.lifetime.start.p0(ptr)197define void @test5() {198; CHECK-LABEL: @test5(199; CHECK-NEXT:    call void @baz(ptr nonnull byval(i8) @G)200; CHECK-NEXT:    ret void201;202  %A = alloca %T203  call void @llvm.lifetime.start.p0(ptr %A)204  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @G, i64 124, i1 false)205  call void @baz(ptr byval(i8) %A)206  ret void207}208 209 210declare void @baz(ptr byval(i8))211 212 213define void @test6() {214; CHECK-LABEL: @test6(215; CHECK-NEXT:    call void @bar(ptr nonnull @H) #[[ATTR3]]216; CHECK-NEXT:    ret void217;218  %A = alloca %U, align 16219  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %A, ptr align 16 @H, i64 20, i1 false)220  call void @bar(ptr %A) readonly221  ret void222}223 224define void @test7() {225; CHECK-LABEL: @test7(226; CHECK-NEXT:    call void @bar(ptr nonnull @H) #[[ATTR3]]227; CHECK-NEXT:    ret void228;229  %A = alloca %U, align 16230  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @H, i64 20, i1 false)231  call void @bar(ptr %A) readonly232  ret void233}234 235define void @test8() {236; CHECK-LABEL: @test8(237; CHECK-NEXT:    [[AL:%.*]] = alloca [[U:%.*]], align 16238; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) [[AL]], ptr noundef nonnull align 4 dereferenceable(20) getelementptr inbounds nuw (i8, ptr @H, i64 20), i64 20, i1 false)239; CHECK-NEXT:    call void @bar(ptr nonnull [[AL]]) #[[ATTR3]]240; CHECK-NEXT:    ret void241;242  %al = alloca %U, align 16243  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %al, ptr align 4 getelementptr ([2 x %U], ptr @H, i64 0, i32 1), i64 20, i1 false)244  call void @bar(ptr %al) readonly245  ret void246}247 248 249define void @test8_addrspacecast() {250; CHECK-LABEL: @test8_addrspacecast(251; CHECK-NEXT:    [[AL:%.*]] = alloca [[U:%.*]], align 16252; CHECK-NEXT:    call void @llvm.memcpy.p0.p1.i64(ptr noundef nonnull align 16 dereferenceable(20) [[AL]], ptr addrspace(1) noundef align 4 dereferenceable(20) addrspacecast (ptr getelementptr inbounds nuw (i8, ptr @H, i64 20) to ptr addrspace(1)), i64 20, i1 false)253; CHECK-NEXT:    call void @bar(ptr nonnull [[AL]]) #[[ATTR3]]254; CHECK-NEXT:    ret void255;256  %Al = alloca %U, align 16257  call void @llvm.memcpy.p0.p1.i64(ptr align 4 %Al, ptr addrspace(1) align 4 addrspacecast (ptr getelementptr ([2 x %U], ptr @H, i64 0, i32 1) to ptr addrspace(1)), i64 20, i1 false)258  call void @bar(ptr %Al) readonly259  ret void260}261 262define void @test9() {263; CHECK-LABEL: @test9(264; CHECK-NEXT:    call void @bar(ptr nonnull getelementptr inbounds nuw (i8, ptr @H, i64 20)) #[[ATTR3]]265; CHECK-NEXT:    ret void266;267  %A = alloca %U, align 4268  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 getelementptr ([2 x %U], ptr @H, i64 0, i32 1), i64 20, i1 false)269  call void @bar(ptr %A) readonly270  ret void271}272 273define void @test9_addrspacecast() {274; CHECK-LABEL: @test9_addrspacecast(275; CHECK-NEXT:    call void @bar(ptr nonnull getelementptr inbounds nuw (i8, ptr @H, i64 20)) #[[ATTR3]]276; CHECK-NEXT:    ret void277;278  %A = alloca %U, align 4279  call void @llvm.memcpy.p0.p1.i64(ptr align 4 %A, ptr addrspace(1) align 4 addrspacecast (ptr getelementptr ([2 x %U], ptr @H, i64 0, i32 1) to ptr addrspace(1)), i64 20, i1 false)280  call void @bar(ptr %A) readonly281  ret void282}283 284@bbb = local_unnamed_addr global [1000000 x i8] zeroinitializer, align 16285@_ZL3KKK = internal unnamed_addr constant [3 x i8] c"\01\01\02", align 1286 287; Should not replace alloca with global because of size mismatch.288define void @test9_small_global() {289; CHECK-LABEL: @test9_small_global(290; CHECK-NEXT:  entry:291; CHECK-NEXT:    [[CC:%.*]] = alloca [1000000 x i8], align 16292; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(3) [[CC]], ptr noundef nonnull align 16 dereferenceable(3) @_ZL3KKK, i64 3, i1 false)293; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(1000000) @bbb, ptr noundef nonnull align 16 dereferenceable(1000000) [[CC]], i64 1000000, i1 false)294; CHECK-NEXT:    ret void295;296entry:297  %cc = alloca [1000000 x i8], align 16298  call void @llvm.memcpy.p0.p0.i64(ptr %cc, ptr @_ZL3KKK, i64 3, i1 false)299  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @bbb, ptr align 16 %cc, i64 1000000, i1 false)300  ret void301}302 303; Should replace alloca with global as they have exactly the same size.304define void @test10_same_global() {305; CHECK-LABEL: @test10_same_global(306; CHECK-NEXT:  entry:307; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(3) @bbb, ptr noundef nonnull align 16 dereferenceable(3) @_ZL3KKK, i64 3, i1 false)308; CHECK-NEXT:    ret void309;310entry:311  %cc = alloca [3 x i8], align 1312  call void @llvm.memcpy.p0.p0.i64(ptr %cc, ptr @_ZL3KKK, i64 3, i1 false)313  call void @llvm.memcpy.p0.p0.i64(ptr @bbb, ptr %cc, i64 3, i1 false)314  ret void315}316 317; Should replace alloca with global even when the global is in a different address space318define float @test11(i64 %i) {319; CHECK-LABEL: @test11(320; CHECK-NEXT:  entry:321; CHECK-NEXT:    ret float 0.000000e+00322;323 324entry:325  %a = alloca [4 x float], align 4326  call void @llvm.lifetime.start.p0(ptr %a)327  call void @llvm.memcpy.p0.p1.i64(ptr align 4 %a, ptr addrspace(1) align 4 @I, i64 16, i1 false)328  %g = getelementptr inbounds [4 x float], ptr %a, i64 0, i64 %i329  %r = load float, ptr %g, align 4330  ret float %r331}332 333; If the memcpy is volatile, it should not be removed334define float @test11_volatile(i64 %i) {335; CHECK-LABEL: @test11_volatile(336; CHECK-NEXT:  entry:337; CHECK-NEXT:    [[A:%.*]] = alloca [4 x float], align 4338; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr nonnull [[A]])339; CHECK-NEXT:    call void @llvm.memcpy.p0.p1.i64(ptr align 4 [[A]], ptr addrspace(1) align 4 @I, i64 16, i1 true)340; CHECK-NEXT:    [[G:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[I:%.*]]341; CHECK-NEXT:    [[R:%.*]] = load float, ptr [[G]], align 4342; CHECK-NEXT:    ret float [[R]]343;344 345entry:346  %a = alloca [4 x float], align 4347  call void @llvm.lifetime.start.p0(ptr %a)348  call void @llvm.memcpy.p0.p1.i64(ptr align 4 %a, ptr addrspace(1) align 4 @I, i64 16, i1 true)349  %g = getelementptr inbounds [4 x float], ptr %a, i64 0, i64 %i350  %r = load float, ptr %g, align 4351  ret float %r352}353 354; Tests that we can eliminate allocas copied from readonly noalias pointers.355define void @memcpy_from_readonly_noalias(ptr readonly noalias align 8 dereferenceable(124) %arg) {356; CHECK-LABEL: @memcpy_from_readonly_noalias(357; CHECK-NEXT:    call void @bar(ptr nonnull [[ARG:%.*]]) #[[ATTR3]]358; CHECK-NEXT:    ret void359;360  %alloca = alloca %T, align 8361  call void @llvm.memcpy.p0.p0.i64(ptr %alloca, ptr %arg, i64 124, i1 false)362  call void @bar(ptr %alloca) readonly363  ret void364}365 366; Tests that we don't eliminate allocas copied from readonly pointers without noalias.367define void @memcpy_from_just_readonly(ptr readonly align 8 dereferenceable(124) %arg) {368; CHECK-LABEL: @memcpy_from_just_readonly(369; CHECK-NEXT:    [[ALLOCA:%.*]] = alloca [[T:%.*]], align 8370; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(124) [[ALLOCA]], ptr noundef nonnull align 8 dereferenceable(124) [[ARG:%.*]], i64 124, i1 false)371; CHECK-NEXT:    call void @bar(ptr nonnull [[ALLOCA]]) #[[ATTR3]]372; CHECK-NEXT:    ret void373;374  %alloca = alloca %T, align 8375  call void @llvm.memcpy.p0.p0.i64(ptr %alloca, ptr %arg, i64 124, i1 false)376  call void @bar(ptr %alloca) readonly377  ret void378}379 380; Test that we don't elide a volatile memcpy.381define void @volatile_memcpy() {382; CHECK-LABEL: @volatile_memcpy(383; CHECK-NEXT:    [[A:%.*]] = alloca [[U:%.*]], align 16384; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[A]], ptr align 4 @H, i64 20, i1 true)385; CHECK-NEXT:    call void @bar(ptr nonnull [[A]]) #[[ATTR3]]386; CHECK-NEXT:    ret void387;388  %A = alloca %U, align 16389  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @H, i64 20, i1 true)390  call void @bar(ptr %A) readonly391  ret void392}393 394; Test that we can elide a memcpy when copying a constant value onto the stack395; and then forwarding it by readonly nocapture reference.396define void @memcpy_to_nocapture_readonly() {397; CHECK-LABEL: @memcpy_to_nocapture_readonly(398; CHECK-NEXT:    call void @bar(ptr nonnull readonly captures(none) @H)399; CHECK-NEXT:    ret void400;401  %A = alloca %U, align 16402  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @H, i64 20, i1 false)403  call void @bar(ptr nocapture readonly %A)404  ret void405}406 407; Test that we don't elide the memcpy when copying a constant value onto the408; stack and then forwarding it by readonly, but capturing, reference.409define void @memcpy_to_capturing_readonly() {410; CHECK-LABEL: @memcpy_to_capturing_readonly(411; CHECK-NEXT:    [[A:%.*]] = alloca [[U:%.*]], align 16412; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) [[A]], ptr noundef nonnull align 16 dereferenceable(20) @H, i64 20, i1 false)413; CHECK-NEXT:    call void @bar_may_capture(ptr nonnull readonly [[A]])414; CHECK-NEXT:    ret void415;416  %A = alloca %U, align 16417  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @H, i64 20, i1 false)418  call void @bar_may_capture(ptr readonly %A)419  ret void420}421 422; Test that we don't elide the memcpy when copying a constant value onto the423; stack and then forwarding it by read-write, nocapture reference, even if it's424; also forwarded by readonly nocapture reference to the same function.425define void @memcpy_to_aliased_nocapture_readonly() {426; CHECK-LABEL: @memcpy_to_aliased_nocapture_readonly(427; CHECK-NEXT:    [[A:%.*]] = alloca [[U:%.*]], align 16428; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) [[A]], ptr noundef nonnull align 16 dereferenceable(20) @H, i64 20, i1 false)429; CHECK-NEXT:    call void @two_params(ptr nonnull readonly captures(none) [[A]], ptr nonnull captures(none) [[A]])430; CHECK-NEXT:    ret void431;432  %A = alloca %U, align 16433  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %A, ptr align 4 @H, i64 20, i1 false)434  call void @two_params(ptr nocapture readonly %A, ptr nocapture %A)435  ret void436}437 438declare void @two_params(ptr nocapture readonly, ptr nocapture)439 440attributes #0 = { null_pointer_is_valid }441