(selectSpil): fixed bug
1337835 by not spilling bit variables
* support/regression/tests/bug1337835.c: added test for this bug
* src/mcs51/peeph.def: restart after rule 3.c,
addded rules 263.x to optimize loading constants
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3913
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2005-10-27 Maarten Brock <sourceforge.brock AT dse.nl>
+
+ * src/mcs51/ralloc.c (bitType): added to detect bit variables,
+ (selectSpil): fixed bug 1337835 by not spilling bit variables
+ * support/regression/tests/bug1337835.c: added test for this bug
+ * src/mcs51/peeph.def: restart after rule 3.c,
+ addded rules 263.x to optimize loading constants
+
2005-10-26 Raphael Neider <rneider AT web.de>
* src/SDCCsymt.c (compStructSize): allow signed bitfields for PIC ports
2005-10-26 Raphael Neider <rneider AT web.de>
* src/SDCCsymt.c (compStructSize): allow signed bitfields for PIC ports
* src/pic16/glue.c (pic16emitStaticSeg): fixed(?) handling of fixed
extern variables, added verbose error message
* device/include/pic16/{string.h,errno.h}: added #pragma library c
* src/pic16/glue.c (pic16emitStaticSeg): fixed(?) handling of fixed
extern variables, added verbose error message
* device/include/pic16/{string.h,errno.h}: added #pragma library c
2005-10-26 Bernhard Held <bernhard AT bernhardheld.de>
* src/mcs51/gen.c (genMinus): fixed bug 1270906: reverse subtraction,
2005-10-26 Bernhard Held <bernhard AT bernhardheld.de>
* src/mcs51/gen.c (genMinus): fixed bug 1270906: reverse subtraction,
// saving 1 byte, loosing 1 cycle but maybe allowing peephole 3.b to start
mov %1,#0x00
mov %2,#0x00
// saving 1 byte, loosing 1 cycle but maybe allowing peephole 3.b to start
mov %1,#0x00
mov %2,#0x00
; Peephole 262 removed redundant cpl c
}
; Peephole 262 removed redundant cpl c
}
+replace {
+ mov %1,#%2
+ inc %1
+ inc %1
+ inc %1
+} by {
+ ; Peephole 263.a optimized loading const
+ mov %1,#(%2 + 3)
+}
+
+replace {
+ mov %1,#%2
+ inc %1
+ inc %1
+} by {
+ ; Peephole 263.b optimized loading const
+ mov %1,#(%2 + 2)
+}
+
+replace {
+ mov %1,#%2
+ inc %1
+} by {
+ ; Peephole 263.c optimized loading const
+ mov %1,#(%2 + 1)
+}
+
// should be one of the last peepholes
replace{
%1:
// should be one of the last peepholes
replace{
%1:
+/*-----------------------------------------------------------------*/
+/* bitType - will return 1 if the symbol has type REG_BIT */
+/*-----------------------------------------------------------------*/
+static int
+bitType (symbol * sym, eBBlock * ebp, iCode * ic)
+{
+ return (sym->regType == REG_BIT ? 1 : 0);
+}
+
/*-----------------------------------------------------------------*/
/* noSpilLoc - return true if a variable has no spil location */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* noSpilLoc - return true if a variable has no spil location */
/*-----------------------------------------------------------------*/
}
/*-----------------------------------------------------------------*/
}
/*-----------------------------------------------------------------*/
-/* directSpilLoc - will return 1 if the splilocation is in direct */
+/* directSpilLoc - will return 1 if the spillocation is in direct */
/*-----------------------------------------------------------------*/
static int
directSpilLoc (symbol * sym, eBBlock * ebp, iCode * ic)
/*-----------------------------------------------------------------*/
static int
directSpilLoc (symbol * sym, eBBlock * ebp, iCode * ic)
{
/* if usage is the same then prefer
{
/* if usage is the same then prefer
- the spill the smaller of the two */
+ to spill the smaller of the two */
if (lsym->used == sym->used)
if (getSize (lsym->type) < getSize (sym->type))
sym = lsym;
if (lsym->used == sym->used)
if (getSize (lsym->type) < getSize (sym->type))
sym = lsym;
/* get the spillable live ranges */
lrcs = computeSpillable (ic);
/* get the spillable live ranges */
lrcs = computeSpillable (ic);
- /* get all live ranges that are rematerizable */
- if ((selectS = liveRangesWith (lrcs, rematable, ebp, ic)))
+ /* remove incompatible registers */
+ if ((forSym->regType == REG_PTR) || (forSym->regType == REG_GPR))
+ {
+ selectS = liveRangesWith (lrcs, bitType, ebp, ic);
+
+ for (sym = setFirstItem (selectS); sym; sym = setNextItem (selectS))
+ bitVectUnSetBit (lrcs, sym->key);
+ }
+ }
+ /* get all live ranges that are rematerializable */
+ if ((selectS = liveRangesWith (lrcs, rematable, ebp, ic)))
+ {
/* return the least used of these */
return leastUsedLR (selectS);
}
/* return the least used of these */
return leastUsedLR (selectS);
}
/* if the symbol is local to the block then */
if (forSym->liveTo < ebp->lSeq)
{
/* if the symbol is local to the block then */
if (forSym->liveTo < ebp->lSeq)
{
/* check if there are any live ranges allocated
to registers that are not used in this block */
if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInBlock, ebp, ic)))
/* check if there are any live ranges allocated
to registers that are not used in this block */
if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInBlock, ebp, ic)))
/* find live ranges with spillocation && not used as pointers */
if ((selectS = liveRangesWith (lrcs, hasSpilLocnoUptr, ebp, ic)))
{
/* find live ranges with spillocation && not used as pointers */
if ((selectS = liveRangesWith (lrcs, hasSpilLocnoUptr, ebp, ic)))
{
sym = leastUsedLR (selectS);
/* mark this as allocation required */
sym->usl.spillLoc->allocreq++;
sym = leastUsedLR (selectS);
/* mark this as allocation required */
sym->usl.spillLoc->allocreq++;
/* find live ranges with spillocation */
if ((selectS = liveRangesWith (lrcs, hasSpilLoc, ebp, ic)))
{
/* find live ranges with spillocation */
if ((selectS = liveRangesWith (lrcs, hasSpilLoc, ebp, ic)))
{
sym = leastUsedLR (selectS);
sym->usl.spillLoc->allocreq++;
return sym;
sym = leastUsedLR (selectS);
sym->usl.spillLoc->allocreq++;
return sym;
used ofcourse */
if ((selectS = liveRangesWith (lrcs, noSpilLoc, ebp, ic)))
{
used ofcourse */
if ((selectS = liveRangesWith (lrcs, noSpilLoc, ebp, ic)))
{
/* return a created spil location */
sym = createStackSpil (leastUsedLR (selectS));
sym->usl.spillLoc->allocreq++;
/* return a created spil location */
sym = createStackSpil (leastUsedLR (selectS));
sym->usl.spillLoc->allocreq++;
--- /dev/null
+/*
+ bug1057979.c
+*/
+
+#include <testfwk.h>
+#include <stdbool.h>
+
+#ifndef BOOL
+#define BOOL bool
+#endif
+
+char e;
+
+void foo (unsigned long ul, BOOL b, char c) REENTRANT
+{
+ if (b && (long) ul < 0)
+ e = 0;
+ if (ul && b && c)
+ e = 1;
+}
+
+void
+test_1337835(void)
+{
+ e = 2;
+ foo(0, 1, 0);
+ ASSERT( e == 2 );
+}