Safe Passes

Which transformation passes are 'safe', meaning it does not worsens the effectiveness of a later pass or the generated code? I imagine all passes which either removes data or add attributes are included in this list, plus some simplification passes:

-adce
-argpromotion
-constmerge
-constprop
-deadargelim
-dse
-functionattrs
-globaldce
-globalopt
-gvn
-instcombine
-internalize
-ipconstprop
-ipsccp
-licm
-prune-eh
-sccp

Also, is there any redundant pass in this list (things line sccp/ipsccp)?

Hi Marco,

Which transformation passes are 'safe', meaning it does not worsens the
effectiveness of a later pass or the generated code?

are you looking for a guarantee, or just "usually makes things better"?
All standard passes usually make things better otherwise they wouldn't
be run! Consider for example GVN: this is a pass that has a big impact,
usually it is a win; but it also tends to increase register pressure so
it can make things worse (it can make things worse for other reasons too).

  I imagine all

passes which either removes data or add attributes are included in this
list,

Ha, if only things were so simple! Anyone who has implemented any optimization
has discovered that there is always some program somewhere that runs slower
because of it. For example, marking a function as readonly should be a win,
right? Yet by doing so you open up additional possibilities for other passes
which might make things worse, for example by moving code around in an
unfortunate way.

  plus some simplification passes:

-adce
-argpromotion
-constmerge
-constprop
-deadargelim
-dse
-functionattrs
-globaldce
-globalopt
-gvn
-instcombine
-internalize
-ipconstprop
-ipsccp
-licm
-prune-eh
-sccp

Most of these can make things worse.

Ciao, Duncan.