This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] vdefs vs DCE


So can someone educate me as to why DCE has to look at VDEFs when 
trying to determine if a statement is useful?

The reason I'm asking is doing so causes DCE to keep around a fair number
of stores which are trivially shown to be unnecessary.

Let's consider gimplification of this code

   foo ("fu", "bar", "com")

We'll gimplify that into something like

   T1 = "fu"
   T2 = "bar"
   T3 = "com"
   foo (T1, T2, T3)

[ Frankly that seems rather silly as well -- but I'll postpone that argument
  for another day. ]


Now since T1, T2 and T3 are used as arguments, we consider the memory
they point to as modified by the call itself and we consider *T1, *T2 and *T3
as aliasing global memory.

That in turn causes us to hang a bunch of VDEFs on the assignments to T1, T2
and T3.

Anyway, we go into SSA form and we have:

   T1 = "fu"
   T2 = "bar"
   T3 = "com"
   foo ("fu", "bar", "com")

[ See why I said the gimplification was rather silly? :-) ]

T1, T2 and T3 are never used again.  But because we've got those annoying
VDEFs we consider each of those statements are useful and thus they are not
removed.

So you might legitimately ask is this important.  Consider that this is
going to happen anytime we pass strings as arguments to functions!  Or
that every call to abort within gcc itself will result in two of these
stores that we can't eliminate due to their VDEFS (look at how abort
expands into fancy_abort)...


Jeff








Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]