summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/add.ll
blob: a8793a78bb08f05454a44f726997ab8e1ae237e9 (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
30
31
32
; This test makes sure that add instructions are properly eliminated.
;
; This also tests that a subtract with a constant is properly converted
; to a add w/negative constant

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

implementation

int "test1"(int %A)
begin
	%B = add int %A, 0
	ret int %B
end

int "test2"(int %A)
begin
	%B = add int %A, 5
	%C = add int %B, -5
	ret int %C
end

int "test3"(int %A)
begin
	%B = add int %A, 5
	%C = sub int %B, 5   ;; This should get converted to an add
	ret int %C
end