2002-05-07 01:00:47 +08:00
|
|
|
; This test makes sure that these instructions are properly eliminated.
|
|
|
|
;
|
|
|
|
|
2014-11-27 18:57:24 +08:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
; CHECK-NOT: xor
|
2002-05-07 01:00:47 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test1(i32 %A) {
|
2015-09-09 01:58:22 +08:00
|
|
|
%B = xor i32 %A, -1
|
|
|
|
%C = xor i32 %B, -1
|
2008-03-01 17:15:35 +08:00
|
|
|
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
|
2015-09-09 01:58:22 +08:00
|
|
|
%cond = icmp sle i32 %A, %B
|
|
|
|
%Ret = xor i1 %cond, true
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i1 %Ret
|
2002-08-22 01:11:18 +08:00
|
|
|
}
|
2002-08-24 02:31:18 +08:00
|
|
|
|
2015-09-09 01:58:22 +08:00
|
|
|
; Test that De Morgan's law can be instcombined.
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test3(i32 %A, i32 %B) {
|
2015-09-09 01:58:22 +08:00
|
|
|
%a = xor i32 %A, -1
|
|
|
|
%b = xor i32 %B, -1
|
|
|
|
%c = and i32 %a, %b
|
|
|
|
%d = xor i32 %c, -1
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %d
|
2002-08-24 02:31:18 +08:00
|
|
|
}
|
2003-03-11 07:13:32 +08:00
|
|
|
|
2015-09-09 01:58:22 +08:00
|
|
|
; Test that De Morgan's law can work with constants.
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test4(i32 %A, i32 %B) {
|
2015-09-09 01:58:22 +08:00
|
|
|
%a = xor i32 %A, -1
|
|
|
|
%c = and i32 %a, 5
|
|
|
|
%d = xor i32 %c, -1
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %d
|
2003-03-11 07:13:32 +08:00
|
|
|
}
|
|
|
|
|
2015-09-09 01:58:22 +08:00
|
|
|
; Test the mirror of De Morgan's law.
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test5(i32 %A, i32 %B) {
|
2015-09-09 01:58:22 +08:00
|
|
|
%a = xor i32 %A, -1
|
|
|
|
%b = xor i32 %B, -1
|
|
|
|
%c = or i32 %a, %b
|
|
|
|
%d = xor i32 %c, -1
|
2008-03-01 17:15:35 +08:00
|
|
|
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
|
2015-09-09 01:58:22 +08:00
|
|
|
define zeroext i8 @test6(i32 %a, i32 %b) {
|
2008-05-09 13:19:28 +08:00
|
|
|
entry:
|
2015-09-09 01:58:22 +08:00
|
|
|
%tmp1not = xor i32 %a, -1
|
|
|
|
%tmp2not = xor i32 %b, -1
|
|
|
|
%tmp3 = icmp slt i32 %tmp1not, %tmp2not
|
|
|
|
%retval67 = zext i1 %tmp3 to i8
|
2008-05-09 13:19:28 +08:00
|
|
|
ret i8 %retval67
|
|
|
|
}
|
2015-02-13 04:26:46 +08:00
|
|
|
|
|
|
|
define <2 x i1> @test7(<2 x i32> %A, <2 x i32> %B) {
|
|
|
|
%cond = icmp sle <2 x i32> %A, %B
|
|
|
|
%Ret = xor <2 x i1> %cond, <i1 true, i1 true>
|
|
|
|
ret <2 x i1> %Ret
|
|
|
|
}
|
2015-09-09 01:58:22 +08:00
|
|
|
|