[llvm] r363957 - [X86] Add BLSI to isUseDefConvertible.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 10:52:53 PDT 2019


Author: ctopper
Date: Thu Jun 20 10:52:53 2019
New Revision: 363957

URL: http://llvm.org/viewvc/llvm-project?rev=363957&view=rev
Log:
[X86] Add BLSI to isUseDefConvertible.

Summary:
BLSI sets the C flag is the input is not zero. So if its followed
by a TEST of the input where only the Z flag is consumed, we can
replace it with the opposite check of the C flag.

We should be able to do the same for BLSMSK and BLSR, but the
naive test case for those is being optimized to a subo by
CodeGenPrepare.

Reviewers: spatel, RKSimon

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63589

Modified:
    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
    llvm/trunk/test/CodeGen/X86/bmi.ll

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=363957&r1=363956&r2=363957&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Thu Jun 20 10:52:53 2019
@@ -3369,6 +3369,10 @@ static X86::CondCode isUseDefConvertible
   case X86::BSR32rr:
   case X86::BSR64rr:
     return X86::COND_E;
+  case X86::BLSI32rr:
+  case X86::BLSI64rr:
+    return X86::COND_AE;
+  // TODO: BLSR, BLSMSK, and TBM instructions.
   }
 }
 

Modified: llvm/trunk/test/CodeGen/X86/bmi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/bmi.ll?rev=363957&r1=363956&r2=363957&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/bmi.ll (original)
+++ llvm/trunk/test/CodeGen/X86/bmi.ll Thu Jun 20 10:52:53 2019
@@ -1240,8 +1240,7 @@ define i32 @blsi_cflag_32(i32 %x, i32 %y
 ; X64-LABEL: blsi_cflag_32:
 ; X64:       # %bb.0:
 ; X64-NEXT:    blsil %edi, %eax
-; X64-NEXT:    testl %edi, %edi
-; X64-NEXT:    cmovel %esi, %eax
+; X64-NEXT:    cmovael %esi, %eax
 ; X64-NEXT:    retq
   %tobool = icmp eq i32 %x, 0
   %sub = sub nsw i32 0, %x
@@ -1279,8 +1278,7 @@ define i64 @blsi_cflag_64(i64 %x, i64 %y
 ; X64-LABEL: blsi_cflag_64:
 ; X64:       # %bb.0:
 ; X64-NEXT:    blsiq %rdi, %rax
-; X64-NEXT:    testq %rdi, %rdi
-; X64-NEXT:    cmoveq %rsi, %rax
+; X64-NEXT:    cmovaeq %rsi, %rax
 ; X64-NEXT:    retq
   %tobool = icmp eq i64 %x, 0
   %sub = sub nsw i64 0, %x




More information about the llvm-commits mailing list