[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

Paulo Matos via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 24 06:29:54 PDT 2023


pmatos added a comment.

In D150670#4368238 <https://reviews.llvm.org/D150670#4368238>, @pmatos wrote:

> In D150670#4352163 <https://reviews.llvm.org/D150670#4352163>, @nikic wrote:
>
>> 1. Say that we prefer preserving rotates over "simplifying" funnel shifts (ending up with the rot2 pattern). Basically by skipping the optimization at https://github.com/llvm/llvm-project/blob/7f54b38e28b3b66195de672848f2b5366d0d51e3/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L927-L931 if both fsh operands are the same. Assuming this doesn't cause test regressions, I think this would be acceptable to do. From a backend perspective, even for targets that have a native funnel shift (aarch64, x86), the difference between the rot1/rot2 patterns looks pretty neutral.

OK, I just re-read your comment above and I am starting to assume that what you mean is skipping the optimization for all targets if the funnel shift is a rotate (i.e. same first two operands). Is this correct?

> I am surprised this option is viable for example. This was my initial thought to avoid the rotate, but I assumed adding something like :
>
>   if (!getTarget().getTriple().isWasm()) {
>     APInt DemandedMaskLHS(DemandedMask.lshr(ShiftAmt));
>     APInt DemandedMaskRHS(DemandedMask.shl(BitWidth - ShiftAmt));
>     if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) ||
>         SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1))
>       return I;
>   }
>
> would not be well received. Also, I cannot find precedent for doing this.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670



More information about the cfe-commits mailing list