OSDN Git Service

Implement GlobalConstifier/trivialstore.llx, and also do some
authorChris Lattner <sabre@nondot.org>
Wed, 6 Oct 2004 20:57:02 +0000 (20:57 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 6 Oct 2004 20:57:02 +0000 (20:57 +0000)
commite47ba74b07b2a6015239bcbabba09750580aeced
treea6b3d3a9ddb4cc452b682f79bfbcc1dd1afe70be
parent86900a46d4125b1102e9cc1ecd5e11689396580b
Implement GlobalConstifier/trivialstore.llx, and also do some
simplifications of the resultant program to avoid making later passes
do it all.

This allows us to constify globals that just have the same constant that
they are initialized stored into them.

Suprisingly this comes up ALL of the freaking time, dozens of times in
SPEC, 30 times in vortex alone.

For example, on 256.bzip2, it allows us to constify these two globals:

%smallMode = internal global ubyte 0             ; <ubyte*> [#uses=8]
%verbosity = internal global int 0               ; <int*> [#uses=49]

Which (with later optimizations) results in the bytecode file shrinking
from 82286 to 69686 bytes!  Lets hear it for IPO :)

For the record, it's nuking lots of "if (verbosity > 2) { do lots of stuff }"
code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16793 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/IPO/GlobalOpt.cpp