[PATCH] D63589: [X86] Add BLSI to isUseDefConvertible.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 19 23:59:08 PDT 2019


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63589

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


Index: llvm/test/CodeGen/X86/bmi.ll
===================================================================
--- llvm/test/CodeGen/X86/bmi.ll
+++ llvm/test/CodeGen/X86/bmi.ll
@@ -1240,8 +1240,7 @@
 ; 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 @@
 ; 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
Index: llvm/lib/Target/X86/X86InstrInfo.cpp
===================================================================
--- llvm/lib/Target/X86/X86InstrInfo.cpp
+++ llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -3369,6 +3369,9 @@
   case X86::BSR32rr:
   case X86::BSR64rr:
     return X86::COND_E;
+  case X86::BLSI32rr:
+  case X86::BLSI64rr:
+    return X86::COND_AE;
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63589.205742.patch
Type: text/x-patch
Size: 1115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190620/377067bb/attachment.bin>


More information about the llvm-commits mailing list