Repository: rust
Issue: No auto-vectorization in such case since 1.54.0
Labels: A-LLVM,I-slow,T-compiler,C-bug

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I tried this code:

```rust
const MAX_STEP_DATA_SIZE: usize = 32;

#[inline]
fn check(byte: u8) -> bool {
    return (byte <= 0x20) || (byte == 0x22) || (byte == 0x3D) || (byte == 0x5B) || (byte == 0x5D);
    return (byte <= 0x20) | (byte == 0x22) | (byte == 0x3D) | (byte == 0x5B) | (byte == 0x5D);
}

#[inline]
fn is_any(s: &[bool]) -> bool {
    let mut res = false;
    for i in 0..s.len() {
        res |= s[i];
    }
    res
}

unsafe fn test_impl(s: *const u8, len: usize) -> bool {
    let mut step_data = [false; MAX_STEP_DATA_SIZE / std::mem::size_of::<u8>()];
    let mut s = s;
    let mut len = len;
    while len >= step_data.len() {
        for i in 0..step_data.len() {
            step_data[i] = check(*s.add(i));
        }

        if is_any(&step_data) {
            return true;
        }

        s = s.add(step_data.len());
        len -= step_data.len();
    }
    for i in 0..len {
        if check(*s.add(i)) {
            return true;
        }
    }
    return false;
}

pub fn test(s: &[u8]) -> bool {
    unsafe { test_impl(s.as_ptr(), s.len()) }
}

```

With `rustc 1.53.0-nightly`
run `RUSTFLAGS="--emit=asm -C target-feature=+avx2" cargo build --release`
rustc can generate vectorized asm.

But with 1.54.0 or higher, rustc can not make optimization.

It can be verified in [godbolt.org](https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1DEArgoKkl9ZATwDKjdAGFUtEywYgATAE5SjgBk8BkwAOXcAI0xiEGkAB1QFQjsGFzcPbz8EpNsBIJDwliiY6StMGxShAiZiAjT3T19LTGtchiqagnywyOjYy2ra%2Boym807uwuLYgEpLVBNiZHYONAZzAGoAWQBBAA0AfSEAFWxlfYARbaPtw4BJAC1sE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vU7wWAsIYwDiCHpD4NyFQAG7/SrmCqOUs7LBzwQkmT0dIhExCey4WDe7wDWQSXsxUAYwAKAAangmAmf7cSMCXMiCCIYjsFI7fyEoagq7oXD6BHICmOY%2Bh4BE7aQLMqDYyk7YcFSurzwQVL0IntCij81K6oMwA8lSQE0QsTVol4wJMPHErqy05RtA4DDOK4DR6IEyKTH0w/ZMkAjDJ4H%2BiQ/4MAmL0GIw8ygVAEB0IYr8MiQPvtA9ogwuif3AXoMYcD0iAIGOMdBRRv6zAUCzJYegGqYAziTBWHAKakCpjTOmHBx4EGQOsLg%2B47b7g0AqRmE91i4EIB5csPxh7rBcJbaIQNRHTFLtrWYOIkp9FxnzH4zJOE0KVqQMSzIyT7jJLCO2XhYTS0kFIHwIt6EqyYerEAmsuYhx1vrCASB5gEC%2BhYM2Fs4gm3fvgIgEDe6d3ED3fgghFAqHUNHEyBc4gVxoXQhhvAmH%2B1nB49Y0kuRMzYRwrhPCIASJ8VbaRXBZFa0cQozASiYi4xzlosSXgOFSEkJ2ZkkgNAGIMXLWEzIrHRxsZYOx5StDpVIHzSQ6jDGSB%2BBMskwMOmdh8PLHOPxlb9LVsMnmNCvBrMYRshxIzZiJ2dikWIQA) as well.

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.59.0-nightly (e100ec5bc 2021-12-21)
binary: rustc
commit-hash: e100ec5bc7cd768ec17d75448b29c9ab4a39272b
commit-date: 2021-12-21
host: x86_64-unknown-linux-gnu
release: 1.59.0-nightly
LLVM version: 13.0.0
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Backtrace</summary>
<p>

```
<backtrace>
```

</p>
</details>