• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -basic-aa -sink -S | FileCheck %s
2declare void @foo(i64 *)
3declare i8* @llvm.load.relative.i32(i8* %ptr, i32 %offset) argmemonly nounwind readonly
4define i64 @sinkload(i1 %cmp, i8* %ptr, i32 %off) {
5; CHECK-LABEL: @sinkload
6top:
7    %a = alloca i64
8; CHECK: call void @foo(i64* %a)
9; CHECK-NEXT: %x = load i64, i64* %a
10; CHECK-NEXT: %y = call i8* @llvm.load.relative.i32(i8* %ptr, i32 %off)
11    call void @foo(i64* %a)
12    %x = load i64, i64* %a
13    %y = call i8* @llvm.load.relative.i32(i8* %ptr, i32 %off)
14    br i1 %cmp, label %A, label %B
15A:
16    store i64 0, i64 *%a
17    store i8 0, i8 *%ptr
18    br label %B
19B:
20; CHECK-NOT: load i64, i64 *%a
21; CHECK-NOT: call i8* @llvm.load.relative(i8* %ptr, i32 off)
22    %y2 = ptrtoint i8* %y to i64
23    %retval = add i64 %y2, %x
24    ret i64 %retval
25}
26
27