tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] read32le/write32le


From: Edmund Grimley Evans
Subject: Re: [Tinycc-devel] read32le/write32le
Date: Wed, 18 Nov 2015 20:28:38 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

> As I understand it, this patch changes certain bit copying lines. Those which
> cast their data as integer arrays are now cast as character arrays, and what
> used to be a single copy operation is now four copy operations. Presumably 
> this
> would lead to behavior that is more robust and less likely to fail. Can you
> explain under which circumstances the integer copy would fail where the
> character copy would succeed?

The "*(int *)ptr += ..." stuff could fail in several circumstances:

- host is not little-endian
- host does not allow unaligned memory access
- compiler does some bizarre optimisation because of the implication
  that ptr must, somehow, be a valid pointer to int

> Also, can we expect smart compilers to notice
> that we're copying four consecutive bytes, and use a 32 bit read/write instead
> of four 8 bit read/writes?

Yes.

> In short: it seems unlikely to me that we'd get wrong behavior on any platform
> used by TCC using the current code. Thus a good explanation, and benchmarks
> showing minimal (or zero) impact on execution are important for this patch.

I found no measurable slow-down of tcc built by tcc building tcc.

Edmund



reply via email to

[Prev in Thread] Current Thread [Next in Thread]