2015-02-09 03:38:25 +08:00
|
|
|
; RUN: llc < %s -march=x86 -mattr=+sse2 | FileCheck %s -check-prefix=X32
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-linux -mattr=+sse2 | FileCheck %s -check-prefix=X64
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-win32 -mattr=+sse2 | FileCheck %s -check-prefix=X64
|
2009-09-25 14:49:41 +08:00
|
|
|
|
|
|
|
; Though it is undefined, we want xor undef,undef to produce zero.
|
|
|
|
define <4 x i32> @test1() nounwind {
|
|
|
|
%tmp = xor <4 x i32> undef, undef
|
|
|
|
ret <4 x i32> %tmp
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test1:
|
2011-11-08 03:15:58 +08:00
|
|
|
; X32: xorps %xmm0, %xmm0
|
2009-09-25 14:49:41 +08:00
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Though it is undefined, we want xor undef,undef to produce zero.
|
|
|
|
define i32 @test2() nounwind{
|
|
|
|
%tmp = xor i32 undef, undef
|
|
|
|
ret i32 %tmp
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test2:
|
2009-09-25 14:49:41 +08:00
|
|
|
; X32: xorl %eax, %eax
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test3(i32 %a, i32 %b) nounwind {
|
2008-04-07 05:23:02 +08:00
|
|
|
entry:
|
|
|
|
%tmp1not = xor i32 %b, -2
|
|
|
|
%tmp3 = and i32 %tmp1not, %a
|
|
|
|
%tmp4 = lshr i32 %tmp3, 1
|
|
|
|
ret i32 %tmp4
|
2009-09-25 14:49:41 +08:00
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; X64-LABEL: test3:
|
2011-05-04 09:01:47 +08:00
|
|
|
; X64: notl
|
|
|
|
; X64: andl
|
2012-08-10 08:21:30 +08:00
|
|
|
; X64: shrl
|
2009-09-25 14:49:41 +08:00
|
|
|
; X64: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test3:
|
2009-09-25 14:49:41 +08:00
|
|
|
; X32: movl 8(%esp), %eax
|
|
|
|
; X32: notl %eax
|
|
|
|
; X32: andl 4(%esp), %eax
|
|
|
|
; X32: shrl %eax
|
|
|
|
; X32: ret
|
2008-04-07 05:23:02 +08:00
|
|
|
}
|
|
|
|
|
2009-09-25 14:49:41 +08:00
|
|
|
define i32 @test4(i32 %a, i32 %b) nounwind {
|
2008-04-07 05:23:02 +08:00
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
bb:
|
|
|
|
%b_addr.0 = phi i32 [ %b, %entry ], [ %tmp8, %bb ]
|
|
|
|
%a_addr.0 = phi i32 [ %a, %entry ], [ %tmp3, %bb ]
|
|
|
|
%tmp3 = xor i32 %a_addr.0, %b_addr.0
|
|
|
|
%tmp4not = xor i32 %tmp3, 2147483647
|
|
|
|
%tmp6 = and i32 %tmp4not, %b_addr.0
|
|
|
|
%tmp8 = shl i32 %tmp6, 1
|
|
|
|
%tmp10 = icmp eq i32 %tmp8, 0
|
|
|
|
br i1 %tmp10, label %bb12, label %bb
|
|
|
|
bb12:
|
|
|
|
ret i32 %tmp3
|
2009-09-25 14:49:41 +08:00
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; X64-LABEL: test4:
|
2009-09-27 15:56:52 +08:00
|
|
|
; X64: notl [[REG:%[a-z]+]]
|
|
|
|
; X64: andl {{.*}}[[REG]]
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test4:
|
2009-09-27 15:56:52 +08:00
|
|
|
; X32: notl [[REG:%[a-z]+]]
|
|
|
|
; X32: andl {{.*}}[[REG]]
|
2008-04-07 05:23:02 +08:00
|
|
|
}
|
|
|
|
|
2009-09-25 14:49:41 +08:00
|
|
|
define i16 @test5(i16 %a, i16 %b) nounwind {
|
2008-04-07 05:23:02 +08:00
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
bb:
|
|
|
|
%b_addr.0 = phi i16 [ %b, %entry ], [ %tmp8, %bb ]
|
|
|
|
%a_addr.0 = phi i16 [ %a, %entry ], [ %tmp3, %bb ]
|
|
|
|
%tmp3 = xor i16 %a_addr.0, %b_addr.0
|
|
|
|
%tmp4not = xor i16 %tmp3, 32767
|
|
|
|
%tmp6 = and i16 %tmp4not, %b_addr.0
|
|
|
|
%tmp8 = shl i16 %tmp6, 1
|
|
|
|
%tmp10 = icmp eq i16 %tmp8, 0
|
|
|
|
br i1 %tmp10, label %bb12, label %bb
|
|
|
|
bb12:
|
|
|
|
ret i16 %tmp3
|
2013-07-14 04:38:47 +08:00
|
|
|
; X64-LABEL: test5:
|
2010-04-28 16:30:49 +08:00
|
|
|
; X64: notl [[REG:%[a-z]+]]
|
|
|
|
; X64: andl {{.*}}[[REG]]
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test5:
|
2010-04-28 16:30:49 +08:00
|
|
|
; X32: notl [[REG:%[a-z]+]]
|
|
|
|
; X32: andl {{.*}}[[REG]]
|
2008-04-07 05:23:02 +08:00
|
|
|
}
|
|
|
|
|
2009-09-25 14:49:41 +08:00
|
|
|
define i8 @test6(i8 %a, i8 %b) nounwind {
|
2008-04-07 05:23:02 +08:00
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
bb:
|
|
|
|
%b_addr.0 = phi i8 [ %b, %entry ], [ %tmp8, %bb ]
|
|
|
|
%a_addr.0 = phi i8 [ %a, %entry ], [ %tmp3, %bb ]
|
|
|
|
%tmp3 = xor i8 %a_addr.0, %b_addr.0
|
|
|
|
%tmp4not = xor i8 %tmp3, 127
|
|
|
|
%tmp6 = and i8 %tmp4not, %b_addr.0
|
|
|
|
%tmp8 = shl i8 %tmp6, 1
|
|
|
|
%tmp10 = icmp eq i8 %tmp8, 0
|
|
|
|
br i1 %tmp10, label %bb12, label %bb
|
|
|
|
bb12:
|
|
|
|
ret i8 %tmp3
|
2013-07-14 04:38:47 +08:00
|
|
|
; X64-LABEL: test6:
|
2009-09-27 15:56:52 +08:00
|
|
|
; X64: notb [[REG:%[a-z]+]]
|
|
|
|
; X64: andb {{.*}}[[REG]]
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test6:
|
2009-09-27 15:56:52 +08:00
|
|
|
; X32: notb [[REG:%[a-z]+]]
|
|
|
|
; X32: andb {{.*}}[[REG]]
|
2008-04-07 05:23:02 +08:00
|
|
|
}
|
|
|
|
|
2009-09-25 14:49:41 +08:00
|
|
|
define i32 @test7(i32 %a, i32 %b) nounwind {
|
2008-04-07 05:23:02 +08:00
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
bb:
|
|
|
|
%b_addr.0 = phi i32 [ %b, %entry ], [ %tmp8, %bb ]
|
|
|
|
%a_addr.0 = phi i32 [ %a, %entry ], [ %tmp3, %bb ]
|
|
|
|
%tmp3 = xor i32 %a_addr.0, %b_addr.0
|
|
|
|
%tmp4not = xor i32 %tmp3, 2147483646
|
|
|
|
%tmp6 = and i32 %tmp4not, %b_addr.0
|
|
|
|
%tmp8 = shl i32 %tmp6, 1
|
|
|
|
%tmp10 = icmp eq i32 %tmp8, 0
|
|
|
|
br i1 %tmp10, label %bb12, label %bb
|
|
|
|
bb12:
|
|
|
|
ret i32 %tmp3
|
2013-07-14 04:38:47 +08:00
|
|
|
; X64-LABEL: test7:
|
2009-09-27 15:56:52 +08:00
|
|
|
; X64: xorl $2147483646, [[REG:%[a-z]+]]
|
|
|
|
; X64: andl {{.*}}[[REG]]
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test7:
|
2009-09-27 15:56:52 +08:00
|
|
|
; X32: xorl $2147483646, [[REG:%[a-z]+]]
|
|
|
|
; X32: andl {{.*}}[[REG]]
|
2008-04-07 05:23:02 +08:00
|
|
|
}
|
|
|
|
|
2010-01-19 05:38:44 +08:00
|
|
|
define i32 @test8(i32 %a) nounwind {
|
|
|
|
; rdar://7553032
|
|
|
|
entry:
|
|
|
|
%t1 = sub i32 0, %a
|
|
|
|
%t2 = add i32 %t1, -1
|
|
|
|
ret i32 %t2
|
2013-07-14 04:38:47 +08:00
|
|
|
; X64-LABEL: test8:
|
2011-05-04 09:01:47 +08:00
|
|
|
; X64: notl {{%eax|%edi|%ecx}}
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test8:
|
2010-01-19 05:38:44 +08:00
|
|
|
; X32: notl %eax
|
|
|
|
}
|
2013-05-08 14:44:42 +08:00
|
|
|
|
|
|
|
define i32 @test9(i32 %a) nounwind {
|
|
|
|
%1 = and i32 %a, 4096
|
|
|
|
%2 = xor i32 %1, 4096
|
|
|
|
ret i32 %2
|
2013-07-14 04:38:47 +08:00
|
|
|
; X64-LABEL: test9:
|
2013-05-08 14:44:42 +08:00
|
|
|
; X64: notl [[REG:%[a-z]+]]
|
|
|
|
; X64: andl {{.*}}[[REG:%[a-z]+]]
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test9:
|
2013-05-08 14:44:42 +08:00
|
|
|
; X32: notl [[REG:%[a-z]+]]
|
|
|
|
; X32: andl {{.*}}[[REG:%[a-z]+]]
|
|
|
|
}
|
2013-05-10 22:09:52 +08:00
|
|
|
|
|
|
|
; PR15948
|
|
|
|
define <4 x i32> @test10(<4 x i32> %a) nounwind {
|
|
|
|
%1 = and <4 x i32> %a, <i32 4096, i32 4096, i32 4096, i32 4096>
|
|
|
|
%2 = xor <4 x i32> %1, <i32 4096, i32 4096, i32 4096, i32 4096>
|
|
|
|
ret <4 x i32> %2
|
2013-07-14 04:38:47 +08:00
|
|
|
; X64-LABEL: test10:
|
2013-05-10 22:09:52 +08:00
|
|
|
; X64: andnps
|
2013-07-14 04:38:47 +08:00
|
|
|
; X32-LABEL: test10:
|
2013-05-10 22:09:52 +08:00
|
|
|
; X32: andnps
|
|
|
|
}
|
2013-10-16 22:16:19 +08:00
|
|
|
|
|
|
|
define i32 @PR17487(i1 %tobool) {
|
|
|
|
%tmp = insertelement <2 x i1> undef, i1 %tobool, i32 1
|
|
|
|
%tmp1 = zext <2 x i1> %tmp to <2 x i64>
|
|
|
|
%tmp2 = xor <2 x i64> %tmp1, <i64 1, i64 1>
|
|
|
|
%tmp3 = extractelement <2 x i64> %tmp2, i32 1
|
|
|
|
%add = add nsw i64 0, %tmp3
|
|
|
|
%cmp6 = icmp ne i64 %add, 1
|
|
|
|
%conv7 = zext i1 %cmp6 to i32
|
|
|
|
ret i32 %conv7
|
|
|
|
|
|
|
|
; X64-LABEL: PR17487:
|
|
|
|
; X64: andn
|
2013-11-17 18:40:03 +08:00
|
|
|
; X32-LABEL: PR17487:
|
|
|
|
; X32: andn
|
2013-10-16 22:16:19 +08:00
|
|
|
}
|
2015-03-18 08:03:36 +08:00
|
|
|
|
|
|
|
define i32 @test11(i32 %b) {
|
|
|
|
%shl = shl i32 1, %b
|
|
|
|
%neg = xor i32 %shl, -1
|
|
|
|
ret i32 %neg
|
|
|
|
; X64-LABEL: test11:
|
|
|
|
; X64: movl $-2, %[[REG:.*]]
|
|
|
|
; X64: roll %{{.*}}, %[[REG]]
|
|
|
|
; X32-LABEL: test11:
|
|
|
|
; X32: movl $-2, %[[REG:.*]]
|
|
|
|
; X32: roll %{{.*}}, %[[REG]]
|
|
|
|
}
|