From 88e81a691d4025461c124183e3a253f8a3ad351a Mon Sep 17 00:00:00 2001 From: bonzini Date: Sat, 11 Jul 2009 08:28:34 +0000 Subject: [PATCH] 2009-07-11 Paolo Bonzini * expmed.c (emit_store_flag_1): Fix choice of zero vs. sign extension. 2009-07-11 Paolo Bonzini * gcc.c-torture/execute/20090711-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149509 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 4 ++++ gcc/expmed.c | 2 +- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.c-torture/execute/20090711-1.c | 21 +++++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20090711-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8cf7745..3e62635 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2009-07-11 Paolo Bonzini + + * expmed.c (emit_store_flag_1): Fix choice of zero vs. sign extension. + 2009-07-10 DJ Delorie * config/mep/mep.c (mep_can_inline_p): Correct logic, and simplify. diff --git a/gcc/expmed.c b/gcc/expmed.c index aa8d02d..c73bf21 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -5343,7 +5343,7 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, target = gen_reg_rtx (target_mode); convert_move (target, tem, - 0 == (STORE_FLAG_VALUE + 0 == ((normalizep ? normalizep : STORE_FLAG_VALUE) & ((HOST_WIDE_INT) 1 << (GET_MODE_BITSIZE (word_mode) -1)))); return target; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a29bd83..7a477b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-07-11 Paolo Bonzini + + * gcc.c-torture/execute/20090711-1.c: New test. + 2009-07-11 Richard Sandiford PR testsuite/40699 diff --git a/gcc/testsuite/gcc.c-torture/execute/20090711-1.c b/gcc/testsuite/gcc.c-torture/execute/20090711-1.c new file mode 100644 index 0000000..5c3d93a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20090711-1.c @@ -0,0 +1,21 @@ +/* Used to be miscompiled at -O0 due to incorrect choice of sign extension + vs. zero extension. __attribute__ ((noinline)) added to try to make it + fail at higher optimization levels too. */ + +extern void abort (void); + +long long __attribute__ ((noinline)) +div (long long val) +{ + return val / 32768; +} + +int main (void) +{ + long long d1 = -990000000; + long long d2 = div(d1); + if (d2 != -30212) + abort (); + return 0; +} + -- 2.7.4