File: load.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (62 lines) | stat: -rw-r--r-- 1,900 bytes parent folder | download | duplicates (10)
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
57
58
59
60
61
62
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s

@zeroinit = constant {} zeroinitializer
@poison = constant {} poison
@constzeroarray = internal constant [4 x i32] zeroinitializer

define i32 @crash_on_zeroinit() {
; CHECK-LABEL: @crash_on_zeroinit(
; CHECK-NEXT:    ret i32 poison
;
  %load = load i32, ptr @zeroinit
  ret i32 %load
}

define i32 @crash_on_poison() {
; CHECK-LABEL: @crash_on_poison(
; CHECK-NEXT:    ret i32 poison
;
  %load = load i32, ptr @poison
  ret i32 %load
}

@GV = private constant [8 x i32] [i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49]

define <8 x i32> @partial_load() {
; CHECK-LABEL: @partial_load(
; CHECK-NEXT:    ret <8 x i32> <i32 0, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48>
;
  %load = load <8 x i32>, ptr getelementptr ([8 x i32], ptr @GV, i64 0, i64 -1)
  ret <8 x i32> %load
}

@constvec = internal constant <3 x float> <float 0xBFDA20BC40000000, float 0xBFE6A09EE0000000, float 0x3FE279A760000000>

; This does an out of bounds load from the global constant
define <3 x float> @load_vec3() {
; CHECK-LABEL: @load_vec3(
; CHECK-NEXT:    ret <3 x float> poison
;
  %1 = load <3 x float>, ptr getelementptr inbounds (<3 x float>, ptr @constvec, i64 1)
  ret <3 x float> %1
}

define i32 @load_gep_const_zero_array(i64 %idx) {
; CHECK-LABEL: @load_gep_const_zero_array(
; CHECK-NEXT:    ret i32 0
;
  %gep = getelementptr inbounds [4 x i32], ptr @constzeroarray, i64 0, i64 %idx
  %load = load i32, ptr %gep
  ret i32 %load
}

define i8 @load_i8_multi_gep_const_zero_array(i64 %idx1, i64 %idx2) {
; CHECK-LABEL: @load_i8_multi_gep_const_zero_array(
; CHECK-NEXT:    ret i8 0
;
  %gep1 = getelementptr inbounds i8, ptr @constzeroarray, i64 %idx1
  %gep = getelementptr inbounds i8, ptr %gep1, i64 %idx2
  %load = load i8, ptr %gep
  ret i8 %load
}