+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.
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:
+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
--- /dev/null
+/* 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;
+}