• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; This test checks to make sure that constant exprs fold in some simple
2; situations
3
4; RUN: llvm-as < %s | llvm-dis | not grep {(}
5
6@A = global i64 0
7
8global i64* inttoptr (i64 add (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X + 0 == X
9global i64* inttoptr (i64 sub (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X - 0 == X
10global i64* inttoptr (i64 mul (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X * 0 == 0
11global i64* inttoptr (i64 sdiv (i64 ptrtoint (i64* @A to i64), i64 1) to i64*) ; X / 1 == X
12global i64* inttoptr (i64 srem (i64 ptrtoint (i64* @A to i64), i64 1) to i64*) ; X % 1 == 0
13global i64* inttoptr (i64 and (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X & 0 == 0
14global i64* inttoptr (i64 and (i64 ptrtoint (i64* @A to i64), i64 -1) to i64*) ; X & -1 == X
15global i64 or (i64 ptrtoint (i64* @A to i64), i64 -1)  ; X | -1 == -1
16global i64* inttoptr (i64 xor (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X ^ 0 == X
17
18%Ty = type { i32, i32 }
19@B = external global %Ty
20
21global i1 icmp slt (i64* @A, i64* getelementptr (i64* @A, i64 1))        ; true
22global i1 icmp ult (i64* @A, i64* getelementptr (i64* @A, i64 1))        ; true
23global i1 icmp slt (i64* @A, i64* getelementptr (i64* @A, i64 0))        ; false
24global i1 icmp slt (i32* getelementptr (%Ty* @B, i64 0, i32 0),
25                   i32* getelementptr (%Ty* @B, i64 0, i32 1))            ; true
26;global i1 icmp ne (i64* @A, i64* bitcast (%Ty* @B to i64*))                 ; true
27
28; PR2206
29@cons = weak global i32 0, align 8              ; <i32*> [#uses=1]
30global i64 and (i64 ptrtoint (i32* @cons to i64), i64 7)
31
32