Skip to content

Commit 7e96421

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

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

llvm/lib/Target/X86/X86FixupVectorConstants.cpp

Lines changed: 5 additions & 3 deletions
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();
@@ -396,9 +397,10 @@ bool X86FixupVectorConstantsPass::processInstruction(MachineFunction &MF,
396397
case X86::MOVUPDrm:
397398
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+
return FixupConstant(
401+
{{X86::MOVSSrm, 1, 32, rebuildZeroUpperCst},
402+
{HasSSE2 ? X86::MOVSDrm : 0, 1, 64, rebuildZeroUpperCst}},
403+
128, 1);
402404
case X86::VMOVAPDrm:
403405
case X86::VMOVAPSrm:
404406
case X86::VMOVUPDrm:

llvm/test/CodeGen/X86/sse1.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,5 +251,18 @@ define <2 x float> @PR31672() #0 {
251251

252252
declare <2 x float> @llvm.sqrt.v2f32(<2 x float>) #1
253253

254+
define void @movaps_test(ptr nocapture noundef writeonly %v) {
255+
; X86-LABEL: movaps_test:
256+
; X86: # %bb.0:
257+
; X86-NEXT: movl 4(%esp), %eax
258+
; X86-NEXT: movaps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
259+
260+
; X64-LABEL: movaps_test:
261+
; X64: # %bb.0:
262+
; X64-NEXT: movaps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
263+
store <2 x float> <float 2.560000e+02, float 5.120000e+02>, ptr %v, align 4
264+
ret void
265+
}
266+
254267
attributes #0 = { nounwind "unsafe-fp-math"="true" }
255268

0 commit comments

Comments
 (0)