1 ; RUN: opt -codegenprepare -mtriple=arm64_32-apple-ios %s -S -o - | FileCheck %s
3 define void @test_simple_sink(ptr %base, i64 %offset) {
4 ; CHECK-LABEL: @test_simple_sink
6 ; CHECK: [[ADDR8:%.*]] = getelementptr i8, ptr %base, i64 %offset
7 ; CHECK: load volatile i1, ptr [[ADDR8]]
8 %addr = getelementptr i1, ptr %base, i64 %offset
9 %tst = load i1, ptr %addr
10 br i1 %tst, label %next, label %end
13 load volatile i1, ptr %addr
20 define void @test_inbounds_sink(ptr %base, i64 %offset) {
21 ; CHECK-LABEL: @test_inbounds_sink
23 ; CHECK: [[ADDR8:%.*]] = getelementptr inbounds i8, ptr %base, i64 %offset
24 ; CHECK: load volatile i1, ptr [[ADDR8]]
25 %addr = getelementptr inbounds i1, ptr %base, i64 %offset
26 %tst = load i1, ptr %addr
27 br i1 %tst, label %next, label %end
30 load volatile i1, ptr %addr
37 ; No address derived via an add can be guaranteed inbounds
38 define void @test_add_sink(ptr %base, i64 %offset) {
39 ; CHECK-LABEL: @test_add_sink
41 ; CHECK: [[ADDR8:%.*]] = getelementptr i8, ptr %base, i64 %offset
42 ; CHECK: load volatile i1, ptr [[ADDR8]]
43 %base64 = ptrtoint ptr %base to i64
44 %addr64 = add nsw nuw i64 %base64, %offset
45 %addr = inttoptr i64 %addr64 to ptr
46 %tst = load i1, ptr %addr
47 br i1 %tst, label %next, label %end
50 load volatile i1, ptr %addr