File: fast-isel-no-offset.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (106 lines) | stat: -rw-r--r-- 3,171 bytes parent folder | download | duplicates (6)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
; RUN: llc < %s -asm-verbose=false -fast-isel -fast-isel-abort=1 -verify-machineinstrs | FileCheck %s

target triple = "wasm32-unknown-unknown"

; FastISel should not fold one of the add/sub operands into a load/store's
; offset when 'nuw' (no unsigned wrap) is not present, because the address
; calculation does not wrap. When there is an add/sub and nuw is not present, we
; bail out of FastISel.

@mylabel = external global ptr

; CHECK-LABEL: dont_fold_non_nuw_add_load:
; CHECK:       local.get  0
; CHECK-NEXT:  i32.const  2147483644
; CHECK-NEXT:  i32.add
; CHECK-NEXT:  i32.load  0
define i32 @dont_fold_non_nuw_add_load(ptr %p) {
  %q = ptrtoint ptr %p to i32
  %r = add i32 %q, 2147483644
  %s = inttoptr i32 %r to ptr
  %t = load i32, ptr %s
  ret i32 %t
}

; CHECK-LABEL: dont_fold_non_nuw_add_store:
; CHECK:       local.get  0
; CHECK-NEXT:  i32.const  2147483644
; CHECK-NEXT:  i32.add
; CHECK-NEXT:  i32.const  5
; CHECK-NEXT:  i32.store  0
define void @dont_fold_non_nuw_add_store(ptr %p) {
  %q = ptrtoint ptr %p to i32
  %r = add i32 %q, 2147483644
  %s = inttoptr i32 %r to ptr
  store i32 5, ptr %s
  ret void
}

; CHECK-LABEL: dont_fold_non_nuw_add_load_2:
; CHECK:       i32.const  mylabel
; CHECK-NEXT:  i32.const  -4
; CHECK-NEXT:  i32.add
; CHECK-NEXT:  i32.load  0
define i32 @dont_fold_non_nuw_add_load_2() {
  %t = load i32, ptr inttoptr (i32 add (i32 ptrtoint (ptr @mylabel to i32), i32 -4) to ptr), align 4
  ret i32 %t
}

; CHECK-LABEL: dont_fold_non_nuw_add_store_2:
; CHECK:       i32.const  mylabel
; CHECK-NEXT:  i32.const  -4
; CHECK-NEXT:  i32.add
; CHECK-NEXT:  i32.const  5
; CHECK-NEXT:  i32.store  0
define void @dont_fold_non_nuw_add_store_2() {
  store i32 5, ptr inttoptr (i32 add (i32 ptrtoint (ptr @mylabel to i32), i32 -4) to ptr), align 4
  ret void
}

; CHECK-LABEL: dont_fold_non_nuw_sub_load:
; CHECK:       local.get  0
; CHECK-NEXT:  i32.const  -2147483644
; CHECK-NEXT:  i32.sub
; CHECK-NEXT:  i32.load  0
define i32 @dont_fold_non_nuw_sub_load(ptr %p) {
  %q = ptrtoint ptr %p to i32
  %r = sub i32 %q, -2147483644
  %s = inttoptr i32 %r to ptr
  %t = load i32, ptr %s
  ret i32 %t
}

; CHECK-LABEL: dont_fold_non_nuw_sub_store:
; CHECK:       local.get  0
; CHECK-NEXT:  i32.const  -2147483644
; CHECK-NEXT:  i32.sub
; CHECK-NEXT:  i32.const  5
; CHECK-NEXT:  i32.store  0
define void @dont_fold_non_nuw_sub_store(ptr %p) {
  %q = ptrtoint ptr %p to i32
  %r = sub i32 %q, -2147483644
  %s = inttoptr i32 %r to ptr
  store i32 5, ptr %s
  ret void
}

; CHECK-LABEL: dont_fold_non_nuw_sub_load_2:
; CHECK:       i32.const  mylabel
; CHECK-NEXT:  i32.const  4
; CHECK-NEXT:  i32.sub
; CHECK-NEXT:  i32.load  0
define i32 @dont_fold_non_nuw_sub_load_2() {
  %t = load i32, ptr inttoptr (i32 sub (i32 ptrtoint (ptr @mylabel to i32), i32 4) to ptr), align 4
 ret i32 %t
}

; CHECK-LABEL: dont_fold_non_nuw_sub_store_2:
; CHECK:       i32.const  mylabel
; CHECK-NEXT:  i32.const  4
; CHECK-NEXT:  i32.sub
; CHECK-NEXT:  i32.const  5
; CHECK-NEXT:  i32.store  0
define void @dont_fold_non_nuw_sub_store_2() {
  store i32 5, ptr inttoptr (i32 sub (i32 ptrtoint (ptr @mylabel to i32), i32 4) to ptr), align 4
  ret void
}