Hi, Andrew: > On Jun 30, 2021, at 2:20 PM, Andrew Pinski <pins...@gmail.com> wrote: >>>>> >>>> >>>> Then, where is the correct place for “.DEFERRED_INIT(size2,2)? >>>> >>>> The variable “size2” is a block scope variable which is declared inside >>>> the “if” condition: >>> >>> But that's obviously not how it behaves >>> During into SSA phase since we're inserting a PHI for it - and we're >>> inserting it because of the use in the DEFERED_INIT call. I suppose you >>> need to fiddle with the SSA rewrite and avoid treating the use as a use but >>> only for the purpose of inserting PHIs... >> >> Please see my other email on the new small testing case without >> -ftrivial-auto-var-init. The same issue in SSA with that testing case even >> without -ftrivial-auto-var-init. >> It looks like an existing bug to me in SSA. >> >> Let me know if I still miss anything > > Yes you missed it is unspecified what the value if the auto variable > is used uninitialized. Isn't that the point of what you are trying to > fix in the first place? > So ccp takes PHI<a_1(D), 4> and says since a_1(D) is uninitialized, > the value is 4.
I don’t think CCP did anything wrong. I suspect that SSA did something wrong when constructing PHI node for the block-scope auto variables. For the following example: 1 extern void bar (int); 2 extern int ART_INIT(int, int); 3 void foo (int a) 4 { 5 int i; 6 for (i = 0; i < a; i++) { 7 if (__extension__({int size2; 8 size2 = ART_INIT (size2, 2); 9 size2 = 4; 10 size2 > 5;})) 11 bar (a); 12 } 13 } ~ Is it legal to propagate constant 4 at line 9 to the first argument of call to ART_INIT at line 8? Given size2 is a block-scope auto-variable whose scope is from line 7 to line 10. The value of size2 should not be carried over through loop iterations from my understanding. Qing > > Thanks, > Andrew > >> >> Qing >>> >>> You might be able to construct a testcase which has a use before the real >>> init where then the optimistic CCP propagation will defeat the DEFERED_INIT >>> otherwise. >>> >>> I'd need to play with the actual patch to find a good solution to this >>> problem. >>> >>> Richard. >>> >>