summaryrefslogtreecommitdiffstats
path: root/test/Transforms/InstCombine/getelementptr.ll
blob: 16b947b382b383f8ec8583c3b00e0e3965f14d89 (plain)
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
; The %A getelementptr instruction should be eliminated here

; RUN: if as < %s | opt -instcombine -dce | dis | grep getelementptr | grep '%A'
; RUN: then exit 1
; RUN: else exit 0
; RUN: fi

implementation

int *"foo1"(int * %I) { ; Test noop elimination
	%A = getelementptr int* %I, uint 0
	ret int * %A
}

int* %foo2(int* %I) {  ; Test noop elimination
	%A = getelementptr int* %I
	ret int* %A
}
int* %foo3(int * %I) { ; Test that two array indexing geps fold
	%A = getelementptr int* %I, uint 17
	%B = getelementptr int* %A, uint 4
	ret int* %B
}

int* %foo4({int} *%I) { ; Test that two getelementptr insts fold
	%A = getelementptr {int}* %I, uint 1
	%B = getelementptr {int}* %A, uint 0, ubyte 0
	ret int* %B
}