| Age | Commit message (Collapse) | Author | Files | Lines |
|
Comparision of floating-point values can't be done
like for integral values because of the possibility to have
NaNs which can't be ordered with normal values or even between
themselves.
The real difference appears once there is any "reasoning"
done with the result of the comparison. For example, once NaNs
are taken in account: "!(a < b)" and "(a >= b)" are not the same.
In fact the usual comparison operators must be reinterpreted
as implicitely first testing if any of the operand is a Nan
and return 'false' if it is the case. Thus "a < b" becomes
"!isnan(a) && !isnan(b) && (a < b)".
If we need to negate the comparison we get "!(a < b)" which
naturally becomes "isnan(a) || isnan(b) || (a >= b)".
We thus need two sets of operators for comparison of floats:
one for the "ordered" values (only true if neither operand
is a Nan) and one for the "values" (also true if either
operand is a NaN). A negation of the comparison switch from one
of the set to the other.
So, introduce another set of instructions for the comparison
of floats.
Note: the C standard requires that:
*) "x == x" is false if x is a NaN,
*) "x != x" is true if x is a NaN,
and this is coherent with "x != x" <-> "!(x == x)".
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
OP_BR instructions exist in two flavours, relatively much
differentiated: conditional & non-conditional. One has an
operand (and thus its usage need to be cared for, must be
handled in liveness analysis, ..) the other has not; one has
two BB target, the other only one.
There is essentially no places in the code where both flavours
are handled the same. Sometimes they both must be handled but
each with their specificities but in most cases only one of
them is concerned and we need to filter out the other one.
In both cases it means that we need to check what kind we're
dealing with.
There is already a problem with this because there is
several ways to test which kind an OP_BR is and they
are not exactly equivalent:
1) testing if insn->cond is NULL
2) testing if one of insn->bb_true or ->bb_false is NULL.
There exist also an helper (is_branch_goto()) which does
the second tests but which is never used.
It appears that the first test should not be used because
in some cases an conditional OP_BR is changed into
a non-conditional one by (amongst others things) setting
it's ->cond to VOID. We should thus always use the seconds
test (which need two compares with NULL).
This could be corrected in several ways (like changing all
the places wheer the first test is used, use the helper
everywhere or never set ->cond to VOID) but the simplest
is to simply split them in two separated instructions:
OP_BR & OP_CBR, especailly given the fact that in most cases
the OP_BR was first selected by a switch (opcode).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
In the liveness analysis, the use/def methods have a
'struct instruction *' argument.
This arg is never used and it's not clear for what it
could be used, what it would represent.
This patch remove this argument from all the concerned
functions.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The function phi_defines() does the liveness tracking of phi-pseudos
(pseudos in OP_PHIs args). While doing this, the function is
recursively called when the pseudo would be defined by another phi-node;
but this condition is impossible because all phi-pseudos are defined
by OP_PHISOURCE instructions.
This patch remove the recursive call and its associated test.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Hello,
attached are patch, testing input for test-unssa and its outputs before patch
and after patch. Thanks in advance for considering the patch!
Kamil
test:
.L0x7f9fb2030010
<entry-point>
phisrc.32 %phi2(ptr) <- %arg1
br .L0x7f9fb2030130
.L0x7f9fb2030130
copy.32 %r1(ptr) <- %r5(ptr)
br %r1(ptr), .L0x7f9fb2030058, .L0x7f9fb20300e8
.L0x7f9fb2030058
load.32 %r3 <- 0[%r1(ptr)]
phisrc.32 %phi3(ptr) <- %r3
br .L0x7f9fb2030130
.L0x7f9fb20300e8
ret
test:
.L0x7f4a7f7f1010
<entry-point>
copy.32 %r5(ptr) <- %arg1
br .L0x7f4a7f7f1130
.L0x7f4a7f7f1130
copy.32 %r1(ptr) <- %r5(ptr)
br %r1(ptr), .L0x7f4a7f7f1058, .L0x7f4a7f7f10e8
.L0x7f4a7f7f1058
load.32 %r3 <- 0[%r1(ptr)]
copy.32 %r5(ptr) <- %r3
br .L0x7f4a7f7f1130
.L0x7f4a7f7f10e8
ret
>From 66a02fa7cec780fc88d6ef4cce7a1e704928808a Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Sun, 9 Aug 2009 10:22:11 +0200
Subject: [PATCH] unssa: track uses when replacing a phi node
The output of test-unssa is inconsistent for a simple test-case without
this patch:
static void test(void **ptr)
{
while (ptr) {
ptr = *ptr;
}
}
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Thanks to Luc Van Oostenryck for pointing out a trivial example of
something that does totally the wrong thing with that code.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
|
|
Otherwise we lose the information what the target
type is (we only have the bit-size of the target).
|
|
(symbol addresses).
They are pretty different. Symbol addresses have special meaning during
various phases, from symbol simplification to CSE.
|
|
This also makes the OP_ASM data structures a bit more structured
in order to contain all the required information.
|
|
This only matters for phi-nodes, since other kinds of pseudos
should never see any use before their def anyway.
|
|
We'll want to have the full phi user list when we do liveness.
|
|
tracking. Make the asserts reflect that.
|
|
|
|
update the code that moves "needs" information to the parent.
Now that we only add real needs to the needs list, this
is much simpler.
|
|
Let's not add the pseudos that the bb defines internally onto
the "needs" list. Rather than removign them later, just avoid
putting them there in the first place.
The special cases end up being argument pseudos (which aren't
really defined by the entry bb) and phi-nodes.
|
|
This allows us to always see which pseudos are nonlocally affected
by the phi source.
We can only do this after the instruction flow is fixed, together
with the OP_DEATHNOTE phase.
|
|
|
|
This requires that we be able to handle "uses" pseudos without
a defining instruction.
|
|
Now that we have full pseudo usage lists, we can also add
deathnotes to pseudos in the instruction stream.
NOTE! We add the deathnote to _before_ the last instruction
that uses that pseudo. That looks a bit strange, but it's
actually what you want: when we traverse the instuctions, we
want to know that the inputs are dead.
|
|
(this approximates depth-first) rather than in-order (~breadth first).
This hugely speeds up long chains pseudo use.
|
|
This was originally done so that "struct instruction" would be
smaller, but it has since grown anyway (for the memops), so splitting
OP_SEL into two instructions no longer makes sense, and makes it
harder on CSE.
|
|
The "constant conditional" stuff in flow simplification is now
handled by the trivial instruction simplification, so the only
thing that remained was the conditional flow based on following
constant PHI-nodes. And that one can be much more effectively
done after liveness analysis, when we can decide to skip even
non-empty blocks if the target we are skipping to doesn't care
about this particular block.
|
|
The bb register usage lists are now just the minimal set of pseudos
that are relevant for parents/children.
|
|
This does trivial simplification of casting to the same
typesize. HOWEVER. We split casts up into whether they
cast to a dereferencable pointer type or not, and we don't
simplify pointer casts. This should mean that if we
ever want to do type-based alias analysis, we can still
avoid casted accesses.
(If we do type-based alias analysis, we'll also need to make
a union access do a cast. Which we probably should do anyway).
|
|
|