1; Simple tests for icmp with i8, i16, i32 operands. 2 3; RUN: %if --need=allow_dump --need=target_MIPS32 --command %p2i \ 4; RUN: --filetype=asm --target mips32 -i %s --args -O2 \ 5; RUN: -allow-externally-defined-symbols \ 6; RUN: | %if --need=allow_dump --need=target_MIPS32 --command FileCheck %s \ 7; RUN: --check-prefix=COMMON --check-prefix=MIPS32 8; RUN: %if --need=allow_dump --need=target_MIPS32 --command %p2i \ 9; RUN: --filetype=asm --target mips32 -i %s --args -Om1 \ 10; RUN: -allow-externally-defined-symbols \ 11; RUN: | %if --need=allow_dump --need=target_MIPS32 --command FileCheck %s \ 12; RUN: --check-prefix=COMMON --check-prefix=MIPS32 13 14define internal i32 @icmpEq32(i32 %a, i32 %b) { 15entry: 16 %cmp = icmp eq i32 %a, %b 17 %cmp.ret_ext = zext i1 %cmp to i32 18 ret i32 %cmp.ret_ext 19} 20; MIPS32-LABEL: icmpEq32 21; MIPS32: xor 22; MIPS32: sltiu {{.*}}, {{.*}}, 1 23 24define internal i32 @icmpNe32(i32 %a, i32 %b) { 25entry: 26 %cmp = icmp ne i32 %a, %b 27 %cmp.ret_ext = zext i1 %cmp to i32 28 ret i32 %cmp.ret_ext 29} 30; MIPS32-LABEL: icmpNe32 31; MIPS32: xor 32; MIPS32: sltu {{.*}}, $zero, {{.*}} 33 34define internal i32 @icmpSgt32(i32 %a, i32 %b) { 35entry: 36 %cmp = icmp sgt i32 %a, %b 37 %cmp.ret_ext = zext i1 %cmp to i32 38 ret i32 %cmp.ret_ext 39} 40; MIPS32-LABEL: icmpSgt32 41; MIPS32: slt 42 43define internal i32 @icmpUgt32(i32 %a, i32 %b) { 44entry: 45 %cmp = icmp ugt i32 %a, %b 46 %cmp.ret_ext = zext i1 %cmp to i32 47 ret i32 %cmp.ret_ext 48} 49; MIPS32-LABEL: icmpUgt32 50; MIPS32: sltu 51 52define internal i32 @icmpSge32(i32 %a, i32 %b) { 53entry: 54 %cmp = icmp sge i32 %a, %b 55 %cmp.ret_ext = zext i1 %cmp to i32 56 ret i32 %cmp.ret_ext 57} 58; MIPS32-LABEL: icmpSge32 59; MIPS32: slt 60; MIPS32: xori {{.*}}, {{.*}}, 1 61 62define internal i32 @icmpUge32(i32 %a, i32 %b) { 63entry: 64 %cmp = icmp uge i32 %a, %b 65 %cmp.ret_ext = zext i1 %cmp to i32 66 ret i32 %cmp.ret_ext 67} 68; MIPS32-LABEL: icmpUge32 69; MIPS32: sltu 70; MIPS32: xori {{.*}}, {{.*}}, 1 71 72define internal i32 @icmpSlt32(i32 %a, i32 %b) { 73entry: 74 %cmp = icmp slt i32 %a, %b 75 %cmp.ret_ext = zext i1 %cmp to i32 76 ret i32 %cmp.ret_ext 77} 78; MIPS32-LABEL: icmpSlt32 79; MIPS32: slt 80 81define internal i32 @icmpUlt32(i32 %a, i32 %b) { 82entry: 83 %cmp = icmp ult i32 %a, %b 84 %cmp.ret_ext = zext i1 %cmp to i32 85 ret i32 %cmp.ret_ext 86} 87; MIPS32-LABEL: icmpUlt32 88; MIPS32: sltu 89 90define internal i32 @icmpSle32(i32 %a, i32 %b) { 91entry: 92 %cmp = icmp sle i32 %a, %b 93 %cmp.ret_ext = zext i1 %cmp to i32 94 ret i32 %cmp.ret_ext 95} 96; MIPS32-LABEL: icmpSle32 97; MIPS32: slt 98; MIPS32: xori {{.*}}, {{.*}}, 1 99 100define internal i32 @icmpUle32(i32 %a, i32 %b) { 101entry: 102 %cmp = icmp ule i32 %a, %b 103 %cmp.ret_ext = zext i1 %cmp to i32 104 ret i32 %cmp.ret_ext 105} 106; MIPS32-LABEL: icmpUle32 107; MIPS32: sltu 108; MIPS32: xori {{.*}}, {{.*}}, 1 109 110define internal i32 @icmpEq8(i32 %a, i32 %b) { 111entry: 112 %a_8 = trunc i32 %a to i8 113 %b_8 = trunc i32 %b to i8 114 %icmp = icmp eq i8 %b_8, %a_8 115 %ret = zext i1 %icmp to i32 116 ret i32 %ret 117} 118; MIPS32-LABEL: icmpEq8 119; MIPS32: sll {{.*}}, {{.*}}, 24 120; MIPS32: sll {{.*}}, {{.*}}, 24 121; MIPS32: xor 122; MIPS32: sltiu {{.*}}, {{.*}}, 1 123 124define internal i32 @icmpSgt8(i32 %a, i32 %b) { 125entry: 126 %a_8 = trunc i32 %a to i8 127 %b_8 = trunc i32 %b to i8 128 %icmp = icmp sgt i8 %b_8, %a_8 129 %ret = zext i1 %icmp to i32 130 ret i32 %ret 131} 132; MIPS32-LABEL: icmpSgt8 133; MIPS32: sll {{.*}}, {{.*}}, 24 134; MIPS32: sll {{.*}}, {{.*}}, 24 135; MIPS32: slt 136 137define internal i32 @icmpUgt8(i32 %a, i32 %b) { 138entry: 139 %a_8 = trunc i32 %a to i8 140 %b_8 = trunc i32 %b to i8 141 %icmp = icmp ugt i8 %b_8, %a_8 142 %ret = zext i1 %icmp to i32 143 ret i32 %ret 144} 145; MIPS32-LABEL: icmpUgt8 146; MIPS32: sll {{.*}}, {{.*}}, 24 147; MIPS32: sll {{.*}}, {{.*}}, 24 148; MIPS32: sltu 149 150define internal i32 @icmpSgt16(i32 %a, i32 %b) { 151entry: 152 %a_16 = trunc i32 %a to i16 153 %b_16 = trunc i32 %b to i16 154 %icmp = icmp sgt i16 %b_16, %a_16 155 %ret = zext i1 %icmp to i32 156 ret i32 %ret 157} 158; MIPS32-LABEL: icmpSgt16 159; MIPS32: sll {{.*}}, {{.*}}, 16 160; MIPS32: sll {{.*}}, {{.*}}, 16 161; MIPS32: slt 162 163define internal i32 @icmpUgt16(i32 %a, i32 %b) { 164entry: 165 %a_16 = trunc i32 %a to i16 166 %b_16 = trunc i32 %b to i16 167 %icmp = icmp ugt i16 %b_16, %a_16 168 %ret = zext i1 %icmp to i32 169 ret i32 %ret 170} 171; MIPS32-LABEL: icmpUgt16 172; MIPS32: sll {{.*}}, {{.*}}, 16 173; MIPS32: sll {{.*}}, {{.*}}, 16 174; MIPS32: sltu 175