Skip to content

Commit

Permalink
[X86][CodeGen] Fix crash when commute operands of Instruction for cod…
Browse files Browse the repository at this point in the history
…e size

Reported in 134fcc6
  • Loading branch information
KanRobert committed Jan 24, 2024
1 parent 7e50f00 commit ad9e2f8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions llvm/lib/Target/X86/X86InstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2355,29 +2355,30 @@ MachineInstr *X86InstrInfo::commuteInstructionImpl(MachineInstr &MI, bool NewMI,
// If we're optimizing for size, try to use MOVSD/MOVSS.
if (MI.getParent()->getParent()->getFunction().hasOptSize()) {
unsigned Mask;
unsigned NewOpc;
switch (Opc) {
default:
llvm_unreachable("Unreachable!");
case X86::BLENDPDrri:
Opc = X86::MOVSDrr;
NewOpc = X86::MOVSDrr;
Mask = 0x03;
break;
case X86::BLENDPSrri:
Opc = X86::MOVSSrr;
NewOpc = X86::MOVSSrr;
Mask = 0x0F;
break;
case X86::VBLENDPDrri:
Opc = X86::VMOVSDrr;
NewOpc = X86::VMOVSDrr;
Mask = 0x03;
break;
case X86::VBLENDPSrri:
Opc = X86::VMOVSSrr;
NewOpc = X86::VMOVSSrr;
Mask = 0x0F;
break;
}
if ((MI.getOperand(3).getImm() ^ Mask) == 1) {
WorkingMI = CloneIfNew(MI);
WorkingMI->setDesc(get(Opc));
WorkingMI->setDesc(get(NewOpc));
WorkingMI->removeOperand(3);
break;
}
Expand Down

0 comments on commit ad9e2f8

Please sign in to comment.