[PATCH] D43346: [X86] Enable BT to be used in place of TEST for single bit checks under optsize
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 15 12:30:39 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325290: [X86] Enable BT to be used in place of TEST for single bit checks under optsize (authored by ctopper, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43346?vs=134481&id=134492#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43346
Files:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/test-vs-bittest.ll
Index: llvm/trunk/test/CodeGen/X86/test-vs-bittest.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/test-vs-bittest.ll
+++ llvm/trunk/test/CodeGen/X86/test-vs-bittest.ll
@@ -75,8 +75,8 @@
; CHECK: # %bb.0:
; CHECK-NEXT: pushq %rax
; CHECK-NEXT: .cfi_def_cfa_offset 16
-; CHECK-NEXT: testl $2048, %edi # imm = 0x800
-; CHECK-NEXT: je .LBB3_2
+; CHECK-NEXT: btl $11, %edi
+; CHECK-NEXT: jae .LBB3_2
; CHECK-NEXT: # %bb.1: # %yes
; CHECK-NEXT: callq bar
; CHECK-NEXT: .LBB3_2: # %no
@@ -259,8 +259,8 @@
; CHECK: # %bb.0:
; CHECK-NEXT: pushq %rax
; CHECK-NEXT: .cfi_def_cfa_offset 16
-; CHECK-NEXT: testl $2048, %edi # imm = 0x800
-; CHECK-NEXT: je .LBB11_2
+; CHECK-NEXT: btl $11, %edi
+; CHECK-NEXT: jae .LBB11_2
; CHECK-NEXT: # %bb.1: # %yes
; CHECK-NEXT: callq bar
; CHECK-NEXT: .LBB11_2: # %no
@@ -351,8 +351,8 @@
; CHECK: # %bb.0:
; CHECK-NEXT: pushq %rax
; CHECK-NEXT: .cfi_def_cfa_offset 16
-; CHECK-NEXT: testl $2048, %edi # imm = 0x800
-; CHECK-NEXT: je .LBB15_2
+; CHECK-NEXT: btl $11, %edi
+; CHECK-NEXT: jae .LBB15_2
; CHECK-NEXT: # %bb.1: # %yes
; CHECK-NEXT: callq bar
; CHECK-NEXT: .LBB15_2: # %no
Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
@@ -17709,12 +17709,15 @@
if (AndRHSVal == 1 && AndLHS.getOpcode() == ISD::SRL) {
LHS = AndLHS.getOperand(0);
RHS = AndLHS.getOperand(1);
- }
-
- // Use BT if the immediate can't be encoded in a TEST instruction.
- if (!isUInt<32>(AndRHSVal) && isPowerOf2_64(AndRHSVal)) {
- LHS = AndLHS;
- RHS = DAG.getConstant(Log2_64_Ceil(AndRHSVal), dl, LHS.getValueType());
+ } else {
+ // Use BT if the immediate can't be encoded in a TEST instruction or we
+ // are optimizing for size and the immedaite won't fit in a byte.
+ bool OptForSize = DAG.getMachineFunction().getFunction().optForSize();
+ if ((!isUInt<32>(AndRHSVal) || (OptForSize && !isUInt<8>(AndRHSVal))) &&
+ isPowerOf2_64(AndRHSVal)) {
+ LHS = AndLHS;
+ RHS = DAG.getConstant(Log2_64_Ceil(AndRHSVal), dl, LHS.getValueType());
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43346.134492.patch
Type: text/x-patch
Size: 2381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180215/cb3cc90c/attachment.bin>
More information about the llvm-commits
mailing list