Skip to content
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

Loop vectorizer bloats code in some cases #103

Open
jbush001 opened this issue Nov 26, 2018 · 2 comments
Open

Loop vectorizer bloats code in some cases #103

jbush001 opened this issue Nov 26, 2018 · 2 comments

Comments

@jbush001
Copy link
Owner

The following code:

void* memset(void *dst, int c, unsigned int n)
{
    int i;
    for (i = 0; i < n; i++)
        ((char*) dst)[i] = c;

    return dst;
}

With the "Loop Vectorization" pass enabled will generate a very large unrolled loop with 1024 instructions.

	and s3, s2, 1023
	sub_i s3, s2, s3
	move s4, 0
	b .LBB0_3
.LBB0_3:                                # %vector.body
                                        # =>This Inner Loop Header: Depth=1
	add_i s5, s0, s4
	store_8 s1, 1(s5)
	store_8 s1, (s5)
	store_8 s1, 2(s5)
	store_8 s1, 3(s5)
	store_8 s1, 4(s5)
	store_8 s1, 5(s5)
	store_8 s1, 6(s5)
	store_8 s1, 7(s5)
...
	store_8 s1, 1023(s5)
	add_i s4, s4, 1024
	cmpne_i s5, s4, s3
	bnz s5, .LBB0_3
	b .LBB0_4

Also, it doesn't seem to actually be using vectors here. Probably need to tweak cost model to discourage it from doing this.

@jbush001
Copy link
Owner Author

NyuziToolchain/lib/Transforms/Vectorize/LoopVectorize.cpp

jbush001 added a commit that referenced this issue Nov 26, 2018
- Disabled loop vectorizer because it was breaking xv6-nyuzi kernel boot test.
(issue #103)
- Deleted spmd_compiler project. It was becoming a pain to maintain and doesn't provide
much value.
@jbush001
Copy link
Owner Author

This is currently disabled by default in tools/clang/lib/Driver/ToolChains/Clang.cpp.

@@@ -4447,6 -4852,6 +4854,10 @@@ void Clang::ConstructJob(Compilation &C
    // selected. For optimization levels that want vectorization we use the alias
    // option to simplify the hasFlag logic.
    bool EnableVec = shouldEnableVectorizerAtOLevel(Args, false);
++
++  // XXX Nyuzi
++  EnableVec = false;
++
    OptSpecifier VectorizeAliasOption =
        EnableVec ? options::OPT_O_Group : options::OPT_fvectorize;
    if (Args.hasFlag(options::OPT_fvectorize, VectorizeAliasOption,

@jbush001 jbush001 changed the title Loop vectorizer bloats code Loop vectorizer bloats code in some cases Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant