Issue 174220
Summary `xor undef, undef` always evaluates to `0`
Labels new issue
Assignees
Reporter Veeloxfire
    Tested on x64 clang trunk

```cpp
int foo_xor() {
    int i;
    int j;

    return i ^ j;
}
```
During optimization this reaches `xor undef, undef`
`xor undef, undef` then "optimizes" to `0`

This is special cased to allow `a ^ a` to always be `0`:
https://github.com/llvm/llvm-project/blob/40155458d7660cf4d28894e2ec40010743172e44/llvm/lib/IR/ConstantFold.cpp#L628-L632

I am aware this is UB so the behaviour doesn't necessarily matter but it feels unreasonable that the 2 "different" `undef`'s here xor to `0` and we inject a concrete `0` that the optimizer has to work around
Not sure there is a way in llvm's internals to specify that 2 undef values are different so it may not be worth investigating but I thought I would raise
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to