215 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 52; RUN: llc < %s -mtriple=x86_64-- -mcpu=x86-64-v2 | FileCheck %s --check-prefixes=CHECK,NOBMI3; RUN: llc < %s -mtriple=x86_64-- -mcpu=x86-64-v3 | FileCheck %s --check-prefixes=CHECK,BMI4 5define i64 @test_i64(i64 %w, i64 %x, i64 %y, i64 %z) {6; NOBMI-LABEL: test_i64:7; NOBMI: # %bb.0: # %Entry8; NOBMI-NEXT: movq %rcx, %rax9; NOBMI-NEXT: andq %rdx, %rsi10; NOBMI-NEXT: notq %rsi11; NOBMI-NEXT: andq %rdi, %rsi12; NOBMI-NEXT: notq %rax13; NOBMI-NEXT: orq %rdx, %rax14; NOBMI-NEXT: andq %rsi, %rax15; NOBMI-NEXT: retq16;17; BMI-LABEL: test_i64:18; BMI: # %bb.0: # %Entry19; BMI-NEXT: andq %rdx, %rsi20; BMI-NEXT: andnq %rdi, %rsi, %rax21; BMI-NEXT: andnq %rcx, %rdx, %rcx22; BMI-NEXT: andnq %rax, %rcx, %rax23; BMI-NEXT: retq24Entry:25 %and1 = and i64 %y, %x26 %xor1 = xor i64 %and1, -127 %and2 = and i64 %xor1, %w28 %.not = xor i64 %z, -129 %or1 = or i64 %.not, %y30 %and3 = and i64 %and2, %or131 ret i64 %and332}33 34define i32 @test_i32(i32 %w, i32 %x, i32 %y, i32 %z) {35; NOBMI-LABEL: test_i32:36; NOBMI: # %bb.0: # %Entry37; NOBMI-NEXT: movl %ecx, %eax38; NOBMI-NEXT: andl %edx, %esi39; NOBMI-NEXT: notl %esi40; NOBMI-NEXT: andl %edi, %esi41; NOBMI-NEXT: notl %eax42; NOBMI-NEXT: orl %edx, %eax43; NOBMI-NEXT: andl %esi, %eax44; NOBMI-NEXT: retq45;46; BMI-LABEL: test_i32:47; BMI: # %bb.0: # %Entry48; BMI-NEXT: andl %edx, %esi49; BMI-NEXT: andnl %edi, %esi, %eax50; BMI-NEXT: andnl %ecx, %edx, %ecx51; BMI-NEXT: andnl %eax, %ecx, %eax52; BMI-NEXT: retq53Entry:54 %and1 = and i32 %y, %x55 %xor1 = xor i32 %and1, -156 %and2 = and i32 %xor1, %w57 %.not = xor i32 %z, -158 %or1 = or i32 %.not, %y59 %and3 = and i32 %and2, %or160 ret i32 %and361}62 63define i16 @test_i16(i16 %w, i16 %x, i16 %y, i16 %z) {64; NOBMI-LABEL: test_i16:65; NOBMI: # %bb.0: # %Entry66; NOBMI-NEXT: movl %ecx, %eax67; NOBMI-NEXT: andl %edx, %esi68; NOBMI-NEXT: notl %esi69; NOBMI-NEXT: andl %edi, %esi70; NOBMI-NEXT: notl %eax71; NOBMI-NEXT: orl %edx, %eax72; NOBMI-NEXT: andl %esi, %eax73; NOBMI-NEXT: # kill: def $ax killed $ax killed $eax74; NOBMI-NEXT: retq75;76; BMI-LABEL: test_i16:77; BMI: # %bb.0: # %Entry78; BMI-NEXT: andl %edx, %esi79; BMI-NEXT: andnl %edi, %esi, %eax80; BMI-NEXT: notl %ecx81; BMI-NEXT: orl %edx, %ecx82; BMI-NEXT: andl %ecx, %eax83; BMI-NEXT: # kill: def $ax killed $ax killed $eax84; BMI-NEXT: retq85Entry:86 %and1 = and i16 %y, %x87 %xor1 = xor i16 %and1, -188 %and2 = and i16 %xor1, %w89 %.not = xor i16 %z, -190 %or1 = or i16 %.not, %y91 %and3 = and i16 %and2, %or192 ret i16 %and393}94 95define i8 @test_i8(i8 %w, i8 %x, i8 %y, i8 %z) {96; CHECK-LABEL: test_i8:97; CHECK: # %bb.0: # %Entry98; CHECK-NEXT: movl %edx, %eax99; CHECK-NEXT: andl %edx, %esi100; CHECK-NEXT: notb %sil101; CHECK-NEXT: andb %dil, %sil102; CHECK-NEXT: notb %cl103; CHECK-NEXT: orb %cl, %al104; CHECK-NEXT: andb %sil, %al105; CHECK-NEXT: # kill: def $al killed $al killed $eax106; CHECK-NEXT: retq107Entry:108 %and1 = and i8 %y, %x109 %xor1 = xor i8 %and1, -1110 %and2 = and i8 %xor1, %w111 %.not = xor i8 %z, -1112 %or1 = or i8 %.not, %y113 %and3 = and i8 %and2, %or1114 ret i8 %and3115}116 117define <16 x i8> @test_v16i8(<16 x i8> %w, <16 x i8> %x, <16 x i8> %y, <16 x i8> %z) {118; NOBMI-LABEL: test_v16i8:119; NOBMI: # %bb.0: # %Entry120; NOBMI-NEXT: andps %xmm2, %xmm1121; NOBMI-NEXT: andnps %xmm0, %xmm1122; NOBMI-NEXT: andnps %xmm3, %xmm2123; NOBMI-NEXT: andnps %xmm1, %xmm2124; NOBMI-NEXT: movaps %xmm2, %xmm0125; NOBMI-NEXT: retq126;127; BMI-LABEL: test_v16i8:128; BMI: # %bb.0: # %Entry129; BMI-NEXT: vandps %xmm1, %xmm2, %xmm1130; BMI-NEXT: vandnps %xmm0, %xmm1, %xmm0131; BMI-NEXT: vandnps %xmm3, %xmm2, %xmm1132; BMI-NEXT: vandnps %xmm0, %xmm1, %xmm0133; BMI-NEXT: retq134Entry:135 %and1 = and <16 x i8> %y, %x136 %xor1 = xor <16 x i8> %and1, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>137 %and2 = and <16 x i8> %xor1, %w138 %.not = xor <16 x i8> %z, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>139 %or1 = or <16 x i8> %.not, %y140 %and3 = and <16 x i8> %and2, %or1141 ret <16 x i8> %and3142}143 144define <32 x i8> @test_v32i8(<32 x i8> %w, <32 x i8> %x, <32 x i8> %y, <32 x i8> %z) {145; NOBMI-LABEL: test_v32i8:146; NOBMI: # %bb.0: # %Entry147; NOBMI-NEXT: andps %xmm4, %xmm2148; NOBMI-NEXT: andps %xmm5, %xmm3149; NOBMI-NEXT: andnps %xmm1, %xmm3150; NOBMI-NEXT: andnps %xmm0, %xmm2151; NOBMI-NEXT: andnps %xmm6, %xmm4152; NOBMI-NEXT: andnps %xmm2, %xmm4153; NOBMI-NEXT: andnps %xmm7, %xmm5154; NOBMI-NEXT: andnps %xmm3, %xmm5155; NOBMI-NEXT: movaps %xmm4, %xmm0156; NOBMI-NEXT: movaps %xmm5, %xmm1157; NOBMI-NEXT: retq158;159; BMI-LABEL: test_v32i8:160; BMI: # %bb.0: # %Entry161; BMI-NEXT: vandps %ymm1, %ymm2, %ymm1162; BMI-NEXT: vandnps %ymm0, %ymm1, %ymm0163; BMI-NEXT: vandnps %ymm3, %ymm2, %ymm1164; BMI-NEXT: vandnps %ymm0, %ymm1, %ymm0165; BMI-NEXT: retq166Entry:167 %and1 = and <32 x i8> %y, %x168 %xor1 = xor <32 x i8> %and1, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>169 %and2 = and <32 x i8> %xor1, %w170 %.not = xor <32 x i8> %z, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>171 %or1 = or <32 x i8> %.not, %y172 %and3 = and <32 x i8> %and2, %or1173 ret <32 x i8> %and3174}175 176; PR112347 - don't fold if we'd be inverting a constant, as demorgan normalisation will invert it back again.177define void @PR112347(ptr %p0, ptr %p1, ptr %p2) {178; CHECK-LABEL: PR112347:179; CHECK: # %bb.0:180; CHECK-NEXT: movl (%rdi), %eax181; CHECK-NEXT: notl %eax182; CHECK-NEXT: orl $-16777204, %eax # imm = 0xFF00000C183; CHECK-NEXT: andl (%rsi), %eax184; CHECK-NEXT: movl %eax, (%rdx)185; CHECK-NEXT: retq186 %load0 = load i32, ptr %p0, align 1187 %load1 = load i32, ptr %p1, align 4188 %not = xor i32 %load0, -1189 %top = or i32 %not, -16777204190 %mask = and i32 %load1, %top191 store i32 %mask, ptr %p2, align 4192 ret void193}194 195define void @PR113240(i64 %a) {196; CHECK-LABEL: PR113240:197; CHECK: # %bb.0: # %entry198; CHECK-NEXT: movq %rdi, %rax199; CHECK-NEXT: notq %rax200; CHECK-NEXT: movabsq $8796093022206, %rcx # imm = 0x7FFFFFFFFFE201; CHECK-NEXT: notq %rcx202; CHECK-NEXT: orq %rax, %rcx203; CHECK-NEXT: andq %rdi, %rcx204; CHECK-NEXT: movq %rcx, 0205; CHECK-NEXT: retq206entry:207 %and = and i64 %a, 8796093022206208 %bf.value = and i64 8796093022206, 0209 %not = xor i64 %and, -1210 %and4 = and i64 %a, %not211 store i64 %and4, ptr null, align 8212 ret void213}214 215