[llvm] 6c1b5ec - [X86][NFC] Simplify the patterns of BMI shift/rotate instructions in X86InstrCompiler.td
Shengchen Kan via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 16 07:59:17 PST 2024
Author: Shengchen Kan
Date: 2024-01-16T23:59:08+08:00
New Revision: 6c1b5ec213ee7376bed9357211e5582931318974
URL: https://github.com/llvm/llvm-project/commit/6c1b5ec213ee7376bed9357211e5582931318974
DIFF: https://github.com/llvm/llvm-project/commit/6c1b5ec213ee7376bed9357211e5582931318974.diff
LOG: [X86][NFC] Simplify the patterns of BMI shift/rotate instructions in X86InstrCompiler.td
This patch is to extract NFC in #77433 into a separate commit.
Added:
Modified:
llvm/lib/Target/X86/X86InstrCompiler.td
llvm/lib/Target/X86/X86InstrShiftRotate.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86InstrCompiler.td b/llvm/lib/Target/X86/X86InstrCompiler.td
index 422391a6e02ae0..7e5ce7c32f87c5 100644
--- a/llvm/lib/Target/X86/X86InstrCompiler.td
+++ b/llvm/lib/Target/X86/X86InstrCompiler.td
@@ -1864,64 +1864,6 @@ def : Pat<(fshl GR64:$src1, GR64:$src2, (shiftMask64 CL)),
def : Pat<(fshr GR64:$src2, GR64:$src1, (shiftMask64 CL)),
(SHRD64rrCL GR64:$src1, GR64:$src2)>;
-let Predicates = [HasBMI2] in {
- let AddedComplexity = 1 in {
- def : Pat<(sra GR32:$src1, (shiftMask32 GR8:$src2)),
- (SARX32rr GR32:$src1,
- (INSERT_SUBREG
- (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
- def : Pat<(sra GR64:$src1, (shiftMask64 GR8:$src2)),
- (SARX64rr GR64:$src1,
- (INSERT_SUBREG
- (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
-
- def : Pat<(srl GR32:$src1, (shiftMask32 GR8:$src2)),
- (SHRX32rr GR32:$src1,
- (INSERT_SUBREG
- (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
- def : Pat<(srl GR64:$src1, (shiftMask64 GR8:$src2)),
- (SHRX64rr GR64:$src1,
- (INSERT_SUBREG
- (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
-
- def : Pat<(shl GR32:$src1, (shiftMask32 GR8:$src2)),
- (SHLX32rr GR32:$src1,
- (INSERT_SUBREG
- (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
- def : Pat<(shl GR64:$src1, (shiftMask64 GR8:$src2)),
- (SHLX64rr GR64:$src1,
- (INSERT_SUBREG
- (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
- }
-
- def : Pat<(sra (loadi32 addr:$src1), (shiftMask32 GR8:$src2)),
- (SARX32rm addr:$src1,
- (INSERT_SUBREG
- (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
- def : Pat<(sra (loadi64 addr:$src1), (shiftMask64 GR8:$src2)),
- (SARX64rm addr:$src1,
- (INSERT_SUBREG
- (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
-
- def : Pat<(srl (loadi32 addr:$src1), (shiftMask32 GR8:$src2)),
- (SHRX32rm addr:$src1,
- (INSERT_SUBREG
- (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
- def : Pat<(srl (loadi64 addr:$src1), (shiftMask64 GR8:$src2)),
- (SHRX64rm addr:$src1,
- (INSERT_SUBREG
- (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
-
- def : Pat<(shl (loadi32 addr:$src1), (shiftMask32 GR8:$src2)),
- (SHLX32rm addr:$src1,
- (INSERT_SUBREG
- (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
- def : Pat<(shl (loadi64 addr:$src1), (shiftMask64 GR8:$src2)),
- (SHLX64rm addr:$src1,
- (INSERT_SUBREG
- (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
-}
-
// Use BTR/BTS/BTC for clearing/setting/toggling a bit in a variable location.
multiclass one_bit_patterns<RegisterClass RC, ValueType VT, Instruction BTR,
Instruction BTS, Instruction BTC,
diff --git a/llvm/lib/Target/X86/X86InstrShiftRotate.td b/llvm/lib/Target/X86/X86InstrShiftRotate.td
index dbfd66ae489dda..c76e8cc4d12988 100644
--- a/llvm/lib/Target/X86/X86InstrShiftRotate.td
+++ b/llvm/lib/Target/X86/X86InstrShiftRotate.td
@@ -330,6 +330,12 @@ multiclass ShiftX_Pats<SDNode op> {
def : Pat<(op GR64:$src1, GR8:$src2),
(!cast<Instruction>(NAME#"64rr") GR64:$src1,
(INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
+ def : Pat<(op GR32:$src1, (shiftMask32 GR8:$src2)),
+ (!cast<Instruction>(NAME#"32rr") GR32:$src1,
+ (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
+ def : Pat<(op GR64:$src1, (shiftMask64 GR8:$src2)),
+ (!cast<Instruction>(NAME#"64rr") GR64:$src1,
+ (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
}
// We prefer to use
// mov (%ecx), %esi
@@ -347,6 +353,12 @@ multiclass ShiftX_Pats<SDNode op> {
def : Pat<(op (loadi64 addr:$src1), GR8:$src2),
(!cast<Instruction>(NAME#"64rm") addr:$src1,
(INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
+ def : Pat<(op (loadi32 addr:$src1), (shiftMask32 GR8:$src2)),
+ (!cast<Instruction>(NAME#"32rm") addr:$src1,
+ (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
+ def : Pat<(op (loadi64 addr:$src1), (shiftMask64 GR8:$src2)),
+ (!cast<Instruction>(NAME#"64rm") addr:$src1,
+ (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR8:$src2, sub_8bit))>;
}
let Predicates = [HasBMI2] in {
More information about the llvm-commits
mailing list