Patchwork obvious fix to simplify-rtx.c

login
register
mail settings
Submitter Kenneth Zadeck
Date June 9, 2012, 12:47 p.m.
Message ID <4FD345C7.6080104@naturalbridge.com>
Download mbox | patch
Permalink /patch/163919/
State New
Headers show

Comments

Kenneth Zadeck - June 9, 2012, 12:47 p.m.
The shift count was being truncated by the wrong amount.    It is now 
zero extended from log2 of the mode size rather than the mode size.    
This is a (mostly) obvious fix - iant needed a hint to see what was 
wrong.   The location of this code meant that this would be a very rare 
bug:   only ti mode shifts on an llp64 platform.

bootstrapped and regression tested on x86-64.

committed as revision 188359.

Kenny



2012-06-09  Kenneth Zadeck <zadeck@naturalbridge.com>

     * simplify-rtx.c (simplify_const_binary_operation): Fixed shift
     count trucation.

Patch

Index: gcc/simplify-rtx.c
===================================================================
--- gcc/simplify-rtx.c    (revision 188350)
+++ gcc/simplify-rtx.c    (working copy)
@@ -3653,7 +3653,10 @@  simplify_const_binary_operation (enum rt
          unsigned HOST_WIDE_INT cnt;

          if (SHIFT_COUNT_TRUNCATED)
-          o1 = double_int_zext (o1, GET_MODE_PRECISION (mode));
+          {
+        o1.high = 0;
+        o1.low &= GET_MODE_PRECISION (mode) - 1;
+          }

          if (!double_int_fits_in_uhwi_p (o1)
              || double_int_to_uhwi (o1) >= GET_MODE_PRECISION (mode))