171 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X863; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X644; rdar://73672295 6define i32 @t(i32 %a, i32 %b) nounwind ssp {7; X86-LABEL: t:8; X86: # %bb.0: # %entry9; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax10; X86-NEXT: xorb {{[0-9]+}}(%esp), %al11; X86-NEXT: testb $64, %al12; X86-NEXT: jne bar # TAILCALL13; X86-NEXT: # %bb.1: # %bb14; X86-NEXT: jmp foo # TAILCALL15;16; X64-LABEL: t:17; X64: # %bb.0: # %entry18; X64-NEXT: xorl %esi, %edi19; X64-NEXT: xorl %eax, %eax20; X64-NEXT: testl $16384, %edi # imm = 0x400021; X64-NEXT: jne bar # TAILCALL22; X64-NEXT: # %bb.1: # %bb23; X64-NEXT: jmp foo # TAILCALL24entry:25 %0 = and i32 %a, 1638426 %1 = icmp ne i32 %0, 027 %2 = and i32 %b, 1638428 %3 = icmp ne i32 %2, 029 %4 = xor i1 %1, %330 br i1 %4, label %bb1, label %bb31 32bb: ; preds = %entry33 %5 = tail call i32 (...) @foo() nounwind ; <i32> [#uses=1]34 ret i32 %535 36bb1: ; preds = %entry37 %6 = tail call i32 (...) @bar() nounwind ; <i32> [#uses=1]38 ret i32 %639}40 41declare dso_local i32 @foo(...)42 43declare dso_local i32 @bar(...)44 45define i32 @t2(i32 %x, i32 %y) nounwind ssp {46; X86-LABEL: t2:47; X86: # %bb.0: # %entry48; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)49; X86-NEXT: sete %al50; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)51; X86-NEXT: sete %cl52; X86-NEXT: cmpb %al, %cl53; X86-NEXT: jne foo # TAILCALL54; X86-NEXT: # %bb.1: # %return55; X86-NEXT: retl56;57; X64-LABEL: t2:58; X64: # %bb.0: # %entry59; X64-NEXT: testl %edi, %edi60; X64-NEXT: sete %al61; X64-NEXT: testl %esi, %esi62; X64-NEXT: sete %cl63; X64-NEXT: cmpb %al, %cl64; X64-NEXT: je .LBB1_165; X64-NEXT: # %bb.2: # %bb66; X64-NEXT: xorl %eax, %eax67; X64-NEXT: jmp foo # TAILCALL68; X64-NEXT: .LBB1_1: # %return69; X64-NEXT: retq70 71entry:72 %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1]73 %1 = icmp eq i32 %y, 0 ; <i1> [#uses=1]74 %2 = xor i1 %1, %0 ; <i1> [#uses=1]75 br i1 %2, label %bb, label %return76 77bb: ; preds = %entry78 %3 = tail call i32 (...) @foo() nounwind ; <i32> [#uses=0]79 ret i32 undef80 81return: ; preds = %entry82 ret i32 undef83}84 85; PR4570386; https://bugs.llvm.org/show_bug.cgi?id=4570387 88define i1 @xor_not_bools(i1 zeroext %x, i1 zeroext %y) nounwind {89; X86-LABEL: xor_not_bools:90; X86: # %bb.0:91; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax92; X86-NEXT: xorb {{[0-9]+}}(%esp), %al93; X86-NEXT: xorb $1, %al94; X86-NEXT: retl95;96; X64-LABEL: xor_not_bools:97; X64: # %bb.0:98; X64-NEXT: movl %edi, %eax99; X64-NEXT: xorl %esi, %eax100; X64-NEXT: xorb $1, %al101; X64-NEXT: # kill: def $al killed $al killed $eax102; X64-NEXT: retq103 %xor = xor i1 %x, %y104 %not = xor i1 %xor, true105 ret i1 %not106}107 108; This is probably not canonical IR; just testing another possible pattern.109 110define zeroext i1 @xor_not_cmps(i32 %x, i32 %y) nounwind {111; X86-LABEL: xor_not_cmps:112; X86: # %bb.0:113; X86-NEXT: cmpl $42, {{[0-9]+}}(%esp)114; X86-NEXT: setne %cl115; X86-NEXT: cmpl $235, {{[0-9]+}}(%esp)116; X86-NEXT: sete %al117; X86-NEXT: xorb %cl, %al118; X86-NEXT: xorb $1, %al119; X86-NEXT: retl120;121; X64-LABEL: xor_not_cmps:122; X64: # %bb.0:123; X64-NEXT: cmpl $42, %edi124; X64-NEXT: setne %cl125; X64-NEXT: cmpl $235, %esi126; X64-NEXT: sete %al127; X64-NEXT: xorb %cl, %al128; X64-NEXT: xorb $1, %al129; X64-NEXT: retq130 %cmpx = icmp ne i32 %x, 42131 %cmpy = icmp eq i32 %y, 235132 %xor = xor i1 %cmpx, %cmpy133 %not = xor i1 %xor, 1134 ret i1 %not135}136 137define zeroext i1 @xor_not_cmps_extra_use(i32 %x, i32 %y, ptr %p) nounwind {138; X86-LABEL: xor_not_cmps_extra_use:139; X86: # %bb.0:140; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx141; X86-NEXT: cmpl $42, {{[0-9]+}}(%esp)142; X86-NEXT: setne %dl143; X86-NEXT: cmpl $235, {{[0-9]+}}(%esp)144; X86-NEXT: sete %al145; X86-NEXT: xorb %dl, %al146; X86-NEXT: movzbl %al, %edx147; X86-NEXT: movl %edx, (%ecx)148; X86-NEXT: xorb $1, %al149; X86-NEXT: retl150;151; X64-LABEL: xor_not_cmps_extra_use:152; X64: # %bb.0:153; X64-NEXT: cmpl $42, %edi154; X64-NEXT: setne %al155; X64-NEXT: cmpl $235, %esi156; X64-NEXT: sete %cl157; X64-NEXT: xorb %al, %cl158; X64-NEXT: movzbl %cl, %eax159; X64-NEXT: movl %eax, (%rdx)160; X64-NEXT: xorb $1, %al161; X64-NEXT: # kill: def $al killed $al killed $eax162; X64-NEXT: retq163 %cmpx = icmp ne i32 %x, 42164 %cmpy = icmp eq i32 %y, 235165 %xor = xor i1 %cmpx, %cmpy166 %z = zext i1 %xor to i32167 store i32 %z, ptr %p168 %not = xor i1 %xor, 1169 ret i1 %not170}171