On Tue, Aug 15, 2017 at 10:43 PM, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > On Tue, Aug 15, 2017 at 1:14 PM, Luc Van Oostenryck > <luc.vanoostenryck@xxxxxxxxx> wrote: >> >> For information, the current SSA construction is very broken, >> both in simplify_one_symbol() (the main SSA construction) >> and simplify_loads() (which also creates phi-nodes). They both >> are 'load-driven' which is OK but they both put the phi-nodes >> where the load is while phi-nodes need to placed where branches >> meet. The loads are often placed in a BB following where the >> join-point. Often this *seems* to be OK but in fact is very wrong >> and create all sort of problems a bit everywhere > > I do think you're too hung up about the placement of the phi nodes. > > It may be an issue for simple models that just walk the linearized > code directly and try to turn it into code. But the original intent of > the existing phi node code was to just be as sources of the pseudo's - > the location should be largely immaterial. Yes, what I thought for a long while, But when things like try_ti_simplify_bb() come in play, with pack_basic_blocks() on top the things become *very* messy I often you can't make sense of it anymore. This has also consequences on liveness (but it can't explain the root of the problem there, i's month's I realized it was useless. > IOW, you could think of the phi nodes as being "outside" the > instruction flow entirely, and just being the definition of the pseudo > they define. They have to be placed somewhere, but the "somewhere" is > somewhat arbitrary. It's true to a certain point, after it, you need to have them placed at the confluence point. I can't explain better for now. I'll have an example tomorrow. > That said, I like your new ssa construction -independently- of that > issue - the old SSA constructor really was very ad-hoc. Look through > the git history if you don't believe me ;) Oh I believe ve *and* I have view the logs. Not directly related to that is that I really think we need to associate a ph-node's source to it's parent BB. So if you have something: | | | A B C \ | / *rx: phi, *phsra, %phisrb, %phisrcx , We really want something like: | | | A B C \ | / *rx: phi, A:*phsra, B:%phisrb, C:%phisrcx It's essential for a number of things (I suspect a number of SSA algorithm, for liveliness , writing a trivial simulator, ....) -- Luc -- 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