2013-02-08 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/56250
* fold-const.c (extract_muldiv_1) <case NEGATE_EXPR>: Don't optimize
if type is unsigned and code isn't MULT_EXPR.
* gcc.c-torture/execute/pr56250.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@196147
138bc75d-0d04-0410-961f-
82ee72b054a4
2013-02-19 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2013-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/56250
+ * fold-const.c (extract_muldiv_1) <case NEGATE_EXPR>: Don't optimize
+ if type is unsigned and code isn't MULT_EXPR.
+
2013-02-06 Jakub Jelinek <jakub@redhat.com>
PR middle-end/56217
break;
/* FALLTHROUGH */
case NEGATE_EXPR:
+ /* For division and modulus, type can't be unsigned, as e.g.
+ (-(x / 2U)) / 2U isn't equal to -((x / 2U) / 2U) for x >= 2.
+ For signed types, even with wrapping overflow, this is fine. */
+ if (code != MULT_EXPR && TYPE_UNSIGNED (type))
+ break;
if ((t1 = extract_muldiv (op0, c, code, wide_type, strict_overflow_p))
!= 0)
return fold_build1 (tcode, ctype, fold_convert (ctype, t1));
2013-02-19 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2013-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/56250
+ * gcc.c-torture/execute/pr56250.c: New test.
+
2013-02-07 Jakub Jelinek <jakub@redhat.com>
PR c++/56241
--- /dev/null
+/* PR tree-optimization/56250 */
+
+extern void abort (void);
+
+int
+main ()
+{
+ unsigned int x = 2;
+ unsigned int y = (0U - x / 2) / 2;
+ if (-1U / x != y)
+ abort ();
+ return 0;
+}