From 98ae8f833f3b21f972938f3bda0934fc10b9c42f Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 12 Feb 2018 02:48:42 +0000 Subject: [PATCH] [X86] Change some compare patterns to use loadi8/loadi16/loadi32/loadi64 helper fragments. This enables CMP8mi to fold zextloadi8i1 which in all tests allows us to avoid creating a TEST8rr that peephole can't fold. llvm-svn: 324863 --- llvm/lib/Target/X86/X86InstrArithmetic.td | 9 +++++---- llvm/test/CodeGen/X86/avx512-insert-extract.ll | 3 +-- llvm/test/CodeGen/X86/i386-shrink-wrapping.ll | 11 ++++++----- llvm/test/CodeGen/X86/x86-shrink-wrapping.ll | 5 ++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/llvm/lib/Target/X86/X86InstrArithmetic.td b/llvm/lib/Target/X86/X86InstrArithmetic.td index e6219aa6fcb4..a90c3792bf5c 100644 --- a/llvm/lib/Target/X86/X86InstrArithmetic.td +++ b/llvm/lib/Target/X86/X86InstrArithmetic.td @@ -850,7 +850,8 @@ class BinOpMR_RMW_FF opcode, string mnemonic, X86TypeInfo typeinfo, class BinOpMR_F opcode, string mnemonic, X86TypeInfo typeinfo, SDPatternOperator opnode> : BinOpMR; + [(set EFLAGS, (opnode (typeinfo.LoadNode addr:$dst), + typeinfo.RegClass:$src))]>; // BinOpMI - Instructions like "add [mem], imm". class BinOpMI opcode, string mnemonic, X86TypeInfo typeinfo, @@ -882,8 +883,8 @@ class BinOpMI_RMW_FF opcode, string mnemonic, X86TypeInfo typeinfo, class BinOpMI_F opcode, string mnemonic, X86TypeInfo typeinfo, SDPatternOperator opnode, Format f> : BinOpMI; + [(set EFLAGS, (opnode (typeinfo.LoadNode addr:$dst), + typeinfo.ImmOperator:$src))]>; // BinOpMI8 - Instructions like "add [mem], imm8". class BinOpMI8 : BinOpMI8; // BinOpAI - Instructions like "add %eax, %eax, imm", that imp-def EFLAGS. diff --git a/llvm/test/CodeGen/X86/avx512-insert-extract.ll b/llvm/test/CodeGen/X86/avx512-insert-extract.ll index 31beddffb01f..205af7949c20 100644 --- a/llvm/test/CodeGen/X86/avx512-insert-extract.ll +++ b/llvm/test/CodeGen/X86/avx512-insert-extract.ll @@ -285,9 +285,8 @@ define i64 @test14(<8 x i64>%a, <8 x i64>%b, i64 %a1, i64 %b1) { define i16 @test15(i1 *%addr) { ; CHECK-LABEL: test15: ; CHECK: ## %bb.0: -; CHECK-NEXT: movb (%rdi), %al ; CHECK-NEXT: xorl %ecx, %ecx -; CHECK-NEXT: testb %al, %al +; CHECK-NEXT: cmpb $0, (%rdi) ; CHECK-NEXT: movw $-1, %ax ; CHECK-NEXT: cmovew %cx, %ax ; CHECK-NEXT: retq diff --git a/llvm/test/CodeGen/X86/i386-shrink-wrapping.ll b/llvm/test/CodeGen/X86/i386-shrink-wrapping.ll index d4e099ac6558..8a5b92a82fb2 100644 --- a/llvm/test/CodeGen/X86/i386-shrink-wrapping.ll +++ b/llvm/test/CodeGen/X86/i386-shrink-wrapping.ll @@ -40,11 +40,12 @@ target triple = "i386-apple-macosx10.5" ; The for.end block is split to accomadate the different selects. ; We are interested in the one with the call, so skip until the branch. ; CHECK: [[FOREND_LABEL]]: -; CHECK-NEXT: movb _d, [[D:%[a-z]+]] -; [...] -; CHECK: jne [[CALL_LABEL:LBB[0-9_]+]] +; CHECK-NEXT: xorl +; CHECK-NEXT: cmpb $0, _d +; CHECK-NEXT: movl $0, %edx +; CHECK-NEXT: jne [[CALL_LABEL:LBB[0-9_]+]] ; -; CHECK: movb $6, [[D]] +; CHECK: movb $6, %dl ; ; CHECK: [[CALL_LABEL]] ; @@ -54,7 +55,7 @@ target triple = "i386-apple-macosx10.5" ; ENABLE-NEXT: leal -20(%esp), %esp ; ; CHECK-NEXT: L_e$non_lazy_ptr, [[E:%[a-z]+]] -; CHECK-NEXT: movb [[D]], ([[E]]) +; CHECK-NEXT: movb %dl, ([[E]]) ; CHECK-NEXT: movsbl ([[E]]), [[CONV:%[a-z]+]] ; CHECK-NEXT: movl $6, [[CONV:%[a-z]+]] ; The eflags is used in the next instruction. diff --git a/llvm/test/CodeGen/X86/x86-shrink-wrapping.ll b/llvm/test/CodeGen/X86/x86-shrink-wrapping.ll index ebb363cf7a39..65a5c78a5dad 100644 --- a/llvm/test/CodeGen/X86/x86-shrink-wrapping.ll +++ b/llvm/test/CodeGen/X86/x86-shrink-wrapping.ll @@ -808,10 +808,9 @@ end: ; DISABLE-NEXT: subq $16, %rsp ; ; Load the value of b. -; CHECK: movb _b(%rip), [[BOOL:%cl]] ; Create the zero value for the select assignment. -; CHECK-NEXT: xorl [[CMOVE_VAL:%eax]], [[CMOVE_VAL]] -; CHECK-NEXT: testb [[BOOL]], [[BOOL]] +; CHECK: xorl [[CMOVE_VAL:%eax]], [[CMOVE_VAL]] +; CHECK-NEXT: cmpb $0, _b(%rip) ; CHECK-NEXT: jne [[STOREC_LABEL:LBB[0-9_]+]] ; ; CHECK: movb $48, [[CMOVE_VAL:%al]]