OSDN Git Service

* simplify-rtx.c (simplify_binary_operation) [DIV]: If
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Jan 2002 17:24:13 +0000 (17:24 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Jan 2002 17:24:13 +0000 (17:24 +0000)
gen_lowpart_common fails, use gen_lowpart_SUBREG.

* gcc.c-torture/compile/20020103-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48514 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20020103-1.c [new file with mode: 0644]

index 38ba6c5..ded183f 100644 (file)
@@ -1,4 +1,10 @@
+2002-01-03  Jakub Jelinek  <jakub@redhat.com>
+
+       * simplify-rtx.c (simplify_binary_operation) [DIV]: If
+       gen_lowpart_common fails, use gen_lowpart_SUBREG.
+
 2002-01-03  Turly O'Connor  <turly@apple.com>
+
        * darwin.c (machopic_output_possible_stub_label): Don't generate
        stub routines for pseudo-stubs which we've just defined.
 
index 49c205c..84209cc 100644 (file)
@@ -1413,8 +1413,15 @@ simplify_binary_operation (code, mode, op0, op1)
        case DIV:
          if (trueop1 == CONST1_RTX (mode))
            {
+             /* On some platforms DIV uses narrower mode than its
+                operands.  */
              rtx x = gen_lowpart_common (mode, op0);
-             return x ? x : op0;
+             if (x)
+               return x;
+             else if (mode != GET_MODE (op0) && GET_MODE (op0) != VOIDmode)
+               return gen_lowpart_SUBREG (mode, op0);
+             else
+               return op0;
            }
 
          /* In IEEE floating point, 0/x is not always 0.  */
index 0fd9701..1838539 100644 (file)
@@ -2,6 +2,8 @@
 
        * g++.dg/other/debug2.C: New test.
 
+       * gcc.c-torture/compile/20020103-1.c: New test.
+
 2002-01-02  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/gnu89-init-1.c: Added new tests.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020103-1.c b/gcc/testsuite/gcc.c-torture/compile/20020103-1.c
new file mode 100644 (file)
index 0000000..b986168
--- /dev/null
@@ -0,0 +1,22 @@
+/* This testcase failed on Alpha at -O2 when simplifying conditional
+   expressions.  */
+
+int foo (void);
+
+struct A
+{
+  int a, b, c, d;
+};
+
+void bar (struct A *x)
+{
+  int e, f;
+
+  e = foo ();
+  e = e / x->b;
+  if (e < 1)
+    e = 1;
+  f = (x->a + x->c) / e;
+  if (f < x->d)
+    x->d -= (1 << 16) / 8;
+}