On Mon, Nov 5, 2012 at 5:32 AM, Martin Jambor <mjam...@suse.cz> wrote: > Hi, > > On Sun, Nov 04, 2012 at 09:32:48PM -0800, Handong Ye wrote: >> On Sun, Nov 4, 2012 at 2:13 PM, Martin Jambor <mjam...@suse.cz> wrote: >> > On Sat, Nov 03, 2012 at 09:01:53AM +0000, Yangyueming wrote: >> >> Hi, all >> >> > > ... > >> >> >> >> But when I do the test for a case with a little change, it is failed to >> >> generate MAX_EXPR in phiopt1. >> >> The failed case2 : >> >> int foo(short a ,short b) >> >> { >> >> int c; >> >> if (a < b) >> >> a = b; >> >> >> >> c = *(int *)&a; >> > >> > ehm, and just what do you expect the result of the above line to be? >> > >> >> return c; >> >> } >> >> > > ... > >> > >> > Nevertheless, I can tell why there is no phi node for a. a has its >> > address taken and therefore it is not in SSA form (as clearly visible >> > in the first statements in bb 2 and bb 3). Thus, no PHI nodes for a. >> > >> >> Why 'a' has no SSA form if it's address taken? >> I didn't check the code, but I guess it may because 'a' value is not >> directly used. > > Because address taken variables might be used and defined indirectly > through a memory load/store, often in ways that are practically > impossible to detect.
Isn't memory ssa supposed to handle such issues? ... Seems I need do some research ... Thanks Handong > > Martin > > >> >> >> Dump of phifail.c.027t.esra: >> >> foo (short int a, short int b) >> >> { >> >> int c; >> >> short int a$0; >> >> >> >> <bb 2>: >> >> a$0_1 = a; >> >> if (a$0_1 < b_2(D)) >> >> goto <bb 3>; >> >> else >> >> goto <bb 4>; >> >> >> >> <bb 3>: >> >> a = b_2(D); >> >> >> >> <bb 4>: >> >> c_4 = MEM[(int *)&a]; >> >> c_5 = c_4; >> >> return c_5; >> >> >> >> } >> >> >> >> Why it is failed and if there's a way to make it work? >> > >> > I believe that the modified input has undefined semantics (sorry, I >> > don't have time to verify this in the standard) and so no, there is no >> > way to make it work. >> > >> > Martin >> >> >> >> -- >> Thanks. >> Handong -- Thanks. Handong