xref: /aosp_15_r20/external/llvm/test/Transforms/GlobalOpt/integer-bool.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -S -globalopt -instcombine | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker;; check that global opt turns integers that only hold 0 or 1 into bools.
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker@G = internal addrspace(1) global i32 0
5*9880d681SAndroid Build Coastguard Worker; CHECK: @G
6*9880d681SAndroid Build Coastguard Worker; CHECK: addrspace(1)
7*9880d681SAndroid Build Coastguard Worker; CHECK: global i1 false
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine void @set1() {
10*9880d681SAndroid Build Coastguard Worker  store i32 0, i32 addrspace(1)* @G
11*9880d681SAndroid Build Coastguard Worker; CHECK: store i1 false
12*9880d681SAndroid Build Coastguard Worker  ret void
13*9880d681SAndroid Build Coastguard Worker}
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Workerdefine void @set2() {
16*9880d681SAndroid Build Coastguard Worker  store i32 1, i32 addrspace(1)* @G
17*9880d681SAndroid Build Coastguard Worker; CHECK: store i1 true
18*9880d681SAndroid Build Coastguard Worker  ret void
19*9880d681SAndroid Build Coastguard Worker}
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workerdefine i1 @get() {
22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @get(
23*9880d681SAndroid Build Coastguard Worker  %A = load i32, i32 addrspace(1) * @G
24*9880d681SAndroid Build Coastguard Worker  %C = icmp slt i32 %A, 2
25*9880d681SAndroid Build Coastguard Worker  ret i1 %C
26*9880d681SAndroid Build Coastguard Worker; CHECK: ret i1 true
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29