Issue 144282
Summary LLVM can compile a function differently if there are different paramters even if the demanded bits are the same
Labels new issue
Assignees
Reporter AZero13
    https://godbolt.org/z/4nYe6avsv

unsigned func1(unsigned a, unsigned b)
{
        int c = a & b;
        return (c ^ a)&1;
}

unsigned func1_2(unsigned a, bool b)
{
        int c = a & b;
 return (c ^ a)&1;
}

Here, the only bit that matters is the bottom one, hence it should make no difference.

However, we get:

func1(unsigned int, unsigned int):
        bic     w8, w0, w1
 and     w0, w8, #0x1
        ret

func1_2(unsigned int, bool):
 and     w8, w0, #0x1
        tst     w1, #0x1
        csel    w0, wzr, w8, ne
        ret


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

Reply via email to