1 /*****************************************************************************/
5 /* Optimize compares */
9 /* (C) 2001 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
46 /*****************************************************************************/
47 /* Remove calls to the bool transformer subroutines */
48 /*****************************************************************************/
52 unsigned OptBoolTrans (CodeSeg* S);
53 /* Try to remove the call to boolean transformer routines where the call is
59 /*****************************************************************************/
60 /* Optimizations for compares */
61 /*****************************************************************************/
65 unsigned OptCmp1 (CodeSeg* S);
66 /* Search for the sequence
78 unsigned OptCmp2 (CodeSeg* S);
92 unsigned OptCmp3 (CodeSeg* S);
102 * If a is zero, we may remove the compare. If a and b are both zero, we may
103 * replace it by the sequence
109 * L1 may be either the label at the branch instruction, or the target label
110 * of this instruction.
113 unsigned OptCmp4 (CodeSeg* S);
114 /* Optimize compares of local variables:
127 unsigned OptCmp5 (CodeSeg* S);
128 /* Search for calls to compare subroutines followed by a conditional branch
129 * and replace them by cheaper versions, since the branch means that the
130 * boolean value returned by these routines is not needed (we may also check
131 * that explicitly, but for the current code generator it is always true).
134 unsigned OptCmp6 (CodeSeg* S);
135 /* Search for a sequence ldx/txa/branch and remove the txa if A is not
139 unsigned OptCmp7 (CodeSeg* S);
140 /* Check for register compares where the contents of the register and therefore
141 * the result of the compare is known.
146 /* End of coptcmp.h */