re PR target/13889 (Assignment of an int to an int of different size in a struct...
authorRoger Sayle <roger@eyesopen.com>
Sat, 20 Mar 2004 23:03:03 +0000 (23:03 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sat, 20 Mar 2004 23:03:03 +0000 (23:03 +0000)
PR target/13889
* cse.c (fold_rtx): Avoid substituting constants into unary
convertion operations.

* gcc.c-torture/compile/pr13889.c: New test case.

From-SVN: r79762

gcc/ChangeLog
gcc/cse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr13889.c [new file with mode: 0644]

index f3de3ff54c56f635bfb2467f5eb52dc95bf10a9d..ccbe122132a6d5f6083abd3b9d8dcafa32b07ca7 100644 (file)
@@ -1,3 +1,9 @@
+2004-03-20  Roger Sayle  <roger@eyesopen.com>
+
+       PR target/13889
+       * cse.c (fold_rtx): Avoid substituting constants into unary
+       convertion operations.
+
 2004-03-20  Kazu Hirata  <kazu@cs.umass.edu>
 
        * fold-const.c (fold): Replace "expr" with "t".
index 9e4cab8cd9097f6c8b6a0a79c30d85a85959a4ab..38f6ef06004634b7f0ba3a3b427d31ef55eba9b1 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -3662,6 +3662,23 @@ fold_rtx (rtx x, rtx insn)
                || (new_cost == old_cost && CONSTANT_P (XEXP (x, i))))
              break;
 
+           /* It's not safe to substitute the operand of a conversion
+              operator with a constant, as the conversion's identity
+              depends upon the mode of it's operand.  This optimization
+              is handled by the call to simplify_unary_operation.  */
+           if (GET_RTX_CLASS (code) == RTX_UNARY
+               && GET_MODE (replacements[j]) != mode_arg0
+               && (code == ZERO_EXTEND
+                   || code == SIGN_EXTEND
+                   || code == TRUNCATE
+                   || code == FLOAT_TRUNCATE
+                   || code == FLOAT_EXTEND
+                   || code == FLOAT
+                   || code == FIX
+                   || code == UNSIGNED_FLOAT
+                   || code == UNSIGNED_FIX))
+             continue;
+
            if (validate_change (insn, &XEXP (x, i), replacements[j], 0))
              break;
 
index dc7239bc0d6abd6031c0814a9bd1671319958600..b53e941f16277a9c10860f112eb736a8dbeb4c7a 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-20  Roger Sayle  <roger@eyesopen.com>
+
+       PR target/13889
+       * gcc.c-torture/compile/pr13889.c: New test case.
+
 2004-03-20  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        PR c/14635
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr13889.c b/gcc/testsuite/gcc.c-torture/compile/pr13889.c
new file mode 100644 (file)
index 0000000..d14bc9a
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR target/13889 */
+struct { long long a; } *p;
+void initNetFlowFunct(void) {
+  unsigned int b = (unsigned int)-1;
+  p->a = b;
+}
+