[llvm] r309535 - [X86] Add pattern to use bzhi for 64-bit 'and' with a mask when there is a load involved.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 30 22:55:54 PDT 2017
Author: ctopper
Date: Sun Jul 30 22:55:54 2017
New Revision: 309535
URL: http://llvm.org/viewvc/llvm-project?rev=309535&view=rev
Log:
[X86] Add pattern to use bzhi for 64-bit 'and' with a mask when there is a load involved.
We already had a pattern without load, but with a load we were falling back to a regular 'and' due to pattern complexity priority.
Modified:
llvm/trunk/lib/Target/X86/X86InstrInfo.td
llvm/trunk/test/CodeGen/X86/bmi.ll
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=309535&r1=309534&r2=309535&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Sun Jul 30 22:55:54 2017
@@ -2361,6 +2361,10 @@ let Predicates = [HasBMI2] in {
(BZHI64rr GR64:$src,
(INSERT_SUBREG (i64 (IMPLICIT_DEF)),
(MOV8ri (CountTrailingOnes imm:$mask)), sub_8bit))>;
+ def : Pat<(and (loadi64 addr:$src), BZHIMask:$mask),
+ (BZHI64rm addr:$src,
+ (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
+ (MOV8ri (CountTrailingOnes imm:$mask)), sub_8bit))>;
def : Pat<(and GR32:$src, (add (shl 1, GR8:$lz), -1)),
(BZHI32rr GR32:$src,
Modified: llvm/trunk/test/CodeGen/X86/bmi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/bmi.ll?rev=309535&r1=309534&r2=309535&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/bmi.ll (original)
+++ llvm/trunk/test/CodeGen/X86/bmi.ll Sun Jul 30 22:55:54 2017
@@ -555,6 +555,18 @@ entry:
ret i64 %and
}
+define i64 @bzhi64_constant_mask_load(i64* %x) {
+; CHECK-LABEL: bzhi64_constant_mask_load:
+; CHECK: # BB#0: # %entry
+; CHECK-NEXT: movb $62, %al
+; CHECK-NEXT: bzhiq %rax, (%rdi), %rax
+; CHECK-NEXT: retq
+entry:
+ %x1 = load i64, i64* %x
+ %and = and i64 %x1, 4611686018427387903
+ ret i64 %and
+}
+
define i64 @bzhi64_small_constant_mask(i64 %x) {
; CHECK-LABEL: bzhi64_small_constant_mask:
; CHECK: # BB#0: # %entry
More information about the llvm-commits
mailing list