Skip to content

Commit a492246

Browse files
committed
[X86][SSE] Don't emit SSE2 load instructions in SSE1-only mode
1 parent 449e2f5 commit a492246

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

llvm/lib/Target/X86/X86FixupVectorConstants.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ bool X86FixupVectorConstantsPass::processInstruction(MachineFunction &MF,
333333
MachineInstr &MI) {
334334
unsigned Opc = MI.getOpcode();
335335
MachineConstantPool *CP = MI.getParent()->getParent()->getConstantPool();
336+
bool HasSSE2 = ST->hasSSE2();
336337
bool HasSSE41 = ST->hasSSE41();
337338
bool HasAVX2 = ST->hasAVX2();
338339
bool HasDQI = ST->hasDQI();
@@ -394,11 +395,13 @@ bool X86FixupVectorConstantsPass::processInstruction(MachineFunction &MF,
394395
case X86::MOVAPDrm:
395396
case X86::MOVAPSrm:
396397
case X86::MOVUPDrm:
397-
case X86::MOVUPSrm:
398+
case X86::MOVUPSrm: {
398399
// TODO: SSE3 MOVDDUP Handling
399-
return FixupConstant({{X86::MOVSSrm, 1, 32, rebuildZeroUpperCst},
400-
{X86::MOVSDrm, 1, 64, rebuildZeroUpperCst}},
401-
128, 1);
400+
FixupEntry Fixups[] = {
401+
{X86::MOVSSrm, 1, 32, rebuildZeroUpperCst},
402+
{HasSSE2 ? X86::MOVSDrm : 0, 1, 64, rebuildZeroUpperCst}};
403+
return FixupConstant(Fixups, 128, 1);
404+
}
402405
case X86::VMOVAPDrm:
403406
case X86::VMOVAPSrm:
404407
case X86::VMOVUPDrm:

llvm/test/CodeGen/X86/pr134607.ll

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=+sse -O3 | FileCheck %s --check-prefixes=X86
2+
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=-sse2,+sse -O3 | FileCheck %s --check-prefixes=X64
3+
4+
define void @store_v2f32_constant(ptr %v) {
5+
; X86-LABEL: store_v2f32_constant:
6+
; X86: # %bb.0:
7+
; X86-NEXT: movl 4(%esp), %eax
8+
; X86-NEXT: movaps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
9+
10+
; X64-LABEL: store_v2f32_constant:
11+
; X64: # %bb.0:
12+
; X64-NEXT: movaps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
13+
store <2 x float> <float 2.560000e+02, float 5.120000e+02>, ptr %v, align 4
14+
ret void
15+
}

0 commit comments

Comments
 (0)