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 simplifies chain
5 ; 'cast K->M -> cast M->N -> GEP -> cast N->M -> cast M->K'.
7 define dso_local ptr addrspace(2) @test (ptr addrspace(2) %p) {
8 ; CHECK-LABEL: define dso_local ptr addrspace(2) @test(
9 ; CHECK-SAME: ptr addrspace(2) [[P:%.*]]) {
11 ; CHECK-NEXT: [[C12:%.*]] = getelementptr inbounds i8, ptr addrspace(2) [[P]], i64 8
12 ; CHECK-NEXT: ret ptr addrspace(2) [[C12]]
15 %a = addrspacecast ptr addrspace(2) %p to ptr addrspace(1)
16 %b = addrspacecast ptr addrspace(1) %a to ptr
17 %c = getelementptr inbounds i8, ptr %b, i64 8
18 %d = addrspacecast ptr %c to ptr addrspace(1)
19 %e = addrspacecast ptr addrspace (1) %d to ptr addrspace(2)
20 ret ptr addrspace(2) %e