1 ; RUN: opt -codegenprepare -mtriple=arm64_32-apple-ios %s -S -o - | FileCheck %s
3 define void @test_simple_sink(i1* %base, i64 %offset) {
4 ; CHECK-LABEL: @test_simple_sink
6 ; CHECK: [[BASE8:%.*]] = bitcast i1* %base to i8*
7 ; CHECK: [[ADDR8:%.*]] = getelementptr i8, i8* [[BASE8]], i64 %offset
8 ; CHECK: [[ADDR:%.*]] = bitcast i8* [[ADDR8]] to i1*
9 ; CHECK: load volatile i1, i1* [[ADDR]]
10 %addr = getelementptr i1, i1* %base, i64 %offset
11 %tst = load i1, i1* %addr
12 br i1 %tst, label %next, label %end
15 load volatile i1, i1* %addr
22 define void @test_inbounds_sink(i1* %base, i64 %offset) {
23 ; CHECK-LABEL: @test_inbounds_sink
25 ; CHECK: [[BASE8:%.*]] = bitcast i1* %base to i8*
26 ; CHECK: [[ADDR8:%.*]] = getelementptr inbounds i8, i8* [[BASE8]], i64 %offset
27 ; CHECK: [[ADDR:%.*]] = bitcast i8* [[ADDR8]] to i1*
28 ; CHECK: load volatile i1, i1* [[ADDR]]
29 %addr = getelementptr inbounds i1, i1* %base, i64 %offset
30 %tst = load i1, i1* %addr
31 br i1 %tst, label %next, label %end
34 load volatile i1, i1* %addr
41 ; No address derived via an add can be guaranteed inbounds
42 define void @test_add_sink(i1* %base, i64 %offset) {
43 ; CHECK-LABEL: @test_add_sink
45 ; CHECK: [[BASE8:%.*]] = bitcast i1* %base to i8*
46 ; CHECK: [[ADDR8:%.*]] = getelementptr i8, i8* [[BASE8]], i64 %offset
47 ; CHECK: [[ADDR:%.*]] = bitcast i8* [[ADDR8]] to i1*
48 ; CHECK: load volatile i1, i1* [[ADDR]]
49 %base64 = ptrtoint i1* %base to i64
50 %addr64 = add nsw nuw i64 %base64, %offset
51 %addr = inttoptr i64 %addr64 to i1*
52 %tst = load i1, i1* %addr
53 br i1 %tst, label %next, label %end
56 load volatile i1, i1* %addr