Skip to content

Commit da1eb88

Browse files
authored
[X86] Do not check alignment for VINSERTPS (#65721)
We don't have alignment constraint in AVX instructions.
1 parent 01192a0 commit da1eb88

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

llvm/lib/Target/X86/X86InstrInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6104,7 +6104,8 @@ MachineInstr *X86InstrInfo::foldMemoryOperandCustom(
61046104
const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
61056105
const TargetRegisterClass *RC = getRegClass(MI.getDesc(), OpNum, &RI, MF);
61066106
unsigned RCSize = TRI.getRegSizeInBits(*RC) / 8;
6107-
if ((Size == 0 || Size >= 16) && RCSize >= 16 && Alignment >= Align(4)) {
6107+
if ((Size == 0 || Size >= 16) && RCSize >= 16 &&
6108+
(MI.getOpcode() != X86::INSERTPSrr || Alignment >= Align(4))) {
61086109
int PtrOffset = SrcIdx * 4;
61096110
unsigned NewImm = (DstIdx << 4) | ZMask;
61106111
unsigned NewOpCode =

llvm/test/CodeGen/X86/avx.ll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,12 @@ define <4 x float> @nofold_insertps(ptr %a, <4 x float> %b) {
184184
; X86-LABEL: nofold_insertps:
185185
; X86: ## %bb.0:
186186
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
187-
; X86-NEXT: vmovups (%eax), %xmm1
188-
; X86-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0,1,2],xmm1[2]
187+
; X86-NEXT: vinsertps $48, 8(%eax), %xmm0, %xmm0 ## xmm0 = xmm0[0,1,2],mem[0]
189188
; X86-NEXT: retl
190189
;
191190
; X64-LABEL: nofold_insertps:
192191
; X64: ## %bb.0:
193-
; X64-NEXT: vmovups (%rdi), %xmm1
194-
; X64-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0,1,2],xmm1[2]
192+
; X64-NEXT: vinsertps $48, 8(%rdi), %xmm0, %xmm0 ## xmm0 = xmm0[0,1,2],mem[0]
195193
; X64-NEXT: retq
196194
%1 = load <4 x float>, ptr %a, align 1
197195
%2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 0, i32 1, i32 2, i32 6>

0 commit comments

Comments
 (0)