Re: [PATCH] rs6000: Fix type size checks for __builtin_ppc_atomic_cas_local [PR126513]

Michael Meissner <[email protected]> Wed, 5 Aug 2026 22:37:31 -0400
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
On Tue, Aug 04, 2026 at 02:32:21PM +0530, Avinash Jayakar wrote:
> Hi Michael/Jakub,
> 
> Below patch is to fix PR126513. Bootstrapped and regtested on
> powerpc64le-linux-gnu. Ok for trunk and affected branches (16 and 15)?
> 
> I would need some advice on whether we need to fix it for 16.2 release as well.
> Although the issue reported in PR126513 is a negative test where compiler must
> report error, but currently ICE happens. While testing it I see that case c4
> mentioned in the commit message was also not handled. This is a positive test
> where compiler must produce output, but ICEs and I think this is a bit more
> higher severity issue. So do you think this should go in 16.2?
> 
> Thanks and regards,
> Avinash Jayakar
> 
> Type checks for the first 3 operands of the
> __builtin_ppc_atomic_cas_local were missed with its initial
> implementation. This patch adds the following checks
> c1. Make sure the size of first 3 operands is the same.
> c2. Do not allow function pointers as arguments.
> c3. Report error when -mno-quad-memory-atomic is used but 128 bit
> operands are used as the first 3 operands.
> c4. A separate issue was when no lhs was assigned to this builtin, ICE would
> happen as a result of emit_cmp_and_jump_insns function dereferencing the
> target rtx which would be null. Added the check in rs6000_expand_builtin
> to allocate a reg_rtx if target is null or const0_rtx.

This looks ok for the trunk and for GCC 16.2.1 or GCC 16.3 when they
open up for general patches.

-- 
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: [email protected]