[PATCH] D88104: [GlobalISel] Combine (xor (and x, y), y) -> (and (not x), y)
Jessica Paquette via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 09:22:43 PDT 2020
paquette added inline comments.
================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:2679
+
+ if (Y != SharedReg)
+ std::swap(X, Y);
----------------
aemerson wrote:
> This code is a bit big-brain for me this morning. Simplify this to `return X == SharedReg || Y == SharedReg`?
I don't think that would be correct. At this point, `Y` is set to the RHS of the G_AND. This is passed along as the second element of the pair when we get to `applyXorOfAndWithSameReg`.
So we'd end up folding
```
xor (and x, y), x) -> (and (not x), y)
```
if you let `x =1` and `y = 0` then
```
xor (and 1, 0), 1 = 1
and (not 1), 0 = 0
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88104/new/
https://reviews.llvm.org/D88104
More information about the llvm-commits
mailing list