summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2016-09-07 04:46:11 +0000
committerCraig Topper <craig.topper@gmail.com>2016-09-07 04:46:11 +0000
commitb880ad3a71f288a0f5aef4ecac22faa4cd5e8389 (patch)
treeb75be99c11a113e708de91e2b856cbdf0b7a0655 /llvm/lib/Target
parent94b812ac77bc3d2c94efb295bada00f3bcbf709f (diff)
downloadbcm5719-llvm-b880ad3a71f288a0f5aef4ecac22faa4cd5e8389.tar.gz
bcm5719-llvm-b880ad3a71f288a0f5aef4ecac22faa4cd5e8389.zip
[AVX-512] Add support for commuting masked instructions in findCommutedOpIndices. The default implementation doesn't skip the mask input or the preserved input.
llvm-svn: 280781
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/X86/X86InstrInfo.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp
index bb592e95a5b..5e1a7528a16 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -3709,7 +3709,8 @@ bool X86InstrInfo::findFMA3CommutedOpIndices(
bool X86InstrInfo::findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1,
unsigned &SrcOpIdx2) const {
- if (!MI.isCommutable())
+ const MCInstrDesc &Desc = MI.getDesc();
+ if (!Desc.isCommutable())
return false;
switch (MI.getOpcode()) {
@@ -3750,6 +3751,27 @@ bool X86InstrInfo::findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1,
X86InstrFMA3Info::getFMA3Group(MI.getOpcode());
if (FMA3Group)
return findFMA3CommutedOpIndices(MI, SrcOpIdx1, SrcOpIdx2, *FMA3Group);
+
+ // Handled masked instructions since we need to skip over the mask input
+ // and the preserved input.
+ if (Desc.TSFlags & X86II::EVEX_K) {
+ unsigned CommutableOpIdx1 = Desc.getNumDefs() + 1;
+ // If there is no preserved input we only need to skip 1 operand.
+ if (MI.getDesc().getOperandConstraint(Desc.getNumDefs(),
+ MCOI::TIED_TO) != -1)
+ ++CommutableOpIdx1;
+ unsigned CommutableOpIdx2 = CommutableOpIdx1 + 1;
+ if (!fixCommutedOpIndices(SrcOpIdx1, SrcOpIdx2,
+ CommutableOpIdx1, CommutableOpIdx2))
+ return false;
+
+ if (!MI.getOperand(SrcOpIdx1).isReg() ||
+ !MI.getOperand(SrcOpIdx2).isReg())
+ // No idea.
+ return false;
+ return true;
+ }
+
return TargetInstrInfo::findCommutedOpIndices(MI, SrcOpIdx1, SrcOpIdx2);
}
return false;
OpenPOWER on IntegriCloud