Skip to content

Commit ff7d792

Browse files
committed
release/18x:[X86] Fix typo: QWORD alignment is greater than or equal to 8, not greater than 8 (llvm#87819)
Align(8) is QWORD aligned, but this was checking to see if alignment was greater than that, when it should have been checking for being greater than OR EQUAL to Align(8). This bug was introduced in llvm@6a6af30d433d7 during the transition to the Align type. (cherry picked from commit 8389b3b)
1 parent b6ebea7 commit ff7d792

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

llvm/lib/Target/X86/X86SelectionDAGInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ SDValue X86SelectionDAGInfo::EmitTargetCodeForMemset(
8080
uint64_t Val = ValC->getZExtValue() & 255;
8181

8282
// If the value is a constant, then we can potentially use larger sets.
83-
if (Alignment > Align(2)) {
83+
if (Alignment >= Align(4)) {
8484
// DWORD aligned
8585
AVT = MVT::i32;
8686
ValReg = X86::EAX;
8787
Val = (Val << 8) | Val;
8888
Val = (Val << 16) | Val;
89-
if (Subtarget.is64Bit() && Alignment > Align(8)) { // QWORD aligned
89+
if (Subtarget.is64Bit() && Alignment >= Align(8)) { // QWORD aligned
9090
AVT = MVT::i64;
9191
ValReg = X86::RAX;
9292
Val = (Val << 32) | Val;

llvm/test/CodeGen/X86/memset-minsize.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,17 @@ entry:
136136
ret void
137137
}
138138

139+
define void @small_memset_to_rep_stos_64(ptr %ptr) minsize nounwind {
140+
; CHECK-LABEL: small_memset_to_rep_stos_64:
141+
; CHECK: # %bb.0: # %entry
142+
; CHECK-NEXT: pushq $16
143+
; CHECK-NEXT: popq %rcx
144+
; CHECK-NEXT: xorl %eax, %eax
145+
; CHECK-NEXT: rep;stosq %rax, %es:(%rdi)
146+
; CHECK-NEXT: retq
147+
entry:
148+
call void @llvm.memset.p0.i64(ptr align 8 %ptr, i8 0, i64 128, i1 false)
149+
ret void
150+
}
151+
139152
declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1)

0 commit comments

Comments
 (0)