1 ; This test makes sure that these instructions are properly eliminated.
4 ; RUN: opt < %s -instcombine -S | FileCheck %s
7 define i32 @test1(i32 %A) {
8 %B = xor i32 %A, -1 ; <i32> [#uses=1]
9 %C = xor i32 %B, -1 ; <i32> [#uses=1]
13 define i1 @test2(i32 %A, i32 %B) {
14 ; Can change into setge
15 %cond = icmp sle i32 %A, %B ; <i1> [#uses=1]
16 %Ret = xor i1 %cond, true ; <i1> [#uses=1]
20 ; Test that demorgans law can be instcombined
21 define i32 @test3(i32 %A, i32 %B) {
22 %a = xor i32 %A, -1 ; <i32> [#uses=1]
23 %b = xor i32 %B, -1 ; <i32> [#uses=1]
24 %c = and i32 %a, %b ; <i32> [#uses=1]
25 %d = xor i32 %c, -1 ; <i32> [#uses=1]
29 ; Test that demorgens law can work with constants
30 define i32 @test4(i32 %A, i32 %B) {
31 %a = xor i32 %A, -1 ; <i32> [#uses=1]
32 %c = and i32 %a, 5 ; <i32> [#uses=1]
33 %d = xor i32 %c, -1 ; <i32> [#uses=1]
37 ; test the mirror of demorgans law...
38 define i32 @test5(i32 %A, i32 %B) {
39 %a = xor i32 %A, -1 ; <i32> [#uses=1]
40 %b = xor i32 %B, -1 ; <i32> [#uses=1]
41 %c = or i32 %a, %b ; <i32> [#uses=1]
42 %d = xor i32 %c, -1 ; <i32> [#uses=1]
47 define zeroext i8 @test6(i32 %a, i32 %b) nounwind {
49 %tmp1not = xor i32 %a, -1 ; <i32> [#uses=1]
50 %tmp2not = xor i32 %b, -1 ; <i32> [#uses=1]
51 %tmp3 = icmp slt i32 %tmp1not, %tmp2not ; <i1> [#uses=1]
52 %retval67 = zext i1 %tmp3 to i8 ; <i8> [#uses=1]
56 define <2 x i1> @test7(<2 x i32> %A, <2 x i32> %B) {
57 %cond = icmp sle <2 x i32> %A, %B
58 %Ret = xor <2 x i1> %cond, <i1 true, i1 true>