[llvm] 8c0e715 - [X86] BEXTR SimplifyDemandedBitsForTargetNode - length == 0 -> result = 0
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 08:51:10 PST 2020
Author: Simon Pilgrim
Date: 2020-02-03T16:50:03Z
New Revision: 8c0e715eb281fa8c3b1605191294671eb6a898b5
URL: https://github.com/llvm/llvm-project/commit/8c0e715eb281fa8c3b1605191294671eb6a898b5
DIFF: https://github.com/llvm/llvm-project/commit/8c0e715eb281fa8c3b1605191294671eb6a898b5.diff
LOG: [X86] BEXTR SimplifyDemandedBitsForTargetNode - length == 0 -> result = 0
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/combine-bextr.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index ebb854511c86..2a3ad344973e 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -36290,6 +36290,11 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode(
if (SimplifyDemandedBits(Op1, DemandedMask, Known1, TLO, Depth + 1))
return true;
+ // If the length is 0, replace with 0.
+ KnownBits LengthBits = Known1.extractBits(8, 8);
+ if (LengthBits.isZero())
+ return TLO.CombineTo(Op, TLO.DAG.getConstant(0, SDLoc(Op), VT));
+
break;
}
}
diff --git a/llvm/test/CodeGen/X86/combine-bextr.ll b/llvm/test/CodeGen/X86/combine-bextr.ll
index d4763b3f076c..852e96ebebdd 100644
--- a/llvm/test/CodeGen/X86/combine-bextr.ll
+++ b/llvm/test/CodeGen/X86/combine-bextr.ll
@@ -13,8 +13,7 @@ define i32 @bextr_zero_length(i32 %x, i32 %y) {
;
; X64-LABEL: bextr_zero_length:
; X64: # %bb.0:
-; X64-NEXT: movzbl %sil, %eax
-; X64-NEXT: bextrl %eax, %edi, %eax
+; X64-NEXT: xorl %eax, %eax
; X64-NEXT: retq
%1 = and i32 %y, 255
%2 = tail call i32 @llvm.x86.bmi.bextr.32(i32 %x, i32 %1)
More information about the llvm-commits
mailing list