File: ConstantExprFold.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (52 lines) | stat: -rw-r--r-- 2,084 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; This test checks to make sure that constant exprs fold in some simple
; situations

; RUN: opt -S < %s | FileCheck %s
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
; RUN: verify-uselistorder %s

@A = global i64 0

@add = global ptr inttoptr (i64 add (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X + 0 == X
@sub = global ptr inttoptr (i64 sub (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X - 0 == X
@mul = global ptr inttoptr (i64 mul (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X * 0 == 0
@xor = global ptr inttoptr (i64 xor (i64 ptrtoint (ptr @A to i64), i64 0) to ptr) ; X ^ 0 == X

%Ty = type { i32, i32 }
@B = external global %Ty

; PR2206
@cons = weak global i32 0, align 8              ; <ptr> [#uses=1]

@gep1 = global <2 x ptr> getelementptr(i8, <2 x ptr> undef, <2 x i64> <i64 1, i64 1>)
@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>)
@gep3 = global <2 x ptr> getelementptr(i8, <2 x ptr> zeroinitializer, <2 x i64> <i64 0, i64 0>)
@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>)

@bitcast1 = global <2 x i32> bitcast (<4 x i16> <i16 -1, i16 -1, i16 -1, i16 -1> to <2 x i32>)
@bitcast2 = global <4 x i16> bitcast (<2 x i32> <i32 -1, i32 -1> to <4 x i16>)


; Need a function to make update_test_checks.py work.
;.
; CHECK: @A = global i64 0
; CHECK: @add = global ptr @A
; CHECK: @sub = global ptr @A
; CHECK: @mul = global ptr null
; CHECK: @xor = global ptr @A
; CHECK: @B = external global %Ty
; CHECK: @cons = weak global i32 0, align 8
; CHECK: @gep1 = global <2 x ptr> undef
; CHECK: @gep2 = global <2 x ptr> undef
; CHECK: @gep3 = global <2 x ptr> zeroinitializer
; CHECK: @gep4 = global <2 x ptr> zeroinitializer
; CHECK: @bitcast1 = global <2 x i32> splat (i32 -1)
; CHECK: @bitcast2 = global <4 x i16> splat (i16 -1)
;.
define void @dummy() {
; CHECK-LABEL: @dummy(
; CHECK-NEXT:    ret void
;
  ret void
}