From 0a71919d5257d2e9097d79d00d840f4ecfd746c4 Mon Sep 17 00:00:00 2001 From: Falk Hueffner Date: Sun, 16 Mar 2003 19:43:53 +0000 Subject: [PATCH] re PR target/9164 ([Alpha] improper code generation) PR target/9164 * tree.c (get_narrower): For extensions with unchanged bit number, return the unsignedness of the outer mode. * gcc.c-torture/execute/20030316-1.c: New test case. From-SVN: r64440 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.c-torture/execute/20030316-1.c | 12 ++++++++++++ gcc/tree.c | 3 ++- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20030316-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ad268466898..d7d2eb46561 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-03-16 Falk Hueffner + + PR target/9164 + * tree.c (get_narrower): For extensions with unchanged bit number, + return the unsignedness of the outer mode. + 2003-03-16 Roger Sayle * c-typeck.c (build_component_ref): Turn "for" into "do .. while" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d4558f61f9d..423b43d93ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-03-16 Falk Hueffner + + * gcc.c-torture/execute/20030316-1.c: New test case. + 2003-03-16 Nathan Sidwell PR c++/9629 diff --git a/gcc/testsuite/gcc.c-torture/execute/20030316-1.c b/gcc/testsuite/gcc.c-torture/execute/20030316-1.c new file mode 100644 index 00000000000..bde2e136ad3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20030316-1.c @@ -0,0 +1,12 @@ +/* PR target/9164 */ +/* The comparison operand was sign extended erraneously. */ + +int +main (void) +{ + long j = 0x40000000; + if ((unsigned int) (0x40000000 + j) < 0L) + abort (); + + return 0; +} diff --git a/gcc/tree.c b/gcc/tree.c index 01308595521..30a1c59d5d8 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -3958,10 +3958,10 @@ get_narrower (op, unsignedp_ptr) /* See what's inside this conversion. If we decide to strip it, we will set WIN. */ - op = TREE_OPERAND (op, 0); if (bitschange > 0) { + op = TREE_OPERAND (op, 0); /* An extension: the outermost one can be stripped, but remember whether it is zero or sign extension. */ if (first) @@ -3980,6 +3980,7 @@ get_narrower (op, unsignedp_ptr) if (first) uns = TREE_UNSIGNED (TREE_TYPE (op)); first = 0; + op = TREE_OPERAND (op, 0); } win = op;