[PATCH] PR tree-optimization/78170: Truncate sign-extended padding when encoding bitfields

Kyrill Tkachov kyrylo.tkachov@foss.arm.com
Tue Nov 1 11:54:00 GMT 2016


Hi all,

In this PR the code writes a -1 to a bitfield of size 17 bits and ends up overwriting another bitfields.
The problem is that the intermediate buffer in encode_tree_to_bitpos holding the value to merge holds
a 24-bit temporary with -1 written to it i.e. sign-extended to all ones. That is how native_encode_expr works.This gets then written to
the final buffer (well, a shifted version of it).

We should instead be truncating the intermediate value to contain zeros in all the bits that we don't want.
This is already performed for big-endian, this patch just wires it up for little-endian.

Bootstrapped and tested on x86_64.
Ok for trunk?

Thanks,
Kyrill

2016-11-01  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR tree-optimization/78170
     * gimple-ssa-store-merging.c (encode_tree_to_bitpos): Truncate padding
     introduced by native_encode_expr on little-endian as well.

2016-11-01  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR tree-optimization/78170
     * gcc.c-torture/execute/pr78170.c: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: store-merging-padding.patch
Type: text/x-patch
Size: 2013 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161101/8ce3ba96/attachment.bin>


More information about the Gcc-patches mailing list