Issue 117853
Summary Missed optimization: per-byte comparisons are not always combined properly
Labels new issue
Assignees
Reporter purplesyringa
    Reproducer: https://godbolt.org/z/6caGGoo1e

```c
int is_all_ones(unsigned char *p) {
    unsigned char a = p[0];
    unsigned char b = p[1];
    return a == 255 && b == 255;
}
```

I've expected this to compile to a single read + comparison on platforms that support unaligned accesses. Instead, this happened:

```x86asm
is_all_ones:
        movzx   ecx, byte ptr [rdi + 1]
        and     cl, byte ptr [rdi]
        xor     eax, eax
        cmp cl, -1
        sete    al
        ret
```


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to