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 @xor = global ptr inttoptr (i64 xor (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X ^ 0 == X
16 %Ty = type { i32, i32 }
17 @B = external global %Ty
20 @cons = weak global i32 0, align 8 ; <ptr> [#uses=1]
22 @gep1 = global <2 x ptr> getelementptr(i8, <2 x ptr> undef, <2 x i64> <i64 1, i64 1>)
23 @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>)
24 @gep3 = global <2 x ptr> getelementptr(i8, <2 x ptr> zeroinitializer, <2 x i64> <i64 0, i64 0>)
25 @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>)
27 @bitcast1 = global <2 x i32> bitcast (<4 x i16> <i16 -1, i16 -1, i16 -1, i16 -1> to <2 x i32>)
28 @bitcast2 = global <4 x i16> bitcast (<2 x i32> <i32 -1, i32 -1> to <4 x i16>)
31 ; Need a function to make update_test_checks.py work.
33 ; CHECK: @A = global i64 0
34 ; CHECK: @add = global ptr @A
35 ; CHECK: @sub = global ptr @A
36 ; CHECK: @mul = global ptr null
37 ; CHECK: @xor = global ptr @A
38 ; CHECK: @B = external global %Ty
39 ; CHECK: @cons = weak global i32 0, align 8
40 ; CHECK: @gep1 = global <2 x ptr> undef
41 ; CHECK: @gep2 = global <2 x ptr> undef
42 ; CHECK: @gep3 = global <2 x ptr> zeroinitializer
43 ; CHECK: @gep4 = global <2 x ptr> zeroinitializer
44 ; CHECK: @bitcast1 = global <2 x i32> splat (i32 -1)
45 ; CHECK: @bitcast2 = global <4 x i16> splat (i16 -1)
47 define void @dummy() {
48 ; CHECK-LABEL: @dummy(
49 ; CHECK-NEXT: ret void