2002-05-07 01:00:47 +08:00
|
|
|
; This test makes sure that these instructions are properly eliminated.
|
|
|
|
;
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep xor
|
2002-05-07 01:00:47 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test1(i32 %A) {
|
|
|
|
%B = xor i32 %A, -1 ; <i32> [#uses=1]
|
|
|
|
%C = xor i32 %B, -1 ; <i32> [#uses=1]
|
|
|
|
ret i32 %C
|
2002-05-07 01:00:47 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i1 @test2(i32 %A, i32 %B) {
|
|
|
|
; Can change into setge
|
|
|
|
%cond = icmp sle i32 %A, %B ; <i1> [#uses=1]
|
|
|
|
%Ret = xor i1 %cond, true ; <i1> [#uses=1]
|
|
|
|
ret i1 %Ret
|
2002-08-22 01:11:18 +08:00
|
|
|
}
|
2002-08-24 02:31:18 +08:00
|
|
|
|
|
|
|
; Test that demorgans law can be instcombined
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test3(i32 %A, i32 %B) {
|
|
|
|
%a = xor i32 %A, -1 ; <i32> [#uses=1]
|
|
|
|
%b = xor i32 %B, -1 ; <i32> [#uses=1]
|
|
|
|
%c = and i32 %a, %b ; <i32> [#uses=1]
|
|
|
|
%d = xor i32 %c, -1 ; <i32> [#uses=1]
|
|
|
|
ret i32 %d
|
2002-08-24 02:31:18 +08:00
|
|
|
}
|
2003-03-11 07:13:32 +08:00
|
|
|
|
|
|
|
; Test that demorgens law can work with constants
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test4(i32 %A, i32 %B) {
|
|
|
|
%a = xor i32 %A, -1 ; <i32> [#uses=1]
|
|
|
|
%c = and i32 %a, 5 ; <i32> [#uses=1]
|
|
|
|
%d = xor i32 %c, -1 ; <i32> [#uses=1]
|
|
|
|
ret i32 %d
|
2003-03-11 07:13:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; test the mirror of demorgans law...
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test5(i32 %A, i32 %B) {
|
|
|
|
%a = xor i32 %A, -1 ; <i32> [#uses=1]
|
|
|
|
%b = xor i32 %B, -1 ; <i32> [#uses=1]
|
|
|
|
%c = or i32 %a, %b ; <i32> [#uses=1]
|
|
|
|
%d = xor i32 %c, -1 ; <i32> [#uses=1]
|
|
|
|
ret i32 %d
|
2003-03-11 07:13:32 +08:00
|
|
|
}
|
2008-03-01 17:15:35 +08:00
|
|
|
|
2008-05-09 13:19:28 +08:00
|
|
|
; PR2298
|
|
|
|
define i8 @test6(i32 %a, i32 %b) zeroext nounwind {
|
|
|
|
entry:
|
|
|
|
%tmp1not = xor i32 %a, -1 ; <i32> [#uses=1]
|
|
|
|
%tmp2not = xor i32 %b, -1 ; <i32> [#uses=1]
|
|
|
|
%tmp3 = icmp slt i32 %tmp1not, %tmp2not ; <i1> [#uses=1]
|
|
|
|
%retval67 = zext i1 %tmp3 to i8 ; <i8> [#uses=1]
|
|
|
|
ret i8 %retval67
|
|
|
|
}
|
|
|
|
|