[PATCH] D128080: [SDAG] convert sub from (Pow2-1) constant into xor

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 18 06:18:56 PDT 2022


spatel added a comment.

In D128080#3594009 <https://reviews.llvm.org/D128080#3594009>, @deadalnix wrote:

> It doesn't looks like it is helping D127115 <https://reviews.llvm.org/D127115>, but it looks useful on its own.

Yes,  I stepped through one of those tests, and we'd have to do something else...I'm not sure what that is yet.

I also tracked down where this happens in x86 codegen:
https://github.com/llvm/llvm-project/blob/cd64a427efa0baaf1bb7ae624d4301908afc07f7/llvm/lib/Target/X86/X86InstrCompiler.td#L1535

So this fold and the InstCombine that I copied from are actually over-constrained. We don't need a low-bit-mask constant:
https://alive2.llvm.org/ce/z/OUm6N_

I'll add a TODO comment for now. I can add more tests and generalize the transforms as a follow-up.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128080/new/

https://reviews.llvm.org/D128080



More information about the llvm-commits mailing list