blob: cf025ec614da517233c62f70f36af104a3f062f2 [file] [log] [blame]
Joey Gouly1d505a32013-01-10 10:31:11 +00001; RUN: opt < %s -S -globalopt -instcombine | FileCheck %s
Chris Lattneref07cc52004-12-12 05:52:12 +00002;; check that global opt turns integers that only hold 0 or 1 into bools.
3
Joey Gouly1d505a32013-01-10 10:31:11 +00004@G = internal addrspace(1) global i32 0
5; CHECK @G.b
6; CHECK addrspace(1)
7; CHECK global i1 0
Chris Lattneref07cc52004-12-12 05:52:12 +00008
Tanya Lattnerec9a35a2008-03-01 09:15:35 +00009define void @set1() {
Joey Gouly1d505a32013-01-10 10:31:11 +000010 store i32 0, i32 addrspace(1)* @G
11; CHECK: store i1 false
12 ret void
Chris Lattneref07cc52004-12-12 05:52:12 +000013}
14
Tanya Lattnerec9a35a2008-03-01 09:15:35 +000015define void @set2() {
Joey Gouly1d505a32013-01-10 10:31:11 +000016 store i32 1, i32 addrspace(1)* @G
17; CHECK: store i1 true
18 ret void
Chris Lattneref07cc52004-12-12 05:52:12 +000019}
Tanya Lattnerec9a35a2008-03-01 09:15:35 +000020
21define i1 @get() {
Joey Gouly1d505a32013-01-10 10:31:11 +000022; CHECK @get
23 %A = load i32 addrspace(1) * @G
24 %C = icmp slt i32 %A, 2
25 ret i1 %C
26; CHECK: ret i1 true
Tanya Lattnerec9a35a2008-03-01 09:15:35 +000027}
28