| Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. |
| DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| |
| This code is free software; you can redistribute it and/or modify it |
| under the terms of the GNU General Public License version 2 only, as |
| published by the Free Software Foundation. |
| |
| This code is distributed in the hope that it will be useful, but WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| version 2 for more details (a copy is included in the LICENSE file that |
| accompanied this code). |
| |
| You should have received a copy of the GNU General Public License version |
| 2 along with this work; if not, write to the Free Software Foundation, |
| Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| |
| Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| or visit www.oracle.com if you need additional information or have any |
| questions. |
| |
| Constant Propagation |
| -------------------- |
| Constant propagation is a code reduction technique in which values of variables |
| which are determined to be constants can be passed to expressions which use |
| these constants and can be computed at compile time. |
| |
| |
| Example: |
| |
| Consider the following segment of an original source program: |
| |
| x = 7; |
| y = 2 * x; |
| z = f (x, y); |
| |
| The value of variable x in the segment's last two lines is the constant number 7. |
| This is always true, because of the assignment to x in the segment's first line. |
| Therefore, the two instances of x can be substituted by the constant value 7 |
| (this value propagates through the next two lines). The reduced source program |
| is the following: |
| |
| x = 7; |
| y = 2 * 7; |
| z = f (7, y); |