1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
2 ; This test checks to make sure that constant exprs fold in some simple
5 ; RUN: opt -S < %s | FileCheck %s
6 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
7 ; RUN: verify-uselistorder %s
11 @add = global ptr inttoptr (i64 add (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X + 0 == X
12 @sub = global ptr inttoptr (i64 sub (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X - 0 == X
13 @mul = global ptr inttoptr (i64 mul (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X * 0 == 0
14 @and1 = global ptr inttoptr (i64 and (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X & 0 == 0
15 @and2 = global ptr inttoptr (i64 and (i64 ptrtoint (ptr @A to i64), i64 -1) to ptr) ; X & -1 == X
16 @or = global i64 or (i64 ptrtoint (ptr @A to i64), i64 -1) ; X | -1 == -1
17 @xor = global ptr inttoptr (i64 xor (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X ^ 0 == X
19 %Ty = type { i32, i32 }
20 @B = external global %Ty
22 ; @icmp_ult1 and @icmp_ult2 will be folded by the target-dependent constant folder instead.
23 @icmp_ult1 = global i1 icmp ult (ptr @A, ptr getelementptr (i64, ptr @A, i64 1)) ; true
24 @icmp_slt = global i1 icmp slt (ptr @A, ptr @A) ; false
25 @icmp_ult2 = global i1 icmp ult (ptr @B,
26 ptr getelementptr (%Ty, ptr @B, i64 0, i32 1)) ; true
27 ;global i1 icmp ne (ptr @A, ptr @B) ; true
30 @cons = weak global i32 0, align 8 ; <ptr> [#uses=1]
31 @and3 = global i64 and (i64 ptrtoint (ptr @cons to i64), i64 7)
33 @gep1 = global <2 x ptr> getelementptr(i8, <2 x ptr> undef, <2 x i64> <i64 1, i64 1>)
34 @gep2 = global <2 x ptr> getelementptr({ i8 }, <2 x ptr> undef, <2 x i64> <i64 1, i64 1>, <2 x i32> <i32 0, i32 0>)
35 @gep3 = global <2 x ptr> getelementptr(i8, <2 x ptr> zeroinitializer, <2 x i64> <i64 0, i64 0>)
36 @gep4 = global <2 x ptr> getelementptr({ i8 }, <2 x ptr> zeroinitializer, <2 x i64> <i64 0, i64 0>, <2 x i32> <i32 0, i32 0>)
39 ; Need a function to make update_test_checks.py work.
41 ; CHECK: @[[A:[a-zA-Z0-9_$"\\.-]+]] = global i64 0
42 ; CHECK: @[[ADD:[a-zA-Z0-9_$"\\.-]+]] = global ptr @A
43 ; CHECK: @[[SUB:[a-zA-Z0-9_$"\\.-]+]] = global ptr @A
44 ; CHECK: @[[MUL:[a-zA-Z0-9_$"\\.-]+]] = global ptr null
45 ; CHECK: @[[AND1:[a-zA-Z0-9_$"\\.-]+]] = global ptr null
46 ; CHECK: @[[AND2:[a-zA-Z0-9_$"\\.-]+]] = global ptr @A
47 ; CHECK: @[[OR:[a-zA-Z0-9_$"\\.-]+]] = global i64 -1
48 ; CHECK: @[[XOR:[a-zA-Z0-9_$"\\.-]+]] = global ptr @A
49 ; CHECK: @[[B:[a-zA-Z0-9_$"\\.-]+]] = external global [[TY:%.*]]
50 ; CHECK: @[[ICMP_ULT1:[a-zA-Z0-9_$"\\.-]+]] = global i1 icmp ugt (ptr getelementptr inbounds (i64, ptr @A, i64 1), ptr @A)
51 ; CHECK: @[[ICMP_SLT:[a-zA-Z0-9_$"\\.-]+]] = global i1 false
52 ; CHECK: @[[ICMP_ULT2:[a-zA-Z0-9_$"\\.-]+]] = global i1 icmp ugt (ptr getelementptr inbounds ([[TY:%.*]], ptr @B, i64 0, i32 1), ptr @B)
53 ; CHECK: @[[CONS:[a-zA-Z0-9_$"\\.-]+]] = weak global i32 0, align 8
54 ; CHECK: @[[AND3:[a-zA-Z0-9_$"\\.-]+]] = global i64 0
55 ; CHECK: @[[GEP1:[a-zA-Z0-9_$"\\.-]+]] = global <2 x ptr> undef
56 ; CHECK: @[[GEP2:[a-zA-Z0-9_$"\\.-]+]] = global <2 x ptr> undef
57 ; CHECK: @[[GEP3:[a-zA-Z0-9_$"\\.-]+]] = global <2 x ptr> zeroinitializer
58 ; CHECK: @[[GEP4:[a-zA-Z0-9_$"\\.-]+]] = global <2 x ptr> zeroinitializer
60 define void @dummy() {
61 ; CHECK-LABEL: @dummy(
62 ; CHECK-NEXT: ret void