This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug tree-optimization/63641] Invalid shift leads to incorrect code on 32-bit system


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63641

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-10-24
                 CC|                            |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'd say the right fix would be instead:
--- gcc/tree-ssa-reassoc.c    2014-10-17 12:53:59.286321210 +0200
+++ gcc/tree-ssa-reassoc.c    2014-10-24 22:38:55.762859480 +0200
@@ -2513,7 +2513,7 @@ optimize_range_tests_to_bit_test (enum t
     {
       tree high = wide_int_to_tree (TREE_TYPE (lowi),
                     wi::to_widest (lowi)
-                    + prec - wi::clz (mask));
+                    + prec - 1 - wi::clz (mask));
       operand_entry_t oe = (*ops)[ranges[i].idx];
       tree op = oe->op;
       gimple stmt = op ? SSA_NAME_DEF_STMT (op)
there is no need to build further trees, and the other use of high also wants
the one smaller value.
The thing is, bit 0 of mask is value lowi, if e.g. wi::clz(mask) is 0, then
it means the topmost bit of mask is set, so the highest value in the interval
is
lowi + prec - 1.  If only lowest bit of mask would be set (not possible, at
least 3 ranges of bits need to be there), then wi::clz(mask) would be prec - 1
and we'd want high to be equal to lowi.  Mask is never zero.


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