Skip to content

Generate stosq for std::fill for X86 targets #131377

@hiraditya

Description

@hiraditya

w.r.t. #129316
libc++ generates memset for specific std::fill patterns but we can do better with stosq. gcc generates stosq in some cases.

https://godbolt.org/z/T357Kqqee

Repro

#include <algorithm>
#include <vector>
#include <array>

int fill_v(std::vector<int> &v)
{
    std::fill(v.begin(), v.end(), SETVAL);
    return 0;
}

int fill_a(std::array<int, 100> &v)
{
    std::fill(v.begin(), v.end(), SETVAL);
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions