[llvm] [InstCombine] Modify `foldSelectICmpEq` to only handle more useful and simple cases. (PR #121672)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 4 17:24:03 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff c56b74315f57acb1b285ddc77b07031b773549b7 ee59139acb3995a7688e77ec35b87f408dc31a68 --extensions cpp -- llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 2838d45fcc..948ec3360c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1846,7 +1846,7 @@ static Instruction *foldSelectICmpEq(SelectInst &SI, ICmpInst *ICI,
if (match(CmpRHS, m_Zero())) {
// (X & Y) == 0 ? X |/^/+ Y : X |/^/+ Y -> X |/^/+ Y (false arm)
// `(X & Y) == 0` implies no common bits which means:
- // `X ^ Y == X | Y == X + Y`
+ // `X ^ Y == X | Y == X + Y`
// https://alive2.llvm.org/ce/z/jjcduh
if (match(CmpLHS, m_And(m_Value(X), m_Value(Y)))) {
auto MatchAddOrXor =
@@ -1859,10 +1859,10 @@ static Instruction *foldSelectICmpEq(SelectInst &SI, ICmpInst *ICI,
// (X | Y) == 0 ? X Op0 Y : X Op1 Y -> X Op1 Y
// For any `Op0` and `Op1` that are zero when `X` and `Y` are zero.
- // https://alive2.llvm.org/ce/z/azHzBW
+ // https://alive2.llvm.org/ce/z/azHzBW
if (match(CmpLHS, m_Or(m_Value(X), m_Value(Y))) &&
(match(TrueVal, m_c_BinOp(m_Specific(X), m_Specific(Y))) ||
- // In true arm we can also accept just `0`.
+ // In true arm we can also accept just `0`.
match(TrueVal, m_Zero())) &&
match(FalseVal, m_c_BinOp(m_Specific(X), m_Specific(Y)))) {
auto IsOpcZeroWithZeros = [](Value *V) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/121672
More information about the llvm-commits
mailing list