Skip to content

Commit 8eccf2b

Browse files
committed
[X86] Set Uses = [EFLAGS] for ADCX/ADOX
According to Intel SDE, ADCX reads CF and ADOX reads OF. `Uses` was set to empty by accident, the bug was not exposed b/c compiler never emits these instructions.
1 parent 70b00b4 commit 8eccf2b

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

llvm/lib/Target/X86/X86InstrArithmetic.td

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class BinOpRM_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node>
102102
(t.LoadNode addr:$src2)))]>, DefEFLAGS;
103103
// BinOpRMF_RF - Instructions that read "reg, [mem]", write "reg" and read/write
104104
// EFLAGS.
105-
class BinOpRMF_RF<bits<8> o, string m, X86TypeInfo t, SDNode node>
105+
class BinOpRMF_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node>
106106
: BinOpRM<o, m, t, (outs t.RegClass:$dst),
107107
[(set t.RegClass:$dst, EFLAGS,
108108
(node t.RegClass:$src1, (t.LoadNode addr:$src2), EFLAGS))]>,
@@ -1189,34 +1189,24 @@ let Uses = [RDX] in
11891189
// We don't have patterns for these as there is no advantage over ADC for
11901190
// most code.
11911191
class ADCOXOpRR <string m, X86TypeInfo t>
1192-
: BinOpRR_RF<0xF6, m, t, null_frag> {
1193-
let OpSize = OpSizeFixed;
1192+
: BinOpRRF_RF<0xF6, m, t, null_frag> {
11941193
let Form = MRMSrcReg;
11951194
let isCommutable = 1;
11961195
}
11971196

11981197
class ADCOXOpRM <string m, X86TypeInfo t>
1199-
: BinOpRM_RF<0xF6, m, t, null_frag> {
1200-
let OpSize = OpSizeFixed;
1198+
: BinOpRMF_RF<0xF6, m, t, null_frag> {
12011199
let Form = MRMSrcMem;
12021200
}
12031201

1204-
let Predicates = [HasADX], Constraints = "$src1 = $dst" in {
1205-
let SchedRW = [WriteADC] in {
1206-
def ADCX32rr : ADCOXOpRR<"adcx", Xi32>, T8PD;
1207-
def ADCX64rr : ADCOXOpRR<"adcx", Xi64>, T8PD;
1208-
def ADOX32rr : ADCOXOpRR<"adox", Xi32>, T8XS;
1209-
def ADOX64rr : ADCOXOpRR<"adox", Xi64>, T8XS;
1210-
}
1211-
1212-
let SchedRW = [WriteADC.Folded, WriteADC.ReadAfterFold,
1213-
// Memory operand.
1214-
ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault,
1215-
// Implicit read of EFLAGS
1216-
WriteADC.ReadAfterFold] in {
1217-
def ADCX32rm : ADCOXOpRM<"adcx", Xi32>, T8PD;
1218-
def ADCX64rm : ADCOXOpRM<"adcx", Xi64>, T8PD;
1219-
def ADOX32rm : ADCOXOpRM<"adox", Xi32>, T8XS;
1220-
def ADOX64rm : ADCOXOpRM<"adox", Xi64>, T8XS;
1221-
}
1202+
let OpSize = OpSizeFixed, Constraints = "$src1 = $dst",
1203+
Predicates = [HasADX] in {
1204+
def ADCX32rr : ADCOXOpRR<"adcx", Xi32>, T8PD;
1205+
def ADCX64rr : ADCOXOpRR<"adcx", Xi64>, T8PD;
1206+
def ADOX32rr : ADCOXOpRR<"adox", Xi32>, T8XS;
1207+
def ADOX64rr : ADCOXOpRR<"adox", Xi64>, T8XS;
1208+
def ADCX32rm : ADCOXOpRM<"adcx", Xi32>, T8PD;
1209+
def ADCX64rm : ADCOXOpRM<"adcx", Xi64>, T8PD;
1210+
def ADOX32rm : ADCOXOpRM<"adox", Xi32>, T8XS;
1211+
def ADOX64rm : ADCOXOpRM<"adox", Xi64>, T8XS;
12221212
}

0 commit comments

Comments
 (0)