1; RUN: opt -S < %s -gvn | FileCheck %s 2 3declare void @llvm.sideeffect() 4 5; Store-to-load forwarding across a @llvm.sideeffect. 6 7; CHECK-LABEL: s2l 8; CHECK-NOT: load 9define float @s2l(float* %p) { 10 store float 0.0, float* %p 11 call void @llvm.sideeffect() 12 %t = load float, float* %p 13 ret float %t 14} 15 16; Redundant load elimination across a @llvm.sideeffect. 17 18; CHECK-LABEL: rle 19; CHECK: load 20; CHECK-NOT: load 21define float @rle(float* %p) { 22 %r = load float, float* %p 23 call void @llvm.sideeffect() 24 %s = load float, float* %p 25 %t = fadd float %r, %s 26 ret float %t 27} 28 29; LICM across a @llvm.sideeffect. 30 31; CHECK-LABEL: licm 32; CHECK: load 33; CHECK: loop: 34; CHECK-NOT: load 35define float @licm(i64 %n, float* nocapture readonly %p) #0 { 36bb0: 37 br label %loop 38 39loop: 40 %i = phi i64 [ 0, %bb0 ], [ %t5, %loop ] 41 %sum = phi float [ 0.000000e+00, %bb0 ], [ %t4, %loop ] 42 call void @llvm.sideeffect() 43 %t3 = load float, float* %p 44 %t4 = fadd float %sum, %t3 45 %t5 = add i64 %i, 1 46 %t6 = icmp ult i64 %t5, %n 47 br i1 %t6, label %loop, label %bb2 48 49bb2: 50 ret float %t4 51} 52