On Sat, Apr 11, 2020 at 04:27:07PM -0700, Sasha Krassovsky via Gcc wrote:
> However, in the following example, the load does get the cost applied to it 
> but the store to B does not. 
> 
> void bar(__attribute__((remote(5)) int *a, int *b)
> {
>     if(*A > 5)
>         *A = 10;
>     *B = *A;
> }
> 
> I was wondering if this is the correct way to approach this problem, and also 
> why the attribute sometimes gets applied and sometimes not.

There are many places in the compiler that only consider the cost of
the source of a SET insn, that is, given something like

 (set (mem (address)) (op (reg) (const_int)))

will only pass (op (reg) (const_int)) to rtx_cost, and from there to
TARGET_RTX_COSTS.  Those places are generally looking at costs to see
whether variations in the SET source are profitable, for example
whether it is better to put the (const_int) in another reg first then
change the expression to (op (reg) (reg2)).

Other places, eg. rtlanal.c:seq_cost do pass the entire SET.

-- 
Alan Modra
Australia Development Lab, IBM

Reply via email to