[PATCH] D41798: [LegalizeDAG] Fix ATOMIC_CMP_SWAP_WITH_SUCCESS legalization.

Ulrich Weigand via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 08:44:45 PST 2018


uweigand added a comment.

In https://reviews.llvm.org/D41798#969885, @nemanjai wrote:

> In https://reviews.llvm.org/D41798#969786, @uweigand wrote:
>
> > In any case, I'm not sure why the *input* to ATOMIC_CMP_SWAP should be extended in any way in the first place: the back-end gets told the actual type explicitly, and if any extension is necessary due to the particular way a back-end implements the operation, the back-end can just do that extension itself.
>
>
> I'm not sure what you mean here. The `i8` and `i16` types are not legal on PPC. As such, type legalization will undoubtedly expand operands of those types. If you look at the debug dumps I posted above, you'll notice that pre-type-legalization, the inputs are `i16` and post-type-legalization, they're `i32`.
>  I think the gist of the issue here is that type legalization should do the right thing - operation legalization is probably later than the optimal place for this. Although, I agree that the operands should probably be extended according to `TLI.getExtendForAtomicOps()`.


Sure, the operands will have been any-extended from i8/i16 to i32.  But the target knows that this happened, because it knows that this is a i8/i16 ATOMIC_CMP_SWAP (via getMemoryVT).  In that case, if it actually requires a particular sign- or zero-extended version of the original i8/i16 constant, it can still do the appropriate in-reg extension from the any-extended i32 value it got.


Repository:
  rL LLVM

https://reviews.llvm.org/D41798





More information about the llvm-commits mailing list