Skip to content

Bounds check is not eliminated i != count vs i < count #63125

Closed
@Kojoley

Description

@Kojoley
#define _GLIBCXX_ASSERTIONS
#include <vector>

void foo(std::vector<double> &vec)
{
   auto count = size(vec);
   for (decltype(count) i = 0; i != count; ++i)
     vec[i] += 1;
}

-mllvm -enable-constraint-elimination does not help.
With i < count bounds check is eliminated.
https://godbolt.org/z/s6Gbsqvor

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