Skip to content

Commit 561fcc0

Browse files
committed
[X86-64] Fix 256-bit SET0 lowering for non-VLX targets
If we don't have VLX then 256-bit SET0 should be lowered to VPXOR with ZMM registers. This restores functionality accidentally removed by r309926. Differential Revision: https://reviews.llvm.org/D62415 llvm-svn: 361843
1 parent ebe22a1 commit 561fcc0

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

llvm/lib/Target/X86/X86InstrInfo.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3932,6 +3932,12 @@ bool X86InstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
39323932
MIB.addReg(SrcReg, RegState::ImplicitDefine);
39333933
return true;
39343934
}
3935+
if (MI.getOpcode() == X86::AVX512_256_SET0) {
3936+
// No VLX so we must reference a zmm.
3937+
unsigned ZReg =
3938+
TRI->getMatchingSuperReg(SrcReg, X86::sub_ymm, &X86::VR512RegClass);
3939+
MIB->getOperand(0).setReg(ZReg);
3940+
}
39353941
return Expand2AddrUndef(MIB, get(X86::VPXORDZrr));
39363942
}
39373943
case X86::V_SETALLONES:
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Test that we emit VPXORD with ZMM registers instead of YMM
2+
# registers when we do not have VLX.
3+
#
4+
# RUN: llc -mtriple=x86_64-- -mattr=+avx512f -o - %s | FileCheck %s
5+
# CHECK: vpxord %zmm16, %zmm16, %zmm16
6+
--- |
7+
; ModuleID = 'test.ll'
8+
source_filename = "test.ll"
9+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
10+
target triple = "x86_64-unknown-linux-gnu"
11+
12+
@tst_ = common global [4 x i64] zeroinitializer, align 64
13+
14+
define void @main() #0 {
15+
bb0:
16+
%gep1 = bitcast [4 x i64]* @tst_ to [4 x i64]*
17+
%lsr.iv1 = bitcast [4 x i64]* %gep1 to <4 x i64>*
18+
store <4 x i64> zeroinitializer, <4 x i64>* %lsr.iv1, align 16
19+
ret void
20+
}
21+
22+
attributes #0 = { "target-features"="+avx512f" }
23+
24+
...
25+
---
26+
name: main
27+
alignment: 4
28+
exposesReturnsTwice: false
29+
legalized: false
30+
regBankSelected: false
31+
selected: false
32+
failedISel: false
33+
tracksRegLiveness: true
34+
hasWinCFI: false
35+
registers: []
36+
liveins: []
37+
frameInfo:
38+
isFrameAddressTaken: false
39+
isReturnAddressTaken: false
40+
hasStackMap: false
41+
hasPatchPoint: false
42+
stackSize: 0
43+
offsetAdjustment: 0
44+
maxAlignment: 0
45+
adjustsStack: false
46+
hasCalls: false
47+
stackProtector: ''
48+
maxCallFrameSize: 0
49+
cvBytesOfCalleeSavedRegisters: 0
50+
hasOpaqueSPAdjustment: false
51+
hasVAStart: false
52+
hasMustTailInVarArgFunc: false
53+
localFrameSize: 0
54+
savePoint: ''
55+
restorePoint: ''
56+
fixedStack: []
57+
stack: []
58+
constants: []
59+
machineFunctionInfo: {}
60+
body: |
61+
bb.0.bb0:
62+
renamable $ymm16 = AVX512_256_SET0
63+
VMOVAPSZmr $rip, 1, $noreg, @tst_, $noreg, killed renamable $zmm16 :: (store 32 into %ir.lsr.iv1, align 64)
64+
RET 0
65+
66+
...

0 commit comments

Comments
 (0)