aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/unssa.c
AgeCommit message (Collapse)AuthorFilesLines
2018-07-23extract nbr_users() from unssa.cLuc Van Oostenryck1-6/+1
This small helper was used in unssa.c but is useful elsewhere too. Move it as an inline function to linearize.h and rename it to 'nbr_users()' since it is close to the existing 'has_users()'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-02-13unssa: update comment about the unneeded copiesLuc Van Oostenryck1-0/+4
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13unssa: eliminate trivial phisrc copiesLuc Van Oostenryck1-0/+22
A OP_PHISOURCE which is the only user of its operand can be trivially eliminated. For example, in: add %r6, ... ... phisrc %rt, %r6 the phisrc can safely be eliminated if no other instruction use %r6. With this patch it's rewritten as: add %rt, ... ... Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13unssa: try to avoid some OP_PHI copiesLuc Van Oostenryck1-0/+32
OP_PHI's target can interfer with it's own source swhen defined in the same basic block. Such interference can create problem like the 'swap problem' (which only exist if the phi-node are 'processed' sequentially if they're processed in parallel such problems don't exist) when phi-nodes are destructed. To avoid such problems OP_PHI are rewritten as OP_COPY. if an OP_PHI and it's OP_PHISOURCE are in different basic blocks no such interference is possible and the copy is not needed. This patch detect such situation and eliminate these unneeded copies. Note: during unSSA we're removing the OP_PHI & OP_PHISOURCE but we need to use the def-use chains between them. We must thus not use kill_instruction() in OP_PHI (this would break def-use chains and leave stray OP_PHISOURCE), it's enough to set their bb to NULL. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13unssa: simplify rewrite of OP_PHISOURCELuc Van Oostenryck1-68/+21
Using the fact that each OP_PHISOURCE is used by a single OP_PHI, it's easier to rewrite OP_PHISOURCE at the same time as their associated OP_PHI (because we have access to the new pseudo just created). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-02-13unssa: do not try to update livenessLuc Van Oostenryck1-3/+0
The unSSA step used to try to maintain the liveness info while creating the copies but this can't be done so simply (what is updated is only the liveness for the current bb while it needs to be done for all concerned bbs). If/when liveness is needed after this step, it need to be redone by calling track_pseudo_liveness(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2012-05-04unssa: track use of newly added pseudoJan Pokorný1-1/+1
Currently, it is a completely "isolated island" from backend point of view as it also lacks pseudo->def information. Signed-off-by: Jan Pokorný <pokorny_jan@seznam.cz> Signed-off-by: Christopher Li <sparse@chrisli.org>
2009-08-02unssa: track uses when replacing a phi nodeKamil Dudka1-0/+2
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>
2005-11-25[PATCH] remove old commentLuc Van Oostenryck1-3/+0
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@looxix.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-25[PATCH] unssa: update the liveness info.Luc Van Oostenryck1-0/+20
I'm not 100% sure it is done correctly, but at least it gives sensible results. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@looxix.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-22[PATCH] Rewrite of unssa().Luc Van Oostenryck1-58/+62
This is an almost total rewrite of unssa(). It work now in two passs: - first all the phi nodes are replaced by a copy of a new temporary to the same target as the phi node. - then, all the phisrc are replaced by one or several copies to the temporaries just created, one for each phi node the phisrc feed. It now works on my small tests and on the sparse source files and seems also work well against the kernel sources. There remains (at least) two problems: - I need to update the bb's needs and defines. - In some files, a few phisrc remains but they have an empty phi_users and shouldn't have any effect. Maybe they come from dead basic blocks? Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@looxix.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-21[PATCH] Add a function to translate the SSA form back to normal form.Luc Van Oostenryck1-0/+116
For now, it use a simple method but which introduces a lot more copies than necessary. Can be fixed later. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@looxix.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>