llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

missed optimization of and + csel + sub

Open bcl5980 opened this issue 6 months ago • 14 comments

the case I find: https://alive2.llvm.org/ce/z/eVF5DP

general version: https://alive2.llvm.org/ce/z/jv3rGf

bcl5980 avatar Jun 03 '26 11:06 bcl5980

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. Check that no other contributor is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
  2. Leave a comment indicating that you are working on the issue, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
  3. Fix the issue locally. Be aware that LLVM's AI policy forbids the use of AI tools to fix good first issues since it squanders a learning opportunity. Using LLMs to search and learn is permitted, since the goal is learning.
  4. 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.
  5. Create a Git commit.
  6. Run git clang-format HEAD~1 to format your changes.
  7. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.

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

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

Author: chenglin.bi (bcl5980)

https://alive2.llvm.org/ce/z/jv3rGf

Hi,I'd like to work on this issue.

Chennesxu avatar Jun 03 '26 13:06 Chennesxu

I'd like to work on this!

I can see the missed optimization in the Alive2 link — and + csel + sub can be folded more efficiently.

I'll look at the AArch64 backend and InstCombine to find where this pattern should be caught.

/assign

hesam-oxe avatar Jun 03 '26 13:06 hesam-oxe

I would like to work on this issue can you assign??

AnkitDubeycs25 avatar Jun 03 '26 14:06 AnkitDubeycs25

@AnkitDubeycs25 Please be moderate with flooding "can you assign this to me" messages across LLVM issues.

antoniofrighetto avatar Jun 03 '26 15:06 antoniofrighetto

the case I find: https://alive2.llvm.org/ce/z/eVF5DP

general version: https://alive2.llvm.org/ce/z/jv3rGf

Is there real code that has this pattern?

BreadTom avatar Jun 03 '26 17:06 BreadTom

@Chennesxu Are you still working on this? If you'd like, I can collaborate — I've been looking at the AArch64 InstCombine path and have some ideas on where the fold should happen.

Happy to pair up or let you take the lead. Let me know! 🤝

hesam-oxe avatar Jun 03 '26 19:06 hesam-oxe

@hesam-oxe Thanks for reaching out! Looks like someone already submitted a PR, so I'll step aside. Good luck!

Chennesxu avatar Jun 04 '26 01:06 Chennesxu

@iamaayushrivastava are you still working on this?

SreshthTiwari avatar Jun 28 '26 16:06 SreshthTiwari

Hi @SreshthTiwari, I've already opened a PR (https://github.com/llvm/llvm-project/pull/201469) for it.

iamaayushrivastava avatar Jun 28 '26 17:06 iamaayushrivastava

My fault, missed it.

SreshthTiwari avatar Jun 28 '26 17:06 SreshthTiwari

Dear reviewers, a gentle reminder on this PR (https://github.com/llvm/llvm-project/pull/201469) whenever you get a chance. Thanks!

iamaayushrivastava avatar Jul 08 '26 09:07 iamaayushrivastava

Dear reviewers, a gentle reminder on this PR (https://github.com/llvm/llvm-project/pull/201469) whenever you get a chance. Thanks!

iamaayushrivastava avatar Aug 02 '26 13:08 iamaayushrivastava