[all-commits] [llvm/llvm-project] 472558: [ValueTracking] A and (B & ~A) have no common bits...
Nikita Popov via All-commits
all-commits at lists.llvm.org
Tue May 3 02:33:43 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 47255834e720b735ff1358a74fdf32345bb4daca
https://github.com/llvm/llvm-project/commit/47255834e720b735ff1358a74fdf32345bb4daca
Author: Nikita Popov <npopov at redhat.com>
Date: 2022-05-03 (Tue, 03 May 2022)
Changed paths:
M llvm/lib/Analysis/ValueTracking.cpp
M llvm/test/Transforms/InstCombine/add.ll
Log Message:
-----------
[ValueTracking] A and (B & ~A) have no common bits set
This extends haveNoCommonBitsSet() to two additional cases, allowing
the following folds:
* `A + (B & ~A)` --> `A | (B & ~A)`
(https://alive2.llvm.org/ce/z/crxxhN)
* `A + ((A & B) ^ B)` --> `A | ((A & B) ^ B)`
(https://alive2.llvm.org/ce/z/A_wsH_)
These should further fold to just `A | B`, though this currently
only works in the first case.
The reason why the second fold is necessary is that we consider
this to be the canonical form if B is a constant. (I did check
whether we can change that, but it looks like a number of folds
depend on the current canonicalization, so I ended up adding both
patterns here.)
Differential Revision: https://reviews.llvm.org/D124763
More information about the All-commits
mailing list