Re: [RFC v0 0/4] Give a type to constants too

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

 



On Thu, Aug 10, 2017 at 6:34 PM, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
>
> Absolutely not.
> Anyway, currectlyeach distinct value correspond to a *single/unique*
> pseudo. IN other words, there is no need to do any kind of CSE on
> *values*, they are already kinda pre-CSEed at their creation
> (because a constant value is nothing more than this value).

I see. value_pseudo() has the hash for all constant values.

But float is not covered.

#define PI 3.1415

double a;
void foo(void)
{
a = a*PI + a*PI*5;
}

 ./test-linearize /tmp/pi.c
/tmp/pi.c:3:8: warning: symbol 'a' was not declared. Should it be static?
/tmp/pi.c:4:6: warning: symbol 'foo' was not declared. Should it be static?
foo:
.L0:
<entry-point>
load.64     %r1 <- 0[a]
set.64      %r2 <- 3.141500 <================
mulu.64     %r3 <- %r1, %r2
set.64      %r5 <- 3.141500 <===duplicate======
mulu.64     %r6 <- %r1, %r5
set.64      %r7 <- 5.000000
mulu.64     %r8 <- %r6, %r7
add.64      %r9 <- %r3, %r8
store.64    %r9 -> 0[a]
ret

>
> Sorry, this has been tried and discussed already. It doesn't really work.
> * a size is essentially a type, certainly for integers in sparse IR.
> * A constant is a constant, 1 is 1, when it has 1 bit or 64 bits, it's the same
>   constant and follow the same mathematical rules. It's even not signed or
>   unsigned, it's just 1.
> * in sparse, types are conveyed by the *operations* made on their operands.
>   There are lots of good reasons for this. Trying to do the opposite for these
>   constants will just break a lot of things, duplicate a lot of code
> (try it) and
>   bring confusion everywhere (because of simply using the operation you
>   then need at each time check the type of the operands. It's something
>   we want to avoid (like for the discussion about casts we had yesterday)
>   not something we want to add).

I see, thanks for the explain. Let me think about it for a while.

> * the OP_PUSH instructions do a perfect job of giving a type to functions
>   arguments
> * the OP_PUSH instructions also nicely abstract away the *operation* of
>   argument passing that all architectures have. It's a good thing.

I need to take a closer look at that patch.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux