1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -passes=bpf-aspace-simplify -mtriple=bpf-pc-linux -S < %s | FileCheck %s
4 ; Check that bpf-aspace-simplify pass removes unnecessary (for BPF)
5 ; address space casts for cast M->N -> GEP -> cast N->M chain,
6 ; where chain is split between several BBs.
8 define dso_local ptr addrspace(1) @test (ptr addrspace(1) %p) {
9 ; CHECK-LABEL: define dso_local ptr addrspace(1) @test(
10 ; CHECK-SAME: ptr addrspace(1) [[P:%.*]]) {
12 ; CHECK-NEXT: br label [[EXIT:%.*]]
14 ; CHECK-NEXT: [[B1:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[P]], i64 8
15 ; CHECK-NEXT: ret ptr addrspace(1) [[B1]]
18 %a = addrspacecast ptr addrspace(1) %p to ptr
19 %b = getelementptr inbounds i8, ptr %a, i64 8
23 %c = addrspacecast ptr %b to ptr addrspace(1)
24 ret ptr addrspace(1) %c