On 12/30/23 21:34, YunQiang Su wrote:
Right.  But that's the whole point behind avoiding the narrowing subreg
and forcing use of a truncate operation.

So basically the question becomes is there a way to modify those bits in
a way that GCC doesn't know that it needs to to truncate/extend?


I guess that this code may cause some problem.
int test(int val, unsigned char c, int pos) {
   ((unsigned char*)&val)[pos+0] = c;
   return val;
}
GCC avoids using bitops, instead it uses load/store for it.
Any ISA has INSERT_CHAR_VAR instruction?
      INSERT_CHAR_VAR $rN, $rM,$rX
ISAs that can do that via load certainly exist, but none (to the best of my knowledge) need to extend sub-words for correctness reasons.




So I guess that  known_lt may be a better choice
if (known_lt)
     no_truncate_or_extend_needed;
else
     add_truncate_or_extend;
I think Roger's argument is these cases can't happen.

jeff

Reply via email to