* src/SDCCcse.c (findPointerSet): fixed bug #1493710
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 27 May 2006 20:50:29 +0000 (20:50 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 27 May 2006 20:50:29 +0000 (20:50 +0000)
* support/regression/tests/bug-1493710.c: added

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4195 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCcse.c
support/regression/tests/bug-1493710.c [new file with mode: 0644]

index 0c5d8b598dd693d520bed2bd0f3c9d4dbeac8179..3063744f983dd31b371dc48456699c5b991e903c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-27 Bernhard Held <bernhard AT bernhardheld.de>
+
+       * src/SDCCcse.c (findPointerSet): fixed bug #1493710
+       * support/regression/tests/bug-1493710.c: added
+
 2006-05-27 Borut Razem <borut.razem AT siol.net>
 
        * support/regression/fwk/lib/testfwk.c: define array in _printn() as
index 35a5df940f476513025bc343d0386ae13e69f198..df360ff09f15c35e2b404f836038c15a54ef321f 100644 (file)
@@ -175,6 +175,13 @@ replaceAllSymBySym (iCode * ic, operand * from, operand * to, bitVect ** ndpset)
 {
   iCode *lic;
 
+#ifdef RANGEHUNT
+  printf ("replaceAllSymBySym\n\t");
+  printOperand (from, stdout);
+  printf ("\nwith\t");
+  printOperand (to, stdout);
+  printf ("\n");
+#endif
   for (lic = ic; lic; lic = lic->next)
     {
       int siaddr;
@@ -471,6 +478,16 @@ DEFSETFUNC (findPointerSet)
       getSize (operandType (IC_RIGHT (cdp->diCode))) ==
       getSize (operandType (rop)))
     {
+      if (IS_SPEC (operandType (IC_RIGHT (cdp->diCode))) &&
+          SPEC_USIGN (operandType (IC_RIGHT (cdp->diCode))) !=
+          SPEC_USIGN (operandType (rop)))
+        {
+          /* bug #1493710
+            Reminder for Bernhard: check of signedness
+            could be unnecessary together with 'checkSign', if
+            signedness of operation is stored in ic */
+          return 0;
+        }
       *opp = IC_RIGHT (cdp->diCode);
       return 1;
     }
diff --git a/support/regression/tests/bug-1493710.c b/support/regression/tests/bug-1493710.c
new file mode 100644 (file)
index 0000000..ab5991d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+   bug-1493710.c
+
+   cse
+   findPointerSet with signed/unsigned operands
+*/
+
+#include <testfwk.h>
+
+struct
+  {
+    unsigned char a;
+  } st = { 0xff };
+
+signed char c = -1;
+
+unsigned char f (void)
+{
+  st.a += c;
+  return st.a > 8;
+}
+
+void
+testFindPointerSet(void)
+{
+  ASSERT(f() == 1);
+}