2002-04-18 17:35:39 +00:00
|
|
|
; 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
|
|
|
|
|
2002-08-02 19:27:58 +00:00
|
|
|
; RUN: if as < %s | opt -instcombine -die | dis | grep add
|
2002-04-18 17:35:39 +00:00
|
|
|
; 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
|
|
|
|
|
2002-05-06 16:44:53 +00:00
|
|
|
int "test4"(int %A, int %B) {
|
|
|
|
%C = sub int 0, %A
|
|
|
|
%D = add int %B, %C ; D = B + -A = B - A
|
|
|
|
ret int %D
|
|
|
|
}
|
|
|
|
|
|
|
|
int "test5"(int %A, int %B) {
|
|
|
|
%C = sub int 0, %A
|
|
|
|
%D = add int %C, %B ; D = -A + B = B - A
|
|
|
|
ret int %D
|
|
|
|
}
|
|
|
|
|