Skip to content

Commit 9c4bae7

Browse files
committed
[X86][CodeGen] Disable NDD2NonNDD compression for CFCMOV
1 parent 7ee5112 commit 9c4bae7

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

llvm/lib/Target/X86/X86CompressEVEX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ static bool isRedundantNewDataDest(MachineInstr &MI, const X86Subtarget &ST) {
181181
const MCInstrDesc &Desc = MI.getDesc();
182182
Register Reg0 = MI.getOperand(0).getReg();
183183
const MachineOperand &Op1 = MI.getOperand(1);
184-
if (!Op1.isReg() || X86::getFirstAddrOperandIdx(MI) == 1)
184+
if (!Op1.isReg() || X86::getFirstAddrOperandIdx(MI) == 1 ||
185+
X86::isCFCMOVCC(MI.getOpcode()))
185186
return false;
186187
Register Reg1 = Op1.getReg();
187188
if (Reg1 == Reg0)

llvm/test/CodeGen/X86/apx/compress-evex.mir

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,22 @@ body: |
108108
$rax = ADC64rr_ND $r16, $rdi, implicit-def dead $eflags, implicit $eflags
109109
RET64 $rax
110110
...
111+
---
112+
name: cfcmov_no_convert
113+
body: |
114+
bb.0.entry:
115+
liveins: $eflags, $rax, $rbx
116+
; CHECK: cfcmovew %bx, %ax, %ax # encoding: [0x62,0xf4,0x7d,0x1c,0x44,0xc3]
117+
; CHECK: cfcmovsw 24(%rax), %bx, %bx # encoding: [0x62,0xf4,0x65,0x1c,0x48,0x58,0x18]
118+
; CHECK: cfcmovel %ebx, %eax, %eax # encoding: [0x62,0xf4,0x7c,0x1c,0x44,0xc3]
119+
; CHECK: cfcmovsl 24(%rax), %ebx, %ebx # encoding: [0x62,0xf4,0x64,0x1c,0x48,0x58,0x18]
120+
; CHECK: cfcmoveq %rbx, %rax, %rax # encoding: [0x62,0xf4,0xfc,0x1c,0x44,0xc3]
121+
; CHECK: cfcmovsq 24(%rax), %rbx, %rbx # encoding: [0x62,0xf4,0xe4,0x1c,0x48,0x58,0x18]
122+
$ax = CFCMOV16rr_ND $ax, $bx, 4, implicit $eflags
123+
$bx = CFCMOV16rm_ND $bx, $rax, 1, $noreg, 24, $noreg, 8, implicit $eflags
124+
$eax = CFCMOV32rr_ND $eax, $ebx, 4, implicit $eflags
125+
$ebx = CFCMOV32rm_ND $ebx, $rax, 1, $noreg, 24, $noreg, 8, implicit $eflags
126+
$rax = CFCMOV64rr_ND $rax, $rbx, 4, implicit $eflags
127+
$rbx = CFCMOV64rm_ND $rbx, $rax, 1, $noreg, 24, $noreg, 8, implicit $eflags
128+
RET64 $rax
129+
...

llvm/utils/TableGen/X86ManualCompressEVEXTables.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ NOCOMP(VPSRAQZ256ri)
4848
NOCOMP(VPSRAQZ256rm)
4949
NOCOMP(VPSRAQZ256rr)
5050
NOCOMP(VSCALEFPSZ256rm)
51+
// When condition evaluates to false, the destination register is zeroed for
52+
// nonNDD CFCMOV but not for NDD CFCMOV.
53+
NOCOMP(CFCMOV16rm_ND)
54+
NOCOMP(CFCMOV16rr_ND)
55+
NOCOMP(CFCMOV32rm_ND)
56+
NOCOMP(CFCMOV32rr_ND)
57+
NOCOMP(CFCMOV64rm_ND)
58+
NOCOMP(CFCMOV64rr_ND)
5159
#undef NOCOMP
5260

5361
#ifndef ENTRY

0 commit comments

Comments
 (0)