Skip to content

Commit 1c35535

Browse files
committed
[X86] Add In64BitMode predicates for LOCK_INC64m, LOCK_DEC64m
These two instructions are only encodable in 64bit mode. Reviewed By: pengfei Differential Revision: https://reviews.llvm.org/D137608
1 parent ebac599 commit 1c35535

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

llvm/lib/Target/X86/X86InstrCompiler.td

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -801,9 +801,9 @@ def X86lock_sub_nocf : PatFrag<(ops node:$lhs, node:$rhs),
801801
return hasNoCarryFlagUses(SDValue(N, 0));
802802
}]>;
803803

804-
let Predicates = [UseIncDec] in {
805-
let Defs = [EFLAGS], mayLoad = 1, mayStore = 1, isCodeGenOnly = 1,
806-
SchedRW = [WriteALURMW] in {
804+
let Defs = [EFLAGS], mayLoad = 1, mayStore = 1, isCodeGenOnly = 1,
805+
SchedRW = [WriteALURMW] in {
806+
let Predicates = [UseIncDec] in {
807807
def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
808808
"inc{b}\t$dst",
809809
[(set EFLAGS, (X86lock_add_nocf addr:$dst, (i8 1)))]>,
@@ -816,10 +816,6 @@ let Predicates = [UseIncDec] in {
816816
"inc{l}\t$dst",
817817
[(set EFLAGS, (X86lock_add_nocf addr:$dst, (i32 1)))]>,
818818
OpSize32, LOCK;
819-
def LOCK_INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst),
820-
"inc{q}\t$dst",
821-
[(set EFLAGS, (X86lock_add_nocf addr:$dst, (i64 1)))]>,
822-
LOCK;
823819

824820
def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
825821
"dec{b}\t$dst",
@@ -833,20 +829,33 @@ let Predicates = [UseIncDec] in {
833829
"dec{l}\t$dst",
834830
[(set EFLAGS, (X86lock_sub_nocf addr:$dst, (i32 1)))]>,
835831
OpSize32, LOCK;
832+
}
833+
834+
let Predicates = [UseIncDec, In64BitMode] in {
835+
def LOCK_INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst),
836+
"inc{q}\t$dst",
837+
[(set EFLAGS, (X86lock_add_nocf addr:$dst, (i64 1)))]>,
838+
LOCK;
836839
def LOCK_DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst),
837840
"dec{q}\t$dst",
838841
[(set EFLAGS, (X86lock_sub_nocf addr:$dst, (i64 1)))]>,
839842
LOCK;
840843
}
844+
}
841845

846+
let Predicates = [UseIncDec] in {
842847
// Additional patterns for -1 constant.
843848
def : Pat<(X86lock_add addr:$dst, (i8 -1)), (LOCK_DEC8m addr:$dst)>;
844849
def : Pat<(X86lock_add addr:$dst, (i16 -1)), (LOCK_DEC16m addr:$dst)>;
845850
def : Pat<(X86lock_add addr:$dst, (i32 -1)), (LOCK_DEC32m addr:$dst)>;
846-
def : Pat<(X86lock_add addr:$dst, (i64 -1)), (LOCK_DEC64m addr:$dst)>;
847851
def : Pat<(X86lock_sub addr:$dst, (i8 -1)), (LOCK_INC8m addr:$dst)>;
848852
def : Pat<(X86lock_sub addr:$dst, (i16 -1)), (LOCK_INC16m addr:$dst)>;
849853
def : Pat<(X86lock_sub addr:$dst, (i32 -1)), (LOCK_INC32m addr:$dst)>;
854+
}
855+
856+
let Predicates = [UseIncDec, In64BitMode] in {
857+
// Additional patterns for -1 constant.
858+
def : Pat<(X86lock_add addr:$dst, (i64 -1)), (LOCK_DEC64m addr:$dst)>;
850859
def : Pat<(X86lock_sub addr:$dst, (i64 -1)), (LOCK_INC64m addr:$dst)>;
851860
}
852861

0 commit comments

Comments
 (0)