re PR rtl-optimization/41917 (Strange athrithmetic result with -O3)
PR rtl-optimization/41917 * rtlanal.c (num_sign_bit_copies1) <case UMOD>: If sign bit of second operand isn't known to be 0, return 1. * gcc.c-torture/execute/pr41917.c: New test. From-SVN: r153874
This commit is contained in:
parent
0b94d8b285
commit
24d179b4c7
4 changed files with 42 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-11-03 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR rtl-optimization/41917
|
||||
* rtlanal.c (num_sign_bit_copies1) <case UMOD>: If sign bit of second
|
||||
operand isn't known to be 0, return 1.
|
||||
|
||||
2009-11-03 Richard Sandiford <rdsandiford@googlemail.com>
|
||||
|
||||
* config/mips/mips.md: Fix typos.
|
||||
|
|
|
@ -4517,8 +4517,16 @@ num_sign_bit_copies1 (const_rtx x, enum machine_mode mode, const_rtx known_x,
|
|||
known_x, known_mode, known_ret);
|
||||
|
||||
case UMOD:
|
||||
/* The result must be <= the second operand. */
|
||||
return cached_num_sign_bit_copies (XEXP (x, 1), mode,
|
||||
/* The result must be <= the second operand. If the second operand
|
||||
has (or just might have) the high bit set, we know nothing about
|
||||
the number of sign bit copies. */
|
||||
if (bitwidth > HOST_BITS_PER_WIDE_INT)
|
||||
return 1;
|
||||
else if ((nonzero_bits (XEXP (x, 1), mode)
|
||||
& ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0)
|
||||
return 1;
|
||||
else
|
||||
return cached_num_sign_bit_copies (XEXP (x, 1), mode,
|
||||
known_x, known_mode, known_ret);
|
||||
|
||||
case DIV:
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2009-11-03 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR rtl-optimization/41917
|
||||
* gcc.c-torture/execute/pr41917.c: New test.
|
||||
|
||||
2009-11-03 Uros Bizjak <ubizjak@gmail.com>
|
||||
|
||||
* gcc.target/i386/pr41900.c: Make test compile only. Scan assembler
|
||||
|
|
21
gcc/testsuite/gcc.c-torture/execute/pr41917.c
Normal file
21
gcc/testsuite/gcc.c-torture/execute/pr41917.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* PR rtl-optimization/41917 */
|
||||
|
||||
extern void abort (void);
|
||||
unsigned int a = 1;
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
unsigned int b, c, d;
|
||||
|
||||
if (sizeof (int) != 4 || (int) 0xc7d24b5e > 0)
|
||||
return 0;
|
||||
|
||||
c = 0xc7d24b5e;
|
||||
d = a | -2;
|
||||
b = (d == 0) ? c : (c % d);
|
||||
if (b != c)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue