On 08/11/2022 11:25, Richard Biener wrote:
It would be great to have a code example for the construction of the "if
(f()) f();".
I think for the function above we need to emit __atomic_fetch_add_8,
not the emulated form because we cannot insert the required control
flow (if (f()) f()) on an edge. The __atomic_fetch_add_8 should then be
lowered after the instrumentation took place.
Would it help to change the
if (__atomic_add_fetch_4 ((unsigned int *) &val, 1, __ATOMIC_RELAXED)
== 0)
__atomic_fetch_add_4 (((unsigned int *) &val) + 1, 1,
__ATOMIC_RELAXED);
into
unsigned int v = __atomic_add_fetch_4 ((unsigned int *) &val, 1,
__ATOMIC_RELAXED)
== 0)
v = (unsigned int)(v == 0);
__atomic_fetch_add_4 (((unsigned int *) &val) + 1, 1,
__ATOMIC_RELAXED);
to get rid of an inserted control flow?
On riscv this is optimized to:
li a4,1
amoadd.w a5,a4,0(a0)
addi a5,a5,1
seqz a5,a5
addi a4,a0,4
amoadd.w zero,a5,0(a4)
--
embedded brains GmbH
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/