Hi!
On 2023/09/07 23:22, Max Filippov wrote:
> gcc/
> * config/xtensa/predicates.md (xtensa_cstoresi_operator): Add
> unsigned comparisons.
> * config/xtensa/xtensa.cc (xtensa_expand_scc): Add code
> generation of salt/saltu instructions.
> * config/xtensa/xtensa.h (TARGET_SALT): New macro.
> * gcc/config/xtensa/xtensa.md (salt, saltu): New instruction
> patterns.
> ---
> I've tested it both with configurations that have salt/saltu and that
> don't.
> The inversion of the result at the end looks wasteful. I've been reading
> gccint chapter about cstoreMODE4 and the following part left me with the
> question:
>
> The value stored for a true condition must have 1 as its low bit,
> or else must be negative.
>
> Does it mean that some variants of cstoreMODE4 may return 1 and some may
> return -1 for truth, as both have 1 as its low bit?
IMHO it is nothing more than the fact that there are two possible integer
constants that represent 'true' (the result of !0), namely either 1 or -1.
And given a certain target and configuration, it must be consistently fixed to
one value or the other; for Xtensa, it should be an integer constant of 1.
> If that's true we
> could use 'addi dest, dest, -1' instead of two-intruction sequence
> 'movi tmp, 1; xor dest, dest, tmp'.
An alternative way to convert 1 to 0 and 0 to 1:
neg dest, dest
addi dest, 1
This requires no temporary register.