------- Additional Comments From matt at 3am-software dot com  2005-05-08 15:32 
-------
This bug is to due to struct mult_cost having its member defined as shorts. 
Since MAX_COST is defined to be INT_MAX, when a cost value is moved from div_mod
to mult_cost, the upper bits are truncated and the 0x7fffffd9 cost becomes
0xffd9. This results is a negative cost and causes a premature to happen in
synth_mult due to:

  if (cost_limit->cost < 0
      || (cost_limit->cost == 0 && cost_limit->latency <= 0))
    return;

And so the algorithm fails to be set resulting in the eventual call to
gcc_unreachable.

Simply changing the members of mult_cost from short to int causes the ICE to be
avoided.

--- expmed.c    27 Apr 2005 16:02:33 -0000      1.228
+++ expmed.c    8 May 2005 15:32:04 -0000
@@ -2315,8 +2315,8 @@ enum alg_code { alg_unknown, alg_zero, a
    leaves and rtx_cost(op) + max(latency(a), latency(b)) otherwise.  */
 
 struct mult_cost {
-  short cost;     /* Total rtx_cost of the multiplication sequence.  */
-  short latency;  /* The latency of the multiplication sequence.  */
+  int cost;     /* Total rtx_cost of the multiplication sequence.  */
+  int latency;  /* The latency of the multiplication sequence.  */
 };
 
 /* This macro is used to compare a pointer to a mult_cost against an


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|target                      |middle-end


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21309

Reply via email to