-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[X86][APX] Exclusively emit setzucc to avoid false dependency #142092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
30b8975
46c148b
85e4617
92f4fdd
608f957
17bd924
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,10 +79,11 @@ bool X86FixupSetCCPass::runOnMachineFunction(MachineFunction &MF) { | |
if (MI.definesRegister(X86::EFLAGS, /*TRI=*/nullptr)) | ||
FlagsDefMI = &MI; | ||
|
||
// Find a setcc that is used by a zext. | ||
// Find a setcc/setzucc (if ZU is enabled) that is used by a zext. | ||
// This doesn't have to be the only use, the transformation is safe | ||
// regardless. | ||
if (MI.getOpcode() != X86::SETCCr) | ||
if (MI.getOpcode() != X86::SETCCr && | ||
(!ST->hasZU() || MI.getOpcode() != X86::SETZUCCr)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
continue; | ||
|
||
MachineInstr *ZExt = nullptr; | ||
|
@@ -122,7 +123,8 @@ bool X86FixupSetCCPass::runOnMachineFunction(MachineFunction &MF) { | |
// register. | ||
Register ZeroReg = MRI->createVirtualRegister(RC); | ||
if (ST->hasZU()) { | ||
MI.setDesc(TII->get(X86::SETZUCCr)); | ||
if (MI.getOpcode() != X86::SETZUCCr) | ||
MI.setDesc(TII->get(X86::SETZUCCr)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we always generate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes. We do always emit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why NDD matters here. apx/setzucc.ll doesn't enable NDD either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to check ZU flag for SETZUCCr instruction in td and added assertion here to ensure MI is SETZUCCr instruction. |
||
BuildMI(*ZExt->getParent(), ZExt, ZExt->getDebugLoc(), | ||
TII->get(TargetOpcode::IMPLICIT_DEF), ZeroReg); | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,11 +137,14 @@ let Predicates = [HasCMOV, HasCF] in { | |
} | ||
|
||
// SetCC instructions. | ||
let Uses = [EFLAGS], isCodeGenOnly = 1, ForceDisassemble = 1 in { | ||
let Uses = [EFLAGS], isCodeGenOnly = 1, ForceDisassemble = 1, Predicates = [NoNDD] in { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes. See the definition in X86InstrPredicates.td as below:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean why not checking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. Thanks. |
||
def SETCCr : I<0x90, MRMXrCC, (outs GR8:$dst), (ins ccode:$cond), | ||
"set${cond}\t$dst", | ||
[(set GR8:$dst, (X86setcc timm:$cond, EFLAGS))]>, | ||
TB, Sched<[WriteSETCC]>; | ||
} | ||
|
||
let Uses = [EFLAGS], isCodeGenOnly = 1, ForceDisassemble = 1 in { | ||
def SETCCm : I<0x90, MRMXmCC, (outs), (ins i8mem:$dst, ccode:$cond), | ||
"set${cond}\t$dst", | ||
[(store (X86setcc timm:$cond, EFLAGS), addr:$dst)]>, | ||
|
@@ -152,7 +155,8 @@ let Uses = [EFLAGS], isCodeGenOnly = 1, ForceDisassemble = 1 in { | |
let Uses = [EFLAGS], isCodeGenOnly = 1, ForceDisassemble = 1, | ||
hasSideEffects = 0, Predicates = [In64BitMode], Predicates = [HasNDD] in { | ||
def SETZUCCr : I<0x40, MRMXrCC, (outs GR8:$dst), (ins ccode:$cond), | ||
"setzu${cond}\t$dst", []>, | ||
"setzu${cond}\t$dst", | ||
[(set GR8:$dst, (X86setcc timm:$cond, EFLAGS))]>, | ||
XD, ZU, NoCD8, Sched<[WriteSETCC]>; | ||
def SETCCr_EVEX : I<0x40, MRMXrCC, (outs GR8:$dst), (ins ccode:$cond), | ||
"set${cond}\t$dst", []>, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define GET_SETCC (Subtarget->hasZU() ? X86::SETZUCCr : X86::SETCCr)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.