----- Am 18. Aug 2025 um 15:19 schrieb Jørgen Kvalsvik j...@lambda.is:

> On 8/18/25 14:37, Sebastian Huber wrote:
[...]
> I tried this program:
> 
> int a(int i);
> int b(int i);
> int c(int i);
> 
> int f(int i, int j, int k, int l, int m)
> {
>   if (i && j && (k || !l || m)) {
>     if (a(i) || b(i) || l) {
>       return a(i);
>     } {
>       return c(i);
>     }
>   } else if (k && m) {
>     return b(i);
>   } else {
>     return 123;
>   }
> }
> 
> And compiled it like you did: gcc -O2 -fprofile-update=atomic
> -fcondition-coverage -S -o - test2.c -fdump-tree-all
> 
> Most of the atomics operate on consts, but there is this:
> 
>   <bb 9> [local count: 234572472]:
>   _39 = _35 | 16;
>   _40 = _36 | 1;
>   _53 = ~_40;
>   _54 = _34 & _53;
>   _55 = _39 & _53;
>   __atomic_fetch_or_8 (&__gcov8.f[0], _54, 0);
>   __atomic_fetch_or_8 (&__gcov8.f[1], _55, 0);
>  

My output was from a recent GCC 16 for RISC-V.

> 
> We could still probably detect the zero from the instrumentation, but
> this is a case where the ior is path dependent. I would think a proper
> elimination is better tied to the args to __atomic_fetch though, it must
> surely be able to detect that it is a no-op?

Ok, looks a bit more complicated to optimize. I may have a look at this later. 
For now, the important thing to me is getting it to work on 32-bit targets.

-- 
embedded brains GmbH & Co. KG
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

Reply via email to