176 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 52; RUN: llc < %s -mtriple=i686-linux-gnu -mattr=+cmov -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefix=X863; RUN: llc < %s -mtriple=i686-linux-gnu -mattr=+cmov -global-isel -global-isel-abort=1 | FileCheck %s --check-prefix=X86-GISEL4; RUN: llc < %s -mtriple=i686-linux-gnu -mattr=+cmov -fast-isel=0 -global-isel=0 | FileCheck %s --check-prefix=X865; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefix=X646; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefix=X64-GISEL7; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel=0 -global-isel=0 | FileCheck %s --check-prefix=X648 9; Test that we can generate an fcmove, and also that it passes verification.10 11define x86_fp80 @cmove_cmp(x86_fp80 %a, x86_fp80 %b, i32 %c) {12; X86-LABEL: cmove_cmp:13; X86: # %bb.0:14; X86-NEXT: fldt {{[0-9]+}}(%esp)15; X86-NEXT: fldt {{[0-9]+}}(%esp)16; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)17; X86-NEXT: fadd %st(1), %st18; X86-NEXT: fxch %st(1)19; X86-NEXT: fcmove %st(1), %st20; X86-NEXT: fstp %st(1)21; X86-NEXT: retl22;23; X86-GISEL-LABEL: cmove_cmp:24; X86-GISEL: # %bb.0:25; X86-GISEL-NEXT: fldt {{[0-9]+}}(%esp)26; X86-GISEL-NEXT: fldt {{[0-9]+}}(%esp)27; X86-GISEL-NEXT: xorl %eax, %eax28; X86-GISEL-NEXT: cmpl $0, {{[0-9]+}}(%esp)29; X86-GISEL-NEXT: sete %al30; X86-GISEL-NEXT: fadd %st, %st(1)31; X86-GISEL-NEXT: andl $1, %eax32; X86-GISEL-NEXT: testl %eax, %eax33; X86-GISEL-NEXT: fxch %st(1)34; X86-GISEL-NEXT: fcmove %st(1), %st35; X86-GISEL-NEXT: fstp %st(1)36; X86-GISEL-NEXT: retl37;38; X64-LABEL: cmove_cmp:39; X64: # %bb.0:40; X64-NEXT: fldt {{[0-9]+}}(%rsp)41; X64-NEXT: fldt {{[0-9]+}}(%rsp)42; X64-NEXT: testl %edi, %edi43; X64-NEXT: fadd %st(1), %st44; X64-NEXT: fxch %st(1)45; X64-NEXT: fcmove %st(1), %st46; X64-NEXT: fstp %st(1)47; X64-NEXT: retq48;49; X64-GISEL-LABEL: cmove_cmp:50; X64-GISEL: # %bb.0:51; X64-GISEL-NEXT: fldt {{[0-9]+}}(%rsp)52; X64-GISEL-NEXT: fldt {{[0-9]+}}(%rsp)53; X64-GISEL-NEXT: xorl %eax, %eax54; X64-GISEL-NEXT: cmpl $0, %edi55; X64-GISEL-NEXT: sete %al56; X64-GISEL-NEXT: fadd %st, %st(1)57; X64-GISEL-NEXT: andl $1, %eax58; X64-GISEL-NEXT: testl %eax, %eax59; X64-GISEL-NEXT: fxch %st(1)60; X64-GISEL-NEXT: fcmove %st(1), %st61; X64-GISEL-NEXT: fstp %st(1)62; X64-GISEL-NEXT: retq63 %test = icmp eq i32 %c, 064 %add = fadd x86_fp80 %a, %b65 %ret = select i1 %test, x86_fp80 %add, x86_fp80 %b66 ret x86_fp80 %ret67}68 69define x86_fp80 @cmove_arg(x86_fp80 %a, x86_fp80 %b, i1 %test) {70; X86-LABEL: cmove_arg:71; X86: # %bb.0:72; X86-NEXT: fldt {{[0-9]+}}(%esp)73; X86-NEXT: fldt {{[0-9]+}}(%esp)74; X86-NEXT: fadd %st(1), %st75; X86-NEXT: testb $1, {{[0-9]+}}(%esp)76; X86-NEXT: fxch %st(1)77; X86-NEXT: fcmovne %st(1), %st78; X86-NEXT: fstp %st(1)79; X86-NEXT: retl80;81; X86-GISEL-LABEL: cmove_arg:82; X86-GISEL: # %bb.0:83; X86-GISEL-NEXT: fldt {{[0-9]+}}(%esp)84; X86-GISEL-NEXT: fldt {{[0-9]+}}(%esp)85; X86-GISEL-NEXT: fadd %st, %st(1)86; X86-GISEL-NEXT: movl $1, %eax87; X86-GISEL-NEXT: andl {{[0-9]+}}(%esp), %eax88; X86-GISEL-NEXT: testl %eax, %eax89; X86-GISEL-NEXT: fxch %st(1)90; X86-GISEL-NEXT: fcmove %st(1), %st91; X86-GISEL-NEXT: fstp %st(1)92; X86-GISEL-NEXT: retl93;94; X64-LABEL: cmove_arg:95; X64: # %bb.0:96; X64-NEXT: fldt {{[0-9]+}}(%rsp)97; X64-NEXT: fldt {{[0-9]+}}(%rsp)98; X64-NEXT: fadd %st(1), %st99; X64-NEXT: testb $1, %dil100; X64-NEXT: fxch %st(1)101; X64-NEXT: fcmovne %st(1), %st102; X64-NEXT: fstp %st(1)103; X64-NEXT: retq104;105; X64-GISEL-LABEL: cmove_arg:106; X64-GISEL: # %bb.0:107; X64-GISEL-NEXT: fldt {{[0-9]+}}(%rsp)108; X64-GISEL-NEXT: fldt {{[0-9]+}}(%rsp)109; X64-GISEL-NEXT: fadd %st, %st(1)110; X64-GISEL-NEXT: andl $1, %edi111; X64-GISEL-NEXT: testl %edi, %edi112; X64-GISEL-NEXT: fxch %st(1)113; X64-GISEL-NEXT: fcmove %st(1), %st114; X64-GISEL-NEXT: fstp %st(1)115; X64-GISEL-NEXT: retq116 %add = fadd x86_fp80 %a, %b117 %ret = select i1 %test, x86_fp80 %add, x86_fp80 %b118 ret x86_fp80 %ret119}120 121define x86_fp80 @cmove_load(x86_fp80 %a, x86_fp80 %b, ptr %p) {122; X86-LABEL: cmove_load:123; X86: # %bb.0:124; X86-NEXT: movl {{[0-9]+}}(%esp), %eax125; X86-NEXT: fldt {{[0-9]+}}(%esp)126; X86-NEXT: fldt {{[0-9]+}}(%esp)127; X86-NEXT: fadd %st(1), %st128; X86-NEXT: cmpb $0, (%eax)129; X86-NEXT: fxch %st(1)130; X86-NEXT: fcmovne %st(1), %st131; X86-NEXT: fstp %st(1)132; X86-NEXT: retl133;134; X86-GISEL-LABEL: cmove_load:135; X86-GISEL: # %bb.0:136; X86-GISEL-NEXT: fldt {{[0-9]+}}(%esp)137; X86-GISEL-NEXT: fldt {{[0-9]+}}(%esp)138; X86-GISEL-NEXT: movl {{[0-9]+}}(%esp), %eax139; X86-GISEL-NEXT: fadd %st, %st(1)140; X86-GISEL-NEXT: movzbl (%eax), %eax141; X86-GISEL-NEXT: andl $1, %eax142; X86-GISEL-NEXT: testl %eax, %eax143; X86-GISEL-NEXT: fxch %st(1)144; X86-GISEL-NEXT: fcmove %st(1), %st145; X86-GISEL-NEXT: fstp %st(1)146; X86-GISEL-NEXT: retl147;148; X64-LABEL: cmove_load:149; X64: # %bb.0:150; X64-NEXT: fldt {{[0-9]+}}(%rsp)151; X64-NEXT: fldt {{[0-9]+}}(%rsp)152; X64-NEXT: fadd %st(1), %st153; X64-NEXT: cmpb $0, (%rdi)154; X64-NEXT: fxch %st(1)155; X64-NEXT: fcmovne %st(1), %st156; X64-NEXT: fstp %st(1)157; X64-NEXT: retq158;159; X64-GISEL-LABEL: cmove_load:160; X64-GISEL: # %bb.0:161; X64-GISEL-NEXT: fldt {{[0-9]+}}(%rsp)162; X64-GISEL-NEXT: fldt {{[0-9]+}}(%rsp)163; X64-GISEL-NEXT: fadd %st, %st(1)164; X64-GISEL-NEXT: movzbl (%rdi), %eax165; X64-GISEL-NEXT: andl $1, %eax166; X64-GISEL-NEXT: testl %eax, %eax167; X64-GISEL-NEXT: fxch %st(1)168; X64-GISEL-NEXT: fcmove %st(1), %st169; X64-GISEL-NEXT: fstp %st(1)170; X64-GISEL-NEXT: retq171 %test = load i1, ptr %p172 %add = fadd x86_fp80 %a, %b173 %ret = select i1 %test, x86_fp80 %add, x86_fp80 %b174 ret x86_fp80 %ret175}176