This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Fix fold-const breakage


    The reason is that it is not safe to optimize:
    ( x * -3 - y * 3 ) / 12 into x / -4 - y / 4 which was extract_muldiv trying
    (since extract_muldiv gave non-zero for both operands).

-      if (t1 != 0 && t2 != 0)
+      if (t1 != 0 && t2 != 0
+	  && (code == MULT_EXPR
+	      /* If not multiplication, we can only this if both operands
+		 are divisible by c.  */
+	      || (multiple_of_p (ctype, op0, c)
+		  && multiple_of_p (ctype, op1, c))))

This is a pretty major pessimization of the code.  Isn't there some finer
test that can be made here?

+	  if (TYPE_PRECISION (TREE_TYPE (size_one_node))
+	      > TREE_INT_CST_LOW (op1)
+	      && TREE_INT_CST_HIGH (op1) == 0

This can be done with compare_tree_int.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]