-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InstCombine] fold icmp of the sum of ext bool based on limited range
For the pattern `(zext i1 X) + (sext i1 Y)`, the constant range is [-1, 1]. We can simplify the pattern by logical operations. Like: ``` (zext i1 X) + (sext i1 Y) == -1 --> ~X & Y (zext i1 X) + (sext i1 Y) == 0 --> ~(X ^ Y) (zext i1 X) + (sext i1 Y) == 1 --> X & ~Y ``` And other predicates can the combination of these results: ``` (zext i1 X) + (sext i1 Y)) != -1 --> X | ~Y (zext i1 X) + (sext i1 Y)) s> -1 --> X | ~Y (zext i1 X) + (sext i1 Y)) u< -1 --> X | ~Y (zext i1 X) + (sext i1 Y)) s> 0 --> X & ~Y (zext i1 X) + (sext i1 Y)) s< 0 --> ~X & Y (zext i1 X) + (sext i1 Y)) != 1 --> ~X | Y (zext i1 X) + (sext i1 Y)) s< 1 --> ~X | Y (zext i1 X) + (sext i1 Y)) u> 1 --> ~X & Y ``` All alive proofs: https://alive2.llvm.org/ce/z/KmgDpF https://alive2.llvm.org/ce/z/fLwWa9 https://alive2.llvm.org/ce/z/ZKQn2P Fix: llvm/llvm-project#59666 Reviewed By: spatel Differential Revision: https://reviews.llvm.org/D143373
- Loading branch information
1 parent
35d1d74
commit 72edd8b
Showing
3 changed files
with
120 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters