Skip to content

[X86] Use X86ISD::BSF/BSR fall through operands to be used for general values #123938

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

Open
RKSimon opened this issue Jan 22, 2025 · 1 comment
Open

Comments

@RKSimon
Copy link
Collaborator

RKSimon commented Jan 22, 2025

Followup to #123623 which added a fall through operand to X86ISD::BSF/BSR nodes to handle 'src is zero' behavior on supported CPUs.

We can use the fall through for other cases than the bitwidth constant values which we currently handle.

There are a couple of gotchas to address:

  • Must still be limited to CPUs that support fall through on BSF/BSR instructions
  • The "REP BSF" -> TZCNT performance hack in X86MCInstLower::Lower will need adjusting to only work for undef / correct constants
  • Additional tests (both for constant and variable fall through values) will be necessary as we can't guarantee that 32-bit BSR/BSF instructions correctly zero the upper 32-bits of a register
@llvmbot
Copy link
Member

llvmbot commented Jan 22, 2025

@llvm/issue-subscribers-backend-x86

Author: Simon Pilgrim (RKSimon)

Followup to #123623 which added a fall through operand to X86ISD::BSF/BSR nodes to handle 'src is zero' behavior on supported CPUs.

We can use the fall through for other cases than the bitwidth constant values which we currently handle.

There are a couple of gotchas to address:

  • Must still be limited to CPUs that support fall through on BSF/BSR instructions
  • The "REP BSF" -> TZCNT performance hack in X86MCInstLower::Lower will need adjusting to only work for undef / correct constants
  • Additional tests (both for constant and variable fall through values) will be necessary as we can't guarantee that 32-bit BSR/BSF instructions correctly zero the upper 32-bits of a register

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants