Skip to content

SLP Vectorizer too aggressive with simple stores #30464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MatzeB opened this issue Nov 22, 2016 · 1 comment
Closed

SLP Vectorizer too aggressive with simple stores #30464

MatzeB opened this issue Nov 22, 2016 · 1 comment
Labels
bugzilla Issues migrated from bugzilla llvm:SLPVectorizer

Comments

@MatzeB
Copy link
Contributor

MatzeB commented Nov 22, 2016

Bugzilla Link 31116
Version trunk
OS All
CC @hfinkel,@RKSimon

Extended Description

In a situation like the following (modeled after what happens in a C++ constructor with two base classes), the SLP vectorizer seems too aggressive:

struct C {
  char *BaseA;
  char *BaseB;
};
extern char VTab[];
void initC(C *c) {
  c->BaseA = VTab + 48;
  c->BaseB = VTab + 16;
}

The SLP Vectorizer transforms:

  %BaseA = getelementptr inbounds %struct.C, %struct.C* %c, i64 0, i32 0
  store i8* getelementptr inbounds ([0 x i8], [0 x i8]* @VTab, i64 0, i64 48), i8** %BaseA, align 8, !tbaa !2
  %BaseB = getelementptr inbounds %struct.C, %struct.C* %c, i64 0, i32 1
  store i8* getelementptr inbounds ([0 x i8], [0 x i8]* @VTab, i64 0, i64 16), i8** %BaseB, align 8, !tbaa !7

into:

  %BaseA = getelementptr inbounds %struct.C, %struct.C* %c, i64 0, i32 0
  %BaseB = getelementptr inbounds %struct.C, %struct.C* %c, i64 0, i32 1
  %0 = bitcast i8** %BaseA to <2 x i8*>*
  store <2 x i8*> <i8* getelementptr inbounds ([0 x i8], [0 x i8]* @VTab, i64 0, i64 48), i8* getelementptr inbounds ([0 x i8], [0 x i8]* @VTab, i64 0, i64 16)>, <2 x i8*>* %0, align 8, !tbaa !2
  ret void

which results in this code on X86:

 	movq	_VTab@GOTPCREL(%rip), %rax
   leaq	16(%rax), %rcx
   movd	%rcx, %xmm0
   addq	$48, %rax
   movd	%rax, %xmm1
   punpcklqdq	%xmm0, %xmm1    ## xmm1 = xmm1[0],xmm0[0]
   movdqu	%xmm1, (%rdi)

while it can be this if the SLP Vectorizer doesn't do anything:

	movq	_VTab@GOTPCREL(%rip), %rax
	leaq	48(%rax), %rcx
	movq	%rcx, (%rdi)
	addq	$16, %rax
	movq	%rax, 8(%rdi)
@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@alexey-bataev
Copy link
Member

Cannot be reproduced in trunk, fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:SLPVectorizer
Projects
None yet
Development

No branches or pull requests

3 participants