i386.c (ix86_expand_carry_flag_compare): Fix transformation of a>=0 into (unsigned...
authorRoger Sayle <roger@eyesopen.com>
Sun, 21 Sep 2003 02:22:45 +0000 (02:22 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sun, 21 Sep 2003 02:22:45 +0000 (02:22 +0000)
* config/i386/i386.c (ix86_expand_carry_flag_compare): Fix
transformation of a>=0 into (unsigned)a<0x80000000.

* gcc.c-torture/execute/20030920-1.c: New test case.

From-SVN: r71618

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20030920-1.c [new file with mode: 0644]

index 934670180d054fa36933a961ff0e65319e788958..6e8f5a0ab4db70a37a27028f47e870c6342d2813 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-20  Roger Sayle  <roger@eyesopen.com>
+
+       * config/i386/i386.c (ix86_expand_carry_flag_compare): Fix
+       transformation of a>=0 into (unsigned)a<0x80000000.
+
 2003-09-20  Andrew Pinski <apinski@apple.com>
 
        * config/darwin.c (machopic_select_rtx_section): Fix check for PIC code.
index de867f3e25f95a898fe3582471ec4dc313a57317..c1e8ac6c89483622b9c94411e03f82e98d59feb5 100644 (file)
@@ -9469,19 +9469,19 @@ ix86_expand_carry_flag_compare (enum rtx_code code, rtx op0, rtx op1, rtx *pop)
        }
       break;
 
-    /* Convert a>0 into (unsigned)a<0x7fffffff.  */
+    /* Convert a>=0 into (unsigned)a<0x80000000.  */
     case LT:
     case GE:
       if (mode == DImode || op1 != const0_rtx)
        return false;
-      op1 = gen_int_mode (~(1 << (GET_MODE_BITSIZE (mode) - 1)), mode);
+      op1 = gen_int_mode (1 << (GET_MODE_BITSIZE (mode) - 1), mode);
       code = (code == LT ? GEU : LTU);
       break;
     case LE:
     case GT:
       if (mode == DImode || op1 != constm1_rtx)
        return false;
-      op1 = gen_int_mode (~(1 << (GET_MODE_BITSIZE (mode) - 1)), mode);
+      op1 = gen_int_mode (1 << (GET_MODE_BITSIZE (mode) - 1), mode);
       code = (code == LE ? GEU : LTU);
       break;
 
index 2cfb257f8d7752b9f09f91155d0c48614e4e330d..1ba55f62ebb29668bc83d842c7c96b909db8a7d7 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-20  Roger Sayle  <roger@eyesopen.com>
+
+       * gcc.c-torture/execute/20030920-1.c: New test case.
+
 2003-09-20  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * g++.dg/rtti/typeid3.C: Correct expected error message.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20030920-1.c b/gcc/testsuite/gcc.c-torture/execute/20030920-1.c
new file mode 100644 (file)
index 0000000..2d22115
--- /dev/null
@@ -0,0 +1,15 @@
+extern void abort (void);
+
+int main()
+{
+  int hicount = 0;
+  unsigned char *c;
+  char *str = "\x7f\xff";
+  for (c = (unsigned char *)str; *c ; c++) {
+    if (!(((unsigned int)(*c)) < 0x80)) hicount++;
+  }
+  if (hicount != 1)
+    abort ();
+  return 0;
+}
+