[all-commits] [llvm/llvm-project] 73863a: [InstCombine] Add tests for folding `(add/sub/disj...
goldsteinn via All-commits
all-commits at lists.llvm.org
Mon Jan 15 12:07:30 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 73863a48352c48b0c37a49c5dcfa521eb0cfcb5b
https://github.com/llvm/llvm-project/commit/73863a48352c48b0c37a49c5dcfa521eb0cfcb5b
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2024-01-15 (Mon, 15 Jan 2024)
Changed paths:
A llvm/test/Transforms/InstCombine/fold-ctpop-of-not.ll
Log Message:
-----------
[InstCombine] Add tests for folding `(add/sub/disjoint_or/icmp C, (ctpop (not x)))`; NFC
Commit: 60e8915d2277ab784f4d27139c479868255b22bf
https://github.com/llvm/llvm-project/commit/60e8915d2277ab784f4d27139c479868255b22bf
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2024-01-15 (Mon, 15 Jan 2024)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
M llvm/test/Transforms/InstCombine/fold-ctpop-of-not.ll
Log Message:
-----------
[InstCombine] Add folds for `(add/sub/disjoint_or/icmp C, (ctpop (not x)))`
`(ctpop (not x))` <-> `(sub nuw nsw BitWidth(x), (ctpop x))`. The
`sub` expression can sometimes be constant folded depending on the use
case of `(ctpop (not x))`.
This patch adds fold for the following cases:
`(add/sub/disjoint_or C, (ctpop (not x))`
-> `(add/sub/disjoint_or C', (ctpop x))`
`(cmp pred C, (ctpop (not x))`
-> `(cmp swapped_pred C', (ctpop x))`
Where `C'` depends on how we constant fold `C` with `BitWidth(x)` for
the given opcode.
Proofs: https://alive2.llvm.org/ce/z/qUgfF3
Closes #77859
Compare: https://github.com/llvm/llvm-project/compare/f9b089a7c01d...60e8915d2277
More information about the All-commits
mailing list