This is a temporary fix for UB in IRA, where ubsan complains because
there's signed iteger overflow in the multiplication.  To shut this 
error up, we can perform the multiplication in unsigned and only then
cast the result of the multiplication to int.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2014-03-25  Marek Polacek  <pola...@redhat.com>

        PR other/59545
        * ira-color.c (update_conflict_hard_regno_costs): Perform the
        multiplication in unsigned type.

diff --git gcc/ira-color.c gcc/ira-color.c
index c20aaf7..1f4c96e 100644
--- gcc/ira-color.c
+++ gcc/ira-color.c
@@ -1505,7 +1505,7 @@ update_conflict_hard_regno_costs (int *costs, enum 
reg_class aclass,
                index = ira_class_hard_reg_index[aclass][hard_regno];
                if (index < 0)
                  continue;
-               cost = conflict_costs [i] * mult / div;
+               cost = (int) ((unsigned) conflict_costs [i] * mult) / div;
                if (cost == 0)
                  continue;
                cont_p = true;

        Marek

Reply via email to