Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize x * !x to 0 for vector #84608

Closed
k-arrows opened this issue Mar 9, 2024 · 7 comments · Fixed by #84792
Closed

Optimize x * !x to 0 for vector #84608

k-arrows opened this issue Mar 9, 2024 · 7 comments · Fixed by #84792
Assignees
Labels
good first issue https://github.com/llvm/llvm-project/contribute llvm:instcombine missed-optimization

Comments

@k-arrows
Copy link

k-arrows commented Mar 9, 2024

Consider the following test case from https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/tree-ssa/pr114009.c

typedef int V __attribute__((vector_size (4 * sizeof (int))));

V qux (V x)
{
  return x * (x == 0);
}

Godbolt: https://godbolt.org/z/dfGacerv8
Alive2: https://alive2.llvm.org/ce/z/uijB4T

@dtcxzyw dtcxzyw added the good first issue https://github.com/llvm/llvm-project/contribute label Mar 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 9, 2024

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. In the comments of the issue, request for it to be assigned to you.
  2. Fix the issue locally.
  3. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  4. Create a Git commit.
  5. Run git clang-format HEAD~1 to format your changes.
  6. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

@llvmbot
Copy link
Member

llvmbot commented Mar 9, 2024

@llvm/issue-subscribers-good-first-issue

Author: None (k-arrows)

Consider the following test case from https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/tree-ssa/pr114009.c ```c typedef int V __attribute__((vector_size (4 * sizeof (int))));

V qux (V x)
{
return x * (x == 0);
}

Godbolt: https://godbolt.org/z/dfGacerv8
Alive2: https://alive2.llvm.org/ce/z/uijB4T
</details>

@dtcxzyw dtcxzyw removed the good first issue https://github.com/llvm/llvm-project/contribute label Mar 9, 2024
@dtcxzyw
Copy link
Member

dtcxzyw commented Mar 9, 2024

Alive2: https://alive2.llvm.org/ce/z/-XEPRP

@dtcxzyw dtcxzyw added the good first issue https://github.com/llvm/llvm-project/contribute label Mar 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 9, 2024

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. In the comments of the issue, request for it to be assigned to you.
  2. Fix the issue locally.
  3. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  4. Create a Git commit.
  5. Run git clang-format HEAD~1 to format your changes.
  6. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

@llvmbot
Copy link
Member

llvmbot commented Mar 9, 2024

@llvm/issue-subscribers-good-first-issue

Author: None (k-arrows)

Consider the following test case from https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/tree-ssa/pr114009.c ```c typedef int V __attribute__((vector_size (4 * sizeof (int))));

V qux (V x)
{
return x * (x == 0);
}

Godbolt: https://godbolt.org/z/dfGacerv8
Alive2: https://alive2.llvm.org/ce/z/uijB4T
</details>

@SahilPatidar
Copy link
Contributor

@dtcxzyw,
I would like to work on this one.

@SahilPatidar
Copy link
Contributor

Alive2: https://alive2.llvm.org/ce/z/-XEPRP

This case also needs to be handled. Additionally, I couldn't find any such pattern in the existing code in InstCombineMulDivRem.cpp, so it likely needs to be implemented from scratch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue https://github.com/llvm/llvm-project/contribute llvm:instcombine missed-optimization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants