File: infer-addrspacecast.ll

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,388 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (56 lines) | stat: -rw-r--r-- 2,488 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -infer-address-spaces %s | FileCheck %s

; Test that pure addrspacecast instructions not directly connected to
; a memory operation are inferred.

; CHECK-LABEL: @addrspacecast_gep_addrspacecast(
; CHECK: %gep0 = getelementptr i32, i32 addrspace(3)* %ptr, i64 9
; CHECK-NEXT: store i32 8, i32 addrspace(3)* %gep0, align 8
; CHECK-NEXT: ret void
define void @addrspacecast_gep_addrspacecast(i32 addrspace(3)* %ptr) {
  %asc0 = addrspacecast i32 addrspace(3)* %ptr to i32*
  %gep0 = getelementptr i32, i32* %asc0, i64 9
  %asc1 = addrspacecast i32* %gep0 to i32 addrspace(3)*
  store i32 8, i32 addrspace(3)* %asc1, align 8
  ret void
}

; CHECK-LABEL: @addrspacecast_different_pointee_type(
; CHECK: [[GEP:%.*]] = getelementptr i32, i32 addrspace(3)* %ptr, i64 9
; CHECK: [[CAST:%.*]] = bitcast i32 addrspace(3)* [[GEP]] to i8 addrspace(3)*
; CHECK-NEXT: store i8 8, i8 addrspace(3)* [[CAST]], align 8
; CHECK-NEXT: ret void
define void @addrspacecast_different_pointee_type(i32 addrspace(3)* %ptr) {
  %asc0 = addrspacecast i32 addrspace(3)* %ptr to i32*
  %gep0 = getelementptr i32, i32* %asc0, i64 9
  %asc1 = addrspacecast i32* %gep0 to i8 addrspace(3)*
  store i8 8, i8 addrspace(3)* %asc1, align 8
  ret void
}

; CHECK-LABEL: @addrspacecast_to_memory(
; CHECK: %gep0 = getelementptr i32, i32 addrspace(3)* %ptr, i64 9
; CHECK-NEXT: store volatile i32 addrspace(3)* %gep0, i32 addrspace(3)* addrspace(1)* undef
; CHECK-NEXT: ret void
define void @addrspacecast_to_memory(i32 addrspace(3)* %ptr) {
  %asc0 = addrspacecast i32 addrspace(3)* %ptr to i32*
  %gep0 = getelementptr i32, i32* %asc0, i64 9
  %asc1 = addrspacecast i32* %gep0 to i32 addrspace(3)*
  store volatile i32 addrspace(3)* %asc1, i32 addrspace(3)* addrspace(1)* undef
  ret void
}

; CHECK-LABEL: @multiuse_addrspacecast_gep_addrspacecast(
; CHECK: %asc0 = addrspacecast i32 addrspace(3)* %ptr to i32*
; CHECK-NEXT: store volatile i32* %asc0, i32* addrspace(1)* undef
; CHECK-NEXT: %gep0 = getelementptr i32, i32 addrspace(3)* %ptr, i64 9
; CHECK-NEXT: store i32 8, i32 addrspace(3)* %gep0, align 8
; CHECK-NEXT: ret void
define void @multiuse_addrspacecast_gep_addrspacecast(i32 addrspace(3)* %ptr) {
  %asc0 = addrspacecast i32 addrspace(3)* %ptr to i32*
  store volatile i32* %asc0, i32* addrspace(1)* undef
  %gep0 = getelementptr i32, i32* %asc0, i64 9
  %asc1 = addrspacecast i32* %gep0 to i32 addrspace(3)*
  store i32 8, i32 addrspace(3)* %asc1, align 8
  ret void
}