+2015-10-15 Marek Polacek <polacek@redhat.com>
+
+ PR tree-optimization/67953
+ * match.pd (X - (X / Y) * Y): Don't change signedness of @0.
+
2015-10-15 Jiong Wang <jiong.wang@arm.com>
* config.gcc: Recognize "." in architecture base name for AArch64.
/* X - (X / Y) * Y is the same as X % Y. */
(simplify
(minus (convert1? @0) (convert2? (mult (trunc_div @0 @1) @1)))
- (if (INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type))
+ (if ((INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type))
+ && TYPE_UNSIGNED (TREE_TYPE (@0)) == TYPE_UNSIGNED (type))
(trunc_mod (convert @0) (convert @1))))
/* Optimize TRUNC_MOD_EXPR by a power of two into a BIT_AND_EXPR,
+2015-10-15 Marek Polacek <polacek@redhat.com>
+
+ PR tree-optimization/67953
+ * gcc.dg/fold-minus-6.c (fn4): Change the type of A to
+ unsigned.
+ * gcc.dg/torture/pr67953.c: New test.
+
2015-10-14 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/ssa-dom-thread-2.c: Deleted. The six functions
}
int
-fn4 (int a, int b)
+fn4 (unsigned int a, int b)
{
return a - (unsigned) ((a / b) * b);
}
--- /dev/null
+/* PR tree-optimization/67953 */
+/* { dg-do run } */
+
+unsigned int
+fn1 (signed int a)
+{
+ return (unsigned int) a - ((a / 3) * 3);
+}
+
+unsigned int
+fn2 (signed int a)
+{
+ return a - ((a / 3) * 3);
+}
+
+unsigned int
+fn3 (int a)
+{
+ return a - (unsigned) ((a / 3) * 3);
+}
+
+signed int
+fn4 (int a)
+{
+ return (unsigned) a - (unsigned) ((a / 3) * 3);
+}
+
+int
+main ()
+{
+ if (fn1 (-5) != -2
+ || fn2 (-5) != -2
+ || fn3 (-5) != -2
+ || fn4 (-5) != -2)
+ __builtin_abort ();
+}