Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: test/Transforms/NaCl/promote-i1-ops.ll

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/Transforms/NaCl/pnacl-sjlj-eh-bug.ll ('k') | test/Transforms/NaCl/promote-integers.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 ; RUN: opt %s -nacl-promote-i1-ops -S | FileCheck %s
2
3 ; Test that the PromoteI1Ops pass expands out i1 loads/stores and i1
4 ; comparison and arithmetic operations, with the exception of "and",
5 ; "or" and "xor".
6
7
8 ; i1 loads and stores are converted to i8 load and stores with
9 ; explicit casts.
10
11 define i1 @load(i1* %ptr) {
12 %val = load i1* %ptr
13 ret i1 %val
14 }
15 ; CHECK: define i1 @load
16 ; CHECK-NEXT: %ptr.i8ptr = bitcast i1* %ptr to i8*
17 ; CHECK-NEXT: %val.pre_trunc = load i8* %ptr.i8ptr
18 ; CHECK-NEXT: %val = trunc i8 %val.pre_trunc to i1
19
20 define void @store(i1 %val, i1* %ptr) {
21 store i1 %val, i1* %ptr
22 ret void
23 }
24 ; CHECK: define void @store
25 ; CHECK-NEXT: %ptr.i8ptr = bitcast i1* %ptr to i8*
26 ; CHECK-NEXT: %val.expand_i1_val = zext i1 %val to i8
27 ; CHECK-NEXT: store i8 %val.expand_i1_val, i8* %ptr.i8ptr
28
29
30 ; i1 arithmetic and comparisons are converted to their i8 equivalents
31 ; with explicit casts.
32
33 define i1 @add(i1 %x, i1 %y) {
34 %result = add i1 %x, %y
35 ret i1 %result
36 }
37 ; CHECK: define i1 @add
38 ; CHECK-NEXT: %x.expand_i1_val = zext i1 %x to i8
39 ; CHECK-NEXT: %y.expand_i1_val = zext i1 %y to i8
40 ; CHECK-NEXT: %result.pre_trunc = add i8 %x.expand_i1_val, %y.expand_i1_val
41 ; CHECK-NEXT: %result = trunc i8 %result.pre_trunc to i1
42
43 define i1 @compare(i1 %x, i1 %y) {
44 %result = icmp slt i1 %x, %y
45 ret i1 %result
46 }
47 ; CHECK: define i1 @compare
48 ; CHECK-NEXT: %x.expand_i1_val = sext i1 %x to i8
49 ; CHECK-NEXT: %y.expand_i1_val = sext i1 %y to i8
50 ; CHECK-NEXT: %result = icmp slt i8 %x.expand_i1_val, %y.expand_i1_val
51
52
53 ; Non-shift bitwise operations should not be modified.
54 define void @bitwise_ops(i1 %x, i1 %y) {
55 %and = and i1 %x, %y
56 %or = or i1 %x, %y
57 %xor = xor i1 %x, %y
58 ret void
59 }
60 ; CHECK: define void @bitwise_ops
61 ; CHECK-NEXT: %and = and i1 %x, %y
62 ; CHECK-NEXT: %or = or i1 %x, %y
63 ; CHECK-NEXT: %xor = xor i1 %x, %y
64
65
66 define void @unchanged_cases(i32 %x, i32 %y, i32* %ptr) {
67 %add = add i32 %x, %y
68 %cmp = icmp slt i32 %x, %y
69 %val = load i32* %ptr
70 store i32 %x, i32* %ptr
71 ret void
72 }
73 ; CHECK: define void @unchanged_cases
74 ; CHECK-NEXT: %add = add i32 %x, %y
75 ; CHECK-NEXT: %cmp = icmp slt i32 %x, %y
76 ; CHECK-NEXT: %val = load i32* %ptr
77 ; CHECK-NEXT: store i32 %x, i32* %ptr
78
79 define void @i1_switch(i1 %a) {
80 entry:
81 switch i1 %a, label %impossible [
82 i1 true, label %truedest
83 i1 false, label %falsedest
84 ]
85
86 impossible:
87 %phi = phi i32 [ 123, %entry ]
88 unreachable
89
90 truedest:
91 unreachable
92
93 falsedest:
94 unreachable
95 }
96 ; CHECK-LABEL: define void @i1_switch
97 ; CHECK-LABEL: entry:
98 ; CHECK-NEXT: br i1 %a, label %truedest, label %falsedest
99 ; CHECK-LABEL: impossible:
100 ; CHECK-NEXT: unreachable
101 ; CHECK-LABEL: truedest:
102 ; CHECK-NEXT: unreachable
103 ; CHECK-LABEL: falsedest:
104 ; CHECK-NEXT: unreachable
105
106 define void @i1_switch_default_true(i1 %a) {
107 entry:
108 switch i1 %a, label %truedest [
109 i1 false, label %falsedest
110 ]
111
112 truedest:
113 unreachable
114 falsedest:
115 unreachable
116 }
117 ; CHECK-LABEL: define void @i1_switch_default_true(i1 %a)
118 ; CHECK-LABEL: entry:
119 ; CHECK-NEXT: br i1 %a, label %truedest, label %falsedest
120 ; CHECK-LABEL: truedest:
121 ; CHECK-NEXT: unreachable
122 ; CHECK-LABEL: falsedest:
123 ; CHECK-NEXT: unreachable
124
125 define void @i1_switch_default_false(i1 %a) {
126 entry:
127 switch i1 %a, label %falsedest [
128 i1 true, label %truedest
129 ]
130
131 truedest:
132 unreachable
133 falsedest:
134 unreachable
135 }
136 ; CHECK-LABEL: define void @i1_switch_default_false(i1 %a)
137 ; CHECK-LABEL: entry:
138 ; CHECK-NEXT: br i1 %a, label %truedest, label %falsedest
139 ; CHECK-LABEL: truedest:
140 ; CHECK-NEXT: unreachable
141 ; CHECK-LABEL: falsedest:
142 ; CHECK-NEXT: unreachable
143
OLDNEW
« no previous file with comments | « test/Transforms/NaCl/pnacl-sjlj-eh-bug.ll ('k') | test/Transforms/NaCl/promote-integers.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698