1 /*-------------------------------------------------------------------------
2 SDCCcse.c - source file for Common Subexpressions and other utility
4 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 In other words, you are welcome to use, share and improve this program.
21 You are forbidden to forbid anyone else to use, share and improve
22 what you give them. Help stamp out software-hoarding!
23 -------------------------------------------------------------------------*/
28 /*-----------------------------------------------------------------*/
29 /* newCseDef - new cseDef */
30 /*-----------------------------------------------------------------*/
32 newCseDef (operand * sym, iCode * ic)
37 cdp = Safe_alloc (sizeof (cseDef));
48 /*-----------------------------------------------------------------*/
49 /* int isCseDefEqual - two definitions are equal */
50 /*-----------------------------------------------------------------*/
52 isCseDefEqual (void *vsrc, void *vdest)
60 return (src->key == dest->key &&
61 src->diCode == dest->diCode);
65 /*-----------------------------------------------------------------*/
66 /* pcseDef - in the cseDef */
67 /*-----------------------------------------------------------------*/
69 pcseDef (void *item, va_list ap)
77 fprintf (stdout, "**null op**");
78 printOperand (cdp->sym, stdout);
79 icTab = getTableEntry (cdp->diCode->op);
80 icTab->iCodePrint (stdout, cdp->diCode, icTab->printName);
84 /*-----------------------------------------------------------------*/
85 /* replaceAllSymBySym - replaces all operands by operand in an */
86 /* instruction chain */
87 /*-----------------------------------------------------------------*/
89 replaceAllSymBySym (iCode * ic, operand * from, operand * to, bitVect ** ndpset)
93 for (lic = ic; lic; lic = lic->next)
97 /* do the special cases first */
101 IC_COND (lic)->key == from->key)
104 bitVectUnSetBit (OP_USES (from), lic->key);
105 OP_USES (to) = bitVectSetBit (OP_USES (to), lic->key);
106 siaddr = IC_COND (lic)->isaddr;
107 IC_COND (lic) = operandFromOperand (to);
108 IC_COND (lic)->isaddr = siaddr;
114 if (lic->op == JUMPTABLE)
117 IC_JTCOND (lic)->key == from->key)
120 bitVectUnSetBit (OP_USES (from), lic->key);
121 OP_USES (to) = bitVectSetBit (OP_USES (to), lic->key);
122 siaddr = IC_COND (lic)->isaddr;
123 IC_JTCOND (lic) = operandFromOperand (to);
124 IC_JTCOND (lic)->isaddr = siaddr;
130 if (IC_RESULT (lic) && IC_RESULT (lic)->key == from->key)
132 /* maintain du chains */
133 if (POINTER_SET (lic))
135 bitVectUnSetBit (OP_USES (from), lic->key);
136 OP_USES (to) = bitVectSetBit (OP_USES (to), lic->key);
138 /* also check if the "from" was in the non-dominating
139 pointer sets and replace it with "to" in the bitVector */
140 if (bitVectBitValue (*ndpset, from->key))
142 bitVectUnSetBit (*ndpset, from->key);
143 bitVectSetBit (*ndpset, to->key);
149 bitVectUnSetBit (OP_DEFS (from), lic->key);
150 OP_DEFS (to) = bitVectSetBit (OP_DEFS (to), lic->key);
152 siaddr = IC_RESULT (lic)->isaddr;
153 IC_RESULT (lic) = operandFromOperand (to);
154 IC_RESULT (lic)->isaddr = siaddr;
158 IC_RIGHT (lic) && IC_RIGHT (lic)->key == from->key)
160 bitVectUnSetBit (OP_USES (from), lic->key);
161 OP_USES (to) = bitVectSetBit (OP_USES (to), lic->key);
162 siaddr = IC_RIGHT (lic)->isaddr;
163 IC_RIGHT (lic) = operandFromOperand (to);
164 IC_RIGHT (lic)->isaddr = siaddr;
168 IC_LEFT (lic) && IC_LEFT (lic)->key == from->key)
170 bitVectUnSetBit (OP_USES (from), lic->key);
171 OP_USES (to) = bitVectSetBit (OP_USES (to), lic->key);
172 siaddr = IC_LEFT (lic)->isaddr;
173 IC_LEFT (lic) = operandFromOperand (to);
174 IC_LEFT (lic)->isaddr = siaddr;
179 /*-----------------------------------------------------------------*/
180 /* iCodeKeyIs - if the icode keys match then return 1 */
181 /*-----------------------------------------------------------------*/
182 DEFSETFUNC (iCodeKeyIs)
187 if (cdp->diCode->key == key)
193 /*-----------------------------------------------------------------*/
194 /* removeFromInExprs - removes an icode from inexpressions */
195 /*-----------------------------------------------------------------*/
196 DEFSETFUNC (removeFromInExprs)
200 V_ARG (operand *, from);
201 V_ARG (operand *, to);
202 V_ARG (eBBlock *, cbp);
208 deleteItemIf (&ebp->inExprs, iCodeKeyIs, ic->key);
209 if (ebp != cbp && !bitVectBitValue (cbp->domVect, ebp->bbnum))
210 replaceAllSymBySym (ebp->sch, from, to, &ebp->ndompset);
212 applyToSet (ebp->succList, removeFromInExprs, ic, from, to, cbp);
216 /*-----------------------------------------------------------------*/
217 /* isGlobalInNearSpace - return TRUE if valriable is a globalin data */
218 /*-----------------------------------------------------------------*/
220 isGlobalInNearSpace (operand * op)
222 sym_link *type = getSpec (operandType (op));
223 /* this is 8051 specific: optimization
224 suggested by Jean-Louis VERN, with 8051s we have no
225 advantage of putting variables in near space into
227 if (isOperandGlobal (op) && !IN_FARSPACE (SPEC_OCLS (type)) &&
228 IN_DIRSPACE (SPEC_OCLS (type)))
234 /*-----------------------------------------------------------------*/
235 /* findCheaperOp - cseBBlock support routine, will check to see if */
236 /* we have a operand previously defined */
237 /*-----------------------------------------------------------------*/
238 DEFSETFUNC (findCheaperOp)
241 V_ARG (operand *, cop);
242 V_ARG (operand **, opp);
244 /* if we have already found it */
248 /* not found it yet check if this is the one */
249 /* and this is not the defining one */
250 if (cop->key == cdp->key)
253 /* do a special check this will help in */
254 /* constant propagation & dead code elim */
255 /* for assignments only */
256 if (cdp->diCode->op == '=') {
257 /* if the result is volatile then return result */
258 if (IS_OP_VOLATILE (IC_RESULT (cdp->diCode)))
259 *opp = IC_RESULT (cdp->diCode);
261 /* if this is a straight assignment and
262 left is a temp then prefer the temporary to the
264 if (!POINTER_SET (cdp->diCode) &&
265 IS_ITEMP (IC_RESULT (cdp->diCode)) &&
266 IS_TRUE_SYMOP (IC_RIGHT (cdp->diCode)))
267 *opp = IC_RESULT (cdp->diCode);
269 /* if straight assignement && and both
270 are temps then prefer the one that
271 will not need extra space to spil, also
272 take into consideration if right side
273 an induction variable
275 if (!POINTER_SET (cdp->diCode) &&
276 IS_ITEMP (IC_RESULT (cdp->diCode)) &&
277 IS_ITEMP (IC_RIGHT (cdp->diCode)) &&
278 !OP_SYMBOL (IC_RIGHT (cdp->diCode))->isind &&
279 ((!SPIL_LOC (IC_RIGHT (cdp->diCode)) &&
280 SPIL_LOC (IC_RESULT (cdp->diCode))) ||
281 (SPIL_LOC (IC_RESULT (cdp->diCode)) &&
282 SPIL_LOC (IC_RESULT (cdp->diCode)) ==
283 SPIL_LOC (IC_RIGHT (cdp->diCode)))))
284 *opp = IC_RESULT (cdp->diCode);
286 *opp = IC_RIGHT (cdp->diCode);
290 *opp = IC_RESULT (cdp->diCode);
293 /* if this is an assign to a temp. then check
294 if the right side is this then return this */
295 if (IS_TRUE_SYMOP (cop) &&
296 cdp->diCode->op == '=' &&
297 !POINTER_SET (cdp->diCode) &&
298 cop->key == IC_RIGHT (cdp->diCode)->key &&
299 !isGlobalInNearSpace (IC_RIGHT (cdp->diCode)) &&
300 IS_ITEMP (IC_RESULT (cdp->diCode)))
301 *opp = IC_RESULT (cdp->diCode);
304 (isOperandLiteral(*opp) ||
305 (SPEC_USIGN(operandType (cop))==SPEC_USIGN(operandType (*opp)) &&
306 (SPEC_LONG(operandType (cop))==SPEC_LONG(operandType (*opp))))))
309 if ((isGlobalInNearSpace (cop) &&
310 !isOperandLiteral (*opp)) ||
311 isOperandVolatile (*opp, FALSE)
318 if (cop->key == (*opp)->key)
324 if ((*opp)->isaddr != cop->isaddr && IS_ITEMP (cop))
326 *opp = operandFromOperand (*opp);
327 (*opp)->isaddr = cop->isaddr;
337 /*-----------------------------------------------------------------*/
338 /* findPointerSet - finds the right side of a pointer set op */
339 /*-----------------------------------------------------------------*/
340 DEFSETFUNC (findPointerSet)
343 V_ARG (operand *, op);
344 V_ARG (operand **, opp);
345 V_ARG (operand *, rop);
347 if (POINTER_SET (cdp->diCode) &&
348 IC_RESULT (cdp->diCode)->key == op->key &&
349 !isOperandVolatile (IC_RESULT (cdp->diCode), TRUE) &&
350 !isOperandVolatile (IC_RIGHT (cdp->diCode), TRUE) &&
351 getSize (operandType (IC_RIGHT (cdp->diCode))) ==
352 getSize (operandType (rop)))
354 *opp = IC_RIGHT (cdp->diCode);
361 /*-----------------------------------------------------------------*/
362 /* findPrevIc - cseBBlock support function will return the iCode */
363 /* which matches the current one */
364 /*-----------------------------------------------------------------*/
365 DEFSETFUNC (findPrevIc)
369 V_ARG (iCode **, icp);
371 /* if already found */
375 /* if the iCodes are the same */
376 if (isiCodeEqual (ic, cdp->diCode) &&
377 isOperandEqual (cdp->sym, IC_RESULT (cdp->diCode)))
383 /* if iCodes are not the same */
384 /* see the operands maybe interchanged */
385 if (ic->op == cdp->diCode->op &&
386 (ic->op == '+' || ic->op == '*') &&
387 isOperandEqual (IC_LEFT (ic), IC_RIGHT (cdp->diCode)) &&
388 isOperandEqual (IC_RIGHT (ic), IC_LEFT (cdp->diCode)))
397 /*-----------------------------------------------------------------*/
398 /* ifDefGlobal - if definition is global */
399 /*-----------------------------------------------------------------*/
400 DEFSETFUNC (ifDefGlobal)
404 return (isOperandGlobal (cdp->sym));
407 /*-----------------------------------------------------------------*/
408 /* ifAnyGetPointer - if get pointer icode */
409 /*-----------------------------------------------------------------*/
410 DEFSETFUNC (ifAnyGetPointer)
414 if (cdp->diCode && POINTER_GET (cdp->diCode))
419 /*-----------------------------------------------------------------*/
420 /* ifOperandsHave - if any of the operand are the same as this */
421 /*-----------------------------------------------------------------*/
422 DEFSETFUNC (ifOperandsHave)
425 V_ARG (operand *, op);
428 if (IC_LEFT (cdp->diCode) &&
429 IS_SYMOP (IC_LEFT (cdp->diCode)) &&
430 IC_LEFT (cdp->diCode)->key == op->key)
433 if (IC_RIGHT (cdp->diCode) &&
434 IS_SYMOP (IC_RIGHT (cdp->diCode)) &&
435 IC_RIGHT (cdp->diCode)->key == op->key)
438 /* or if any of the operands are volatile */
439 if (IC_LEFT (cdp->diCode) &&
440 IS_OP_VOLATILE (IC_LEFT (cdp->diCode)))
443 if (IC_RIGHT (cdp->diCode) &&
444 IS_OP_VOLATILE (IC_RIGHT (cdp->diCode)))
448 if (IC_RESULT (cdp->diCode) &&
449 IS_OP_VOLATILE (IC_RESULT (cdp->diCode)))
455 /*-----------------------------------------------------------------*/
456 /* ifDefSymIs - if a definition is found in the set */
457 /*-----------------------------------------------------------------*/
459 ifDefSymIs (set * cseSet, operand * sym)
464 if (!sym || !IS_SYMOP (sym))
466 for (sl = cseSet; sl; sl = sl->next)
469 if (loop->sym->key == sym->key)
476 /*-----------------------------------------------------------------*/
477 /* ifDefSymIsX - will return 1 if the symbols match */
478 /*-----------------------------------------------------------------*/
479 DEFSETFUNC (ifDefSymIsX)
482 V_ARG (operand *, op);
485 return cdp->sym->key == op->key;
487 return (isOperandEqual (cdp->sym, op));
492 /*-----------------------------------------------------------------*/
493 /* ifDiCodeIs - returns truw if diCode is same */
494 /*-----------------------------------------------------------------*/
496 ifDiCodeIs (set * cseSet, iCode * ic)
504 for (sl = cseSet; sl; sl = sl->next)
507 if (loop->diCode == ic)
514 /*-----------------------------------------------------------------*/
515 /* ifPointerGet - returns true if the icode is pointer get sym */
516 /*-----------------------------------------------------------------*/
517 DEFSETFUNC (ifPointerGet)
520 V_ARG (operand *, op);
521 iCode *dic = cdp->diCode;
522 operand *left = IC_LEFT (cdp->diCode);
524 if (POINTER_GET (dic) && left->key == op->key)
530 /*-----------------------------------------------------------------*/
531 /* ifPointerSet - returns true if the icode is pointer set sym */
532 /*-----------------------------------------------------------------*/
533 DEFSETFUNC (ifPointerSet)
536 V_ARG (operand *, op);
538 if (POINTER_SET (cdp->diCode) &&
539 IC_RESULT (cdp->diCode)->key == op->key)
545 /*-----------------------------------------------------------------*/
546 /* ifDiCodeIsX - will return 1 if the symbols match */
547 /*-----------------------------------------------------------------*/
548 DEFSETFUNC (ifDiCodeIsX)
553 return cdp->diCode == ic;
557 /*-----------------------------------------------------------------*/
558 /* algebraicOpts - does some algebraic optimizations */
559 /*-----------------------------------------------------------------*/
561 algebraicOpts (iCode * ic)
563 /* we don't deal with the following iCodes
574 /* if both operands present & ! IFX */
575 /* then if they are both literal we */
576 /* perform the operation right now */
577 if (IC_RESULT (ic) &&
580 IS_OP_LITERAL (IC_LEFT (ic)) &&
581 IS_OP_LITERAL (IC_RIGHT (ic)))
584 IC_RIGHT (ic) = operandOperation (IC_LEFT (ic),
587 operandType (IC_RESULT (ic)));
590 SET_RESULT_RIGHT (ic);
594 /* if not ifx & only one operand present */
595 if (IC_RESULT (ic) &&
597 IS_OP_LITERAL (IC_LEFT (ic)) &&
601 IC_RIGHT (ic) = operandOperation (IC_LEFT (ic),
604 operandType (IC_RESULT (ic)));
607 SET_RESULT_RIGHT (ic);
612 /* a special case : or in short a kludgy solution will think
613 about a better solution over a glass of wine someday */
614 if (ic->op == GET_VALUE_AT_ADDRESS)
617 if (IS_ITEMP (IC_RESULT (ic)) &&
618 IS_TRUE_SYMOP (IC_LEFT (ic)))
622 IC_RIGHT (ic) = operandFromOperand (IC_LEFT (ic));
623 IC_RIGHT (ic)->isaddr = 0;
625 IC_RESULT (ic) = operandFromOperand (IC_RESULT (ic));
626 IC_RESULT (ic)->isaddr = 0;
627 setOperandType (IC_RESULT (ic), operandType (IC_RIGHT (ic)));
631 if (IS_ITEMP (IC_LEFT (ic)) &&
632 IS_ITEMP (IC_RESULT (ic)) &&
633 /* !OP_SYMBOL(IC_RESULT(ic))->isreqv && */
634 /* !OP_SYMBOL(IC_LEFT(ic))->isreqv && */
635 !IC_LEFT (ic)->isaddr)
638 IC_RIGHT (ic) = operandFromOperand (IC_LEFT (ic));
639 IC_RIGHT (ic)->isaddr = 0;
640 IC_RESULT (ic) = operandFromOperand (IC_RESULT (ic));
641 IC_RESULT (ic)->isaddr = 0;
649 /* depending on the operation */
653 /* if adding the same thing change to left shift by 1 */
654 if (IC_LEFT (ic)->key == IC_RIGHT (ic)->key &&
655 !IS_FLOAT (operandType (IC_RESULT (ic))))
658 IC_RIGHT (ic) = operandFromLit (1);
661 /* if addition then check if one of them is a zero */
662 /* if yes turn it into assignmnt */
663 if (IS_OP_LITERAL (IC_LEFT (ic)) &&
664 operandLitValue (IC_LEFT (ic)) == 0.0)
669 SET_ISADDR (IC_RESULT (ic), 0);
670 SET_ISADDR (IC_RIGHT (ic), 0);
673 if (IS_OP_LITERAL (IC_RIGHT (ic)) &&
674 operandLitValue (IC_RIGHT (ic)) == 0.0)
678 IC_RIGHT (ic) = IC_LEFT (ic);
680 SET_ISADDR (IC_RIGHT (ic), 0);
681 SET_ISADDR (IC_RESULT (ic), 0);
686 /* if subtracting the the same thing then zero */
687 if (IC_LEFT (ic)->key == IC_RIGHT (ic)->key)
690 IC_RIGHT (ic) = operandFromLit (0);
692 IC_RESULT (ic) = operandFromOperand (IC_RESULT (ic));
693 IC_RESULT (ic)->isaddr = 0;
697 /* if subtraction then check if one of the operand */
698 /* is zero then depending on which operand change */
699 /* to assignment or unary minus */
700 if (IS_OP_LITERAL (IC_RIGHT (ic)) &&
701 operandLitValue (IC_RIGHT (ic)) == 0.0)
703 /* right size zero change to assignment */
705 IC_RIGHT (ic) = IC_LEFT (ic);
707 SET_ISADDR (IC_RIGHT (ic), 0);
708 SET_ISADDR (IC_RESULT (ic), 0);
711 if (IS_OP_LITERAL (IC_LEFT (ic)) &&
712 operandLitValue (IC_LEFT (ic)) == 0.0)
714 /* left zero turn into an unary minus */
716 IC_LEFT (ic) = IC_RIGHT (ic);
717 IC_RIGHT (ic) = NULL;
721 /* if multiplication then check if either of */
722 /* them is zero then the result is zero */
723 /* if either of them is one then result is */
726 if (IS_OP_LITERAL (IC_LEFT (ic)))
729 if (operandLitValue (IC_LEFT (ic)) == 0.0)
732 IC_RIGHT (ic) = IC_LEFT (ic);
734 SET_RESULT_RIGHT (ic);
737 if (operandLitValue (IC_LEFT (ic)) == 1.0)
741 SET_RESULT_RIGHT (ic);
746 if (IS_OP_LITERAL (IC_RIGHT (ic)))
749 if (operandLitValue (IC_RIGHT (ic)) == 0.0)
753 SET_RESULT_RIGHT (ic);
757 if (operandLitValue (IC_RIGHT (ic)) == 1.0)
760 IC_RIGHT (ic) = IC_LEFT (ic);
762 SET_RESULT_RIGHT (ic);
768 /* if division by self then 1 */
769 if (IC_LEFT (ic)->key == IC_RIGHT (ic)->key)
772 IC_RIGHT (ic) = operandFromLit (1);
774 IC_RESULT (ic) = operandFromOperand (IC_RESULT (ic));
775 IC_RESULT (ic)->isaddr = 0;
777 /* if this is a division then check if right */
778 /* is one then change it to an assignment */
779 if (IS_OP_LITERAL (IC_RIGHT (ic)) &&
780 operandLitValue (IC_RIGHT (ic)) == 1.0)
784 IC_RIGHT (ic) = IC_LEFT (ic);
786 SET_RESULT_RIGHT (ic);
790 /* if both are the same for an comparison operators */
794 if (isOperandEqual (IC_LEFT (ic), IC_RIGHT (ic)))
797 IC_RIGHT (ic) = operandFromLit (1);
799 SET_RESULT_RIGHT (ic);
805 if (isOperandEqual (IC_LEFT (ic), IC_RIGHT (ic)))
808 IC_RIGHT (ic) = operandFromLit (0);
810 SET_RESULT_RIGHT (ic);
815 sym_link *otype = operandType(IC_RIGHT(ic));
816 sym_link *ctype = operandType(IC_LEFT(ic));
817 /* if this is a cast of a literal value */
818 if (IS_OP_LITERAL (IC_RIGHT (ic)) &&
819 !(IS_GENPTR(ctype) && (IS_PTR(otype) && !IS_GENPTR(otype)))) {
822 operandFromValue (valCastLiteral (operandType (IC_LEFT (ic)),
823 operandLitValue (IC_RIGHT (ic))));
825 SET_ISADDR (IC_RESULT (ic), 0);
827 /* if casting to the same */
828 if (compareType (operandType (IC_RESULT (ic)),
829 operandType (IC_RIGHT (ic))) == 1) {
832 SET_ISADDR (IC_RESULT (ic), 0);
837 if (IS_OP_LITERAL (IC_LEFT (ic)))
841 (operandLitValue (IC_LEFT (ic)) == 0 ?
842 operandFromLit (1) : operandFromLit (0));
844 SET_ISADDR (IC_RESULT (ic), 0);
850 #define OTHERS_PARM(s) (s->_isparm && !s->ismyparm)
851 /*-----------------------------------------------------------------*/
852 /* updateSpillLocation - keeps track of register spill location */
853 /*-----------------------------------------------------------------*/
855 updateSpillLocation (iCode * ic, int induction)
860 if (POINTER_SET (ic))
866 /* for the form true_symbol := iTempNN */
867 if (ASSIGN_ITEMP_TO_SYM (ic) &&
868 !SPIL_LOC (IC_RIGHT (ic))) {
870 setype = getSpec (operandType (IC_RESULT (ic)));
872 if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc &&
873 !IS_VOLATILE (setype) &&
874 !IN_FARSPACE (SPEC_OCLS (setype)) &&
875 !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic))))
877 SPIL_LOC (IC_RIGHT (ic)) =
878 IC_RESULT (ic)->operand.symOperand;
881 if (ASSIGN_ITEMP_TO_ITEMP (ic)) {
883 if (!SPIL_LOC (IC_RIGHT (ic)) &&
884 !bitVectBitsInCommon (OP_DEFS (IC_RIGHT (ic)), OP_USES (IC_RESULT (ic))) &&
885 OP_SYMBOL (IC_RESULT (ic))->isreqv) {
887 setype = getSpec (operandType (IC_RESULT (ic)));
889 if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc &&
890 !IS_VOLATILE (setype) &&
891 !IN_FARSPACE (SPEC_OCLS (setype)) &&
892 !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic))))
894 SPIL_LOC (IC_RIGHT (ic)) =
895 SPIL_LOC (IC_RESULT (ic));
897 /* special case for inductions */
899 OP_SYMBOL(IC_RIGHT(ic))->isreqv &&
900 !OP_SYMBOL(IC_RESULT (ic))->noSpilLoc &&
901 !SPIL_LOC(IC_RESULT(ic))) {
902 SPIL_LOC (IC_RESULT (ic)) = SPIL_LOC (IC_RIGHT (ic));
906 /*-----------------------------------------------------------------*/
907 /* setUsesDef - sets the uses def bitvector for a given operand */
908 /*-----------------------------------------------------------------*/
910 setUsesDefs (operand * op, bitVect * bdefs,
911 bitVect * idefs, bitVect ** oud)
913 /* compute the definitions alive at this point */
914 bitVect *adefs = bitVectUnion (bdefs, idefs);
916 /* of these definitions find the ones that are */
917 /* for this operand */
918 adefs = bitVectIntersect (adefs, OP_DEFS (op));
920 /* these are the definitions that this operand can use */
921 op->usesDefs = adefs;
923 /* the out defs is an union */
924 *oud = bitVectUnion (*oud, adefs);
927 /*-----------------------------------------------------------------*/
928 /* unsetDefsAndUses - clear this operation for the operands */
929 /*-----------------------------------------------------------------*/
931 unsetDefsAndUses (iCode * ic)
933 if (ic->op == JUMPTABLE)
936 /* take away this definition from the def chain of the */
937 /* result & take away from use set of the operands */
940 /* turn off def set */
941 if (IS_SYMOP (IC_RESULT (ic)))
943 if (!POINTER_SET (ic))
944 bitVectUnSetBit (OP_DEFS (IC_RESULT (ic)), ic->key);
946 bitVectUnSetBit (OP_USES (IC_RESULT (ic)), ic->key);
948 /* turn off the useSet for the operands */
949 if (IS_SYMOP (IC_LEFT (ic)))
950 bitVectUnSetBit (OP_USES (IC_LEFT (ic)), ic->key);
952 if (IS_SYMOP (IC_RIGHT (ic)))
953 bitVectUnSetBit (OP_USES (IC_RIGHT (ic)), ic->key);
956 /* must be ifx turn off the use */ if (IS_SYMOP (IC_COND (ic)))
957 bitVectUnSetBit (OP_USES (IC_COND (ic)), ic->key);
960 /*-----------------------------------------------------------------*/
961 /* ifxOptimize - changes ifx conditions if it can */
962 /*-----------------------------------------------------------------*/
964 ifxOptimize (iCode * ic, set * cseSet,
966 eBBlock * ebb, int *change,
967 eBBlock ** ebbs, int count)
972 /* if the condition can be replaced */
976 applyToSetFTrue (cseSet, findCheaperOp, IC_COND (ic), &pdop);
984 /* if the conditional is a literal then */
985 if (IS_OP_LITERAL (IC_COND (ic)))
988 if ((operandLitValue (IC_COND (ic)) != 0.0) && IC_TRUE (ic))
991 /* change to a goto */
993 IC_LABEL (ic) = IC_TRUE (ic);
1000 if (!operandLitValue (IC_COND (ic)) && IC_FALSE (ic))
1003 IC_LABEL (ic) = IC_FALSE (ic);
1009 /* then kill this if condition */
1010 remiCodeFromeBBlock (ebb, ic);
1014 /* now we need to recompute the control flow */
1015 /* since the control flow has changed */
1016 /* this is very expensive but it does not happen */
1017 /* too often, if it does happen then the user pays */
1019 computeControlFlow (ebbs, count, 1);
1020 if (!options.lessPedantic) {
1021 werror (W_CONTROL_FLOW, ic->filename, ic->lineno);
1026 /* if there is only one successor and that successor
1027 is the same one we are conditionally going to then
1028 we can remove this conditional statement */
1029 label = (IC_TRUE (ic) ? IC_TRUE (ic) : IC_FALSE (ic));
1030 if (elementsInSet (ebb->succList) == 1 &&
1031 isinSet (ebb->succList, eBBWithEntryLabel (ebbs, label, count)))
1034 remiCodeFromeBBlock (ebb, ic);
1035 computeControlFlow (ebbs, count, 1);
1036 if (!options.lessPedantic) {
1037 werror (W_CONTROL_FLOW, ic->filename, ic->lineno);
1043 /* if it remains an IFX the update the use Set */
1044 OP_USES (IC_COND (ic)) = bitVectSetBit (OP_USES (IC_COND (ic)), ic->key);
1045 setUsesDefs (IC_COND (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs);
1049 /*-----------------------------------------------------------------*/
1050 /* diCodeForSym - finds the definiting instruction for a symbol */
1051 /*-----------------------------------------------------------------*/
1052 DEFSETFUNC (diCodeForSym)
1055 V_ARG (operand *, sym);
1056 V_ARG (iCode **, dic);
1058 /* if already found */
1062 /* if not if this is the defining iCode */
1063 if (sym->key == cdp->key)
1072 /*-----------------------------------------------------------------*/
1073 /* constFold - does some constant folding */
1074 /*-----------------------------------------------------------------*/
1076 constFold (iCode * ic, set * cseSet)
1080 /* this routine will change
1086 /* deal with only + & - */
1087 if (ic->op != '+' &&
1091 /* this check is a hueristic to prevent live ranges
1092 from becoming too long */
1093 if (IS_PTR (operandType (IC_RESULT (ic))))
1096 /* check if operation with a literal */
1097 if (!IS_OP_LITERAL (IC_RIGHT (ic)))
1100 /* check if we can find a definition for the
1102 if (!(applyToSet (cseSet, diCodeForSym, IC_LEFT (ic), &dic)))
1105 /* check that this is also a +/- */
1106 if (dic->op != '+' && dic->op != '-')
1109 /* with a literal */
1110 if (!IS_OP_LITERAL (IC_RIGHT (dic)))
1113 /* find the definition of the left operand
1114 of dic.then check if this defined with a
1115 get_pointer return 0 if the pointer size is
1116 less than 2 (MCS51 specific) */
1117 if (!(applyToSet (cseSet, diCodeForSym, IC_LEFT (dic), &ldic)))
1120 if (POINTER_GET (ldic) && getSize (operandType (IC_LEFT (ldic))) <= 1)
1123 /* it is if the operations are the same */
1124 /* the literal parts need to be added */
1125 IC_LEFT (ic) = operandFromOperand (IC_LEFT (dic));
1126 if (ic->op == dic->op)
1127 IC_RIGHT (ic) = operandFromLit (operandLitValue (IC_RIGHT (ic)) +
1128 operandLitValue (IC_RIGHT (dic)));
1130 IC_RIGHT (ic) = operandFromLit (operandLitValue (IC_RIGHT (ic)) -
1131 operandLitValue (IC_RIGHT (dic)));
1133 if (IS_ITEMP (IC_RESULT (ic)))
1135 SPIL_LOC (IC_RESULT (ic)) = NULL;
1136 OP_SYMBOL(IC_RESULT (ic))->noSpilLoc = 1;
1143 /*-----------------------------------------------------------------*/
1144 /* deleteGetPointers - called when a pointer is passed as parm */
1145 /* will delete from cseSet all get pointers computed from this */
1146 /* pointer. A simple ifOperandsHave is not good enough here */
1147 /*-----------------------------------------------------------------*/
1149 deleteGetPointers (set ** cseSet, set ** pss, operand * op, eBBlock * ebb)
1151 set *compItems = NULL;
1156 if (!*cseSet && !*pss)
1159 /* first find all items computed from this operand .
1160 This done fairly simply go thru the list and find
1161 those that are computed by arthimetic with this
1163 for (cdp = setFirstItem (*cseSet); cdp; cdp = setNextItem (*cseSet))
1165 if (IS_ARITHMETIC_OP (cdp->diCode))
1167 if (isOperandEqual (IC_LEFT (cdp->diCode), op) ||
1168 isOperandEqual (IC_RIGHT (cdp->diCode), op))
1170 /* save it in our list of items */
1171 addSet (&compItems, IC_RESULT (cdp->diCode));
1173 /* also check for those computed from our computed
1174 list . This will take care of situations like
1175 iTemp1 = iTemp0 + 8;
1176 iTemp2 = iTemp1 + 8; */
1177 if (isinSetWith (compItems, (void*)IC_LEFT (cdp->diCode),
1178 (insetwithFunc)isOperandEqual) ||
1179 isinSetWith (compItems, (void*)IC_RIGHT (cdp->diCode),
1180 (insetwithFunc)isOperandEqual))
1182 addSet (&compItems, IC_RESULT (cdp->diCode));
1187 /* now delete all pointer gets with this op */
1188 deleteItemIf (cseSet, ifPointerGet, op);
1189 deleteItemIf (pss, ifPointerSet, op);
1191 /* set the bit vector used by dataFlow computation later */
1192 ebb->ptrsSet = bitVectSetBit (ebb->ptrsSet, op->key);
1193 /* now for the computed items */
1194 for (cop = setFirstItem (compItems); cop; cop = setNextItem (compItems))
1196 ebb->ptrsSet = bitVectSetBit (ebb->ptrsSet, cop->key);
1197 deleteItemIf (cseSet, ifPointerGet, cop);
1198 deleteItemIf (pss, ifPointerSet, cop);
1202 /*-----------------------------------------------------------------*/
1203 /* delGetPointerSucc - delete get pointer from inExprs of succ with */
1204 /* dfnum > supplied */
1205 /*-----------------------------------------------------------------*/
1206 DEFSETFUNC (delGetPointerSucc)
1208 eBBlock *ebp = item;
1209 V_ARG (operand *, op);
1216 if (ebp->dfnum > dfnum)
1218 deleteItemIf (&ebp->inExprs, ifPointerGet, op);
1221 return applyToSet (ebp->succList, delGetPointerSucc, op, dfnum);
1224 /*-----------------------------------------------------------------*/
1225 /* fixUpTypes - KLUGE HACK fixup a lowering problem */
1226 /*-----------------------------------------------------------------*/
1228 fixUpTypes (iCode * ic)
1230 sym_link *t1 = operandType (IC_LEFT (ic)), *t2;
1232 /* if (TARGET_IS_DS390) */
1233 if (options.model == MODEL_FLAT24)
1239 /* for pointer_gets if the types of result & left r the
1240 same then change it type of result to next */
1242 compareType (t2 = operandType (IC_RESULT (ic)), t1) == 1)
1244 setOperandType (IC_RESULT (ic), t2->next);
1248 /*-----------------------------------------------------------------*/
1249 /* cseBBlock - common subexpression elimination for basic blocks */
1250 /* this is the hackiest kludgiest routine in the whole */
1251 /* system. also the most important, since almost all */
1252 /* data flow related information is computed by it */
1253 /*-----------------------------------------------------------------*/
1255 cseBBlock (eBBlock * ebb, int computeOnly,
1256 eBBlock ** ebbs, int count)
1262 set *ptrSetSet = NULL;
1264 /* if this block is not reachable */
1268 /* set of common subexpressions */
1269 cseSet = setFromSet (ebb->inExprs);
1271 /* these will be computed by this routine */
1272 setToNull ((void **) &ebb->outDefs);
1273 setToNull ((void **) &ebb->defSet);
1274 setToNull ((void **) &ebb->usesDefs);
1275 setToNull ((void **) &ebb->ptrsSet);
1276 setToNull ((void **) &ebb->addrOf);
1277 setToNull ((void **) &ebb->ldefs);
1279 ebb->outDefs = bitVectCopy (ebb->inDefs);
1280 bitVectDefault = iCodeKey;
1281 ebb->defSet = newBitVect (iCodeKey);
1282 ebb->usesDefs = newBitVect (iCodeKey);
1284 /* for all the instructions in this block do */
1285 for (ic = ebb->sch; ic; ic = ic->next)
1295 /* if this is an assignment from true symbol
1296 to a temp then do pointer post inc/dec optimzation */
1297 if (ic->op == '=' && !POINTER_SET (ic) &&
1298 IS_PTR (operandType (IC_RESULT (ic))))
1300 ptrPostIncDecOpt (ic);
1303 /* clear the def & use chains for the operands involved */
1304 /* in this operation . since it can change due to opts */
1305 unsetDefsAndUses (ic);
1307 if (ic->op == PCALL || ic->op == CALL || ic->op == RECEIVE)
1309 /* add to defSet of the symbol */
1310 OP_DEFS (IC_RESULT (ic)) =
1311 bitVectSetBit (OP_DEFS (IC_RESULT (ic)), ic->key);
1312 /* add to the definition set of this block */
1313 ebb->defSet = bitVectSetBit (ebb->defSet, ic->key);
1314 ebb->ldefs = bitVectSetBit (ebb->ldefs, ic->key);
1315 ebb->outDefs = bitVectCplAnd (ebb->outDefs, OP_DEFS (IC_RESULT (ic)));
1316 setUsesDefs (IC_RESULT (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs);
1317 /* delete global variables from the cseSet
1318 since they can be modified by the function call */
1319 deleteItemIf (&cseSet, ifDefGlobal);
1320 /* delete all getpointer iCodes from cseSet, this should
1321 be done only for global arrays & pointers but at this
1322 point we don't know if globals, so to be safe do all */
1323 deleteItemIf (&cseSet, ifAnyGetPointer);
1326 /* for pcall & ipush we need to add to the useSet */
1327 if ((ic->op == PCALL ||
1331 IS_SYMOP (IC_LEFT (ic)))
1334 /* check if they can be replaced */
1338 applyToSetFTrue (cseSet, findCheaperOp, IC_LEFT (ic), &pdop);
1340 IC_LEFT (ic) = pdop;
1342 /* the lookup could have changed it */
1343 if (IS_SYMOP (IC_LEFT (ic)))
1345 OP_USES (IC_LEFT (ic)) =
1346 bitVectSetBit (OP_USES (IC_LEFT (ic)), ic->key);
1347 setUsesDefs (IC_LEFT (ic), ebb->defSet,
1348 ebb->outDefs, &ebb->usesDefs);
1352 /* if we a sending a pointer as a parameter
1353 then kill all cse since the pointed to item
1354 might be changed in the function being called */
1355 if ((ic->op == IPUSH || ic->op == SEND) &&
1356 IS_PTR (operandType (IC_LEFT (ic))))
1358 deleteGetPointers (&cseSet, &ptrSetSet, IC_LEFT (ic), ebb);
1359 ebb->ptrsSet = bitVectSetBit (ebb->ptrsSet, IC_LEFT (ic)->key);
1360 for (i = 0; i < count; ebbs[i++]->visited = 0);
1361 applyToSet (ebb->succList, delGetPointerSucc,
1362 IC_LEFT (ic), ebb->dfnum);
1367 /* if jumptable then mark the usage */
1368 if (ic->op == JUMPTABLE)
1370 OP_USES (IC_JTCOND (ic)) =
1371 bitVectSetBit (OP_USES (IC_JTCOND (ic)), ic->key);
1372 setUsesDefs (IC_JTCOND (ic), ebb->defSet,
1373 ebb->outDefs, &ebb->usesDefs);
1380 /* do some algebraic optimizations if possible */
1382 while (constFold (ic, cseSet));
1385 if (POINTER_GET (ic) && !IS_PTR (operandType (IC_LEFT (ic))))
1387 setOperandType (IC_LEFT (ic),
1388 aggrToPtr (operandType (IC_LEFT (ic)), FALSE));
1392 if (POINTER_SET (ic) && !IS_PTR (operandType (IC_RESULT (ic))))
1394 setOperandType (IC_RESULT (ic),
1395 aggrToPtr (operandType (IC_RESULT (ic)), FALSE));
1398 /* if this is a condition statment then */
1399 /* check if the condition can be replaced */
1402 ifxOptimize (ic, cseSet, computeOnly,
1408 /* if the assignment & result is a temp */
1409 /* see if we can replace it */
1413 /* update the spill location for this */
1414 updateSpillLocation (ic,0);
1416 if (POINTER_SET (ic) &&
1417 !(IS_BITFIELD (OP_SYMBOL (IC_RESULT (ic))->etype)))
1420 applyToSetFTrue (cseSet, findCheaperOp, IC_RESULT (ic), &pdop);
1421 if (pdop && IS_ITEMP (pdop) && !computeOnly)
1422 IC_RESULT (ic) = pdop;
1426 /* do the operand lookup i.e. for both the */
1427 /* right & left operand : check the cseSet */
1428 /* to see if they have been replaced if yes */
1429 /* then replace them with those from cseSet */
1431 /* and left is a symbol */
1432 if (IS_SYMOP (IC_LEFT (ic)) &&
1433 !computeOnly && ic->op != ADDRESS_OF)
1437 applyToSetFTrue (cseSet, findCheaperOp, IC_LEFT (ic), &pdop);
1440 if (POINTER_GET (ic))
1442 if (IS_ITEMP (pdop) || IS_OP_LITERAL (pdop))
1444 IC_LEFT (ic) = pdop;
1447 /* check if there is a pointer set
1448 for the same pointer visible if yes
1449 then change this into an assignment */
1451 if (applyToSetFTrue (cseSet, findPointerSet, IC_LEFT (ic), &pdop, IC_RESULT (ic)) &&
1452 !bitVectBitValue (ebb->ptrsSet, pdop->key))
1455 IC_LEFT (ic) = NULL;
1456 IC_RIGHT (ic) = pdop;
1457 SET_ISADDR (IC_RESULT (ic), 0);
1463 IC_LEFT (ic) = pdop;
1470 if (IS_SYMOP (IC_RIGHT (ic)) && !computeOnly)
1474 applyToSetFTrue (cseSet, findCheaperOp, IC_RIGHT (ic), &pdop);
1478 IC_RIGHT (ic) = pdop;
1483 /* if left or right changed then do algebraic */
1487 while (constFold (ic, cseSet));
1490 /* if after all this it becomes a assignment to self
1491 then delete it and continue */
1492 if (ASSIGNMENT_TO_SELF (ic))
1494 remiCodeFromeBBlock (ebb, ic);
1498 /* now we will check to see if the entire */
1499 /* operation has been performed before */
1500 /* and is available */
1501 /* don't do assignments they will be killed */
1502 /* by dead code elimination if required do */
1503 /* it only if result is a temporary */
1505 if (!(POINTER_GET (ic) &&
1506 (IS_BITFIELD (OP_SYMBOL (IC_RESULT (ic))->etype) ||
1507 isOperandVolatile (IC_LEFT (ic), TRUE) ||
1508 bitVectBitValue (ebb->ndompset, IC_LEFT (ic)->key))) &&
1510 IS_ITEMP (IC_RESULT (ic)) &&
1513 applyToSet (cseSet, findPrevIc, ic, &pdic);
1514 if (pdic && compareType (operandType (IC_RESULT (pdic)),
1515 operandType (IC_RESULT (ic))) != 1)
1520 /* if found then eliminate this and add to */
1521 /* to cseSet an element containing result */
1522 /* of this with previous opcode */
1525 if (IS_ITEMP (IC_RESULT (ic)))
1528 /* replace in the remaining of this block */
1529 replaceAllSymBySym (ic->next, IC_RESULT (ic), IC_RESULT (pdic), &ebb->ndompset);
1530 /* remove this iCode from inexpressions of all
1531 its successors, it cannot be in the in expressions
1532 of any of the predecessors */
1533 for (i = 0; i < count; ebbs[i++]->visited = 0);
1534 applyToSet (ebb->succList, removeFromInExprs, ic, IC_RESULT (ic),
1535 IC_RESULT (pdic), ebb);
1537 /* if this was moved from another block */
1538 /* then replace in those blocks too */
1542 for (owner = setFirstItem (ic->movedFrom); owner;
1543 owner = setNextItem (ic->movedFrom))
1544 replaceAllSymBySym (owner->sch, IC_RESULT (ic), IC_RESULT (pdic), &owner->ndompset);
1546 pdic->movedFrom = unionSets (pdic->movedFrom, ic->movedFrom, THROW_NONE);
1549 addSetHead (&cseSet, newCseDef (IC_RESULT (ic), pdic));
1552 /* eliminate this */
1553 remiCodeFromeBBlock (ebb, ic);
1558 if (IS_ITEMP (IC_RESULT (ic)))
1565 /* just add this as a previous expression except in */
1566 /* case of a pointer access in which case this is a */
1567 /* usage not a definition */
1568 if (!(POINTER_SET (ic)) && IC_RESULT (ic))
1570 deleteItemIf (&cseSet, ifDefSymIsX, IC_RESULT (ic));
1571 addSetHead (&cseSet, newCseDef (IC_RESULT (ic), ic));
1577 /* Alternate code */
1578 if (pdic && IS_ITEMP(IC_RESULT(ic))) {
1579 /* if previous definition found change this to an assignment */
1582 IC_RIGHT(ic) = operandFromOperand(IC_RESULT(pdic));
1583 SET_ISADDR(IC_RESULT(ic),0);
1584 SET_ISADDR(IC_RIGHT (ic),0);
1587 if (!(POINTER_SET (ic)) && IC_RESULT (ic)) {
1588 deleteItemIf (&cseSet, ifDefSymIsX, IC_RESULT (ic));
1589 addSetHead (&cseSet, newCseDef (IC_RESULT (ic), ic));
1593 /* if assignment to a parameter which is not
1594 mine and type is a pointer then delete
1595 pointerGets to take care of aliasing */
1596 if (ASSIGNMENT (ic) &&
1597 OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic))) &&
1598 IS_PTR (operandType (IC_RESULT (ic))))
1600 deleteGetPointers (&cseSet, &ptrSetSet, IC_RIGHT (ic), ebb);
1601 for (i = 0; i < count; ebbs[i++]->visited = 0);
1602 applyToSet (ebb->succList, delGetPointerSucc, IC_RIGHT (ic), ebb->dfnum);
1603 ebb->ptrsSet = bitVectSetBit (ebb->ptrsSet, IC_RIGHT (ic)->key);
1606 /* if this is a pointerget then see if we can replace
1607 this with a previously assigned pointer value */
1608 if (POINTER_GET (ic) &&
1609 !(IS_BITFIELD (OP_SYMBOL (IC_RESULT (ic))->etype) ||
1610 isOperandVolatile (IC_LEFT (ic), TRUE)))
1613 applyToSet (ptrSetSet, findPointerSet, IC_LEFT (ic), &pdop, IC_RESULT (ic));
1614 /* if we find it then locally replace all
1615 references to the result with what we assigned */
1618 replaceAllSymBySym (ic->next, IC_RESULT (ic), pdop, &ebb->ndompset);
1622 /* delete from the cseSet anything that has */
1623 /* operands matching the result of this */
1624 /* except in case of pointer access */
1625 if (!(POINTER_SET (ic)) && IC_RESULT (ic))
1627 deleteItemIf (&cseSet, ifOperandsHave, IC_RESULT (ic));
1628 /* delete any previous definitions */
1629 ebb->defSet = bitVectCplAnd (ebb->defSet, OP_DEFS (IC_RESULT (ic)));
1633 /* add the left & right to the defUse set */
1634 if (IC_LEFT (ic) && IS_SYMOP (IC_LEFT (ic)))
1636 OP_USES (IC_LEFT (ic)) =
1637 bitVectSetBit (OP_USES (IC_LEFT (ic)), ic->key);
1638 setUsesDefs (IC_LEFT (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs);
1642 if (IC_RIGHT (ic) && IS_SYMOP (IC_RIGHT (ic)))
1644 OP_USES (IC_RIGHT (ic)) =
1645 bitVectSetBit (OP_USES (IC_RIGHT (ic)), ic->key);
1646 setUsesDefs (IC_RIGHT (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs);
1650 /* for the result it is special case, put the result */
1651 /* in the defuseSet if it a pointer or array access */
1652 if (POINTER_SET (defic))
1654 OP_USES (IC_RESULT (ic)) =
1655 bitVectSetBit (OP_USES (IC_RESULT (ic)), ic->key);
1656 setUsesDefs (IC_RESULT (ic), ebb->defSet, ebb->outDefs, &ebb->usesDefs);
1657 deleteItemIf (&cseSet, ifPointerGet, IC_RESULT (ic));
1658 ebb->ptrsSet = bitVectSetBit (ebb->ptrsSet, IC_RESULT (ic)->key);
1659 /* delete from inexpressions of all successors which
1660 have dfNum > than this block */
1661 for (i = 0; i < count; ebbs[i++]->visited = 0);
1662 applyToSet (ebb->succList, delGetPointerSucc, IC_RESULT (ic), ebb->dfnum);
1664 /* delete from cseSet all other pointer sets
1666 deleteItemIf (&ptrSetSet, ifPointerSet, IC_RESULT (ic));
1667 /* add to the local pointerset set */
1668 addSetHead (&ptrSetSet, newCseDef (IC_RESULT (ic), ic));
1671 /* add the result to defintion set */ if (IC_RESULT (ic))
1673 OP_DEFS (IC_RESULT (ic)) =
1674 bitVectSetBit (OP_DEFS (IC_RESULT (ic)), ic->key);
1675 ebb->defSet = bitVectSetBit (ebb->defSet, ic->key);
1676 ebb->outDefs = bitVectCplAnd (ebb->outDefs, OP_DEFS (IC_RESULT (ic)));
1677 ebb->ldefs = bitVectSetBit (ebb->ldefs, ic->key);
1681 /* if this is an addressof instruction then */
1682 /* put the symbol in the address of list & */
1683 /* delete it from the cseSet */
1684 if (defic->op == ADDRESS_OF)
1686 addSetHead (&ebb->addrOf, IC_LEFT (ic));
1687 deleteItemIf (&cseSet, ifDefSymIsX, IC_LEFT (ic));
1691 setToNull ((void **) &ebb->outExprs);
1692 ebb->outExprs = cseSet;
1693 ebb->outDefs = bitVectUnion (ebb->outDefs, ebb->defSet);
1694 ebb->ptrsSet = bitVectUnion (ebb->ptrsSet, ebb->inPtrsSet);
1698 /*-----------------------------------------------------------------*/
1699 /* cseAllBlocks - will sequentially go thru & do cse for all blocks */
1700 /*-----------------------------------------------------------------*/
1702 cseAllBlocks (eBBlock ** ebbs, int count)
1707 /* if optimization turned off */
1709 for (i = 0; i < count; i++)
1710 change += cseBBlock (ebbs[i], FALSE, ebbs, count);