[PATCH]Fix PR66556. Don't drop side-effect in simplify_const_relational_operation function.

Renlin Li renlin.li@arm.com
Wed Jul 8 15:03:00 GMT 2015


Hi all,

In simplify_const_relational_operation function, there are cases a const rtx
will be returned.

Three cases are considered in this function:
1, comparisons with upper and lower bounds.
2, Integer comparisons with zero.
3, comparison of ABS with zero.

It's fine to to the optimization if the operands have no side-effects.

For example, I am currently fixing a code generation bug for armv7-a 
bigendian.
It turns out that, the following rtx is simplified into a const, and the
side-effect with it is ignored.

(ltu:SI (lshiftrt:SI (subreg:SI (mem/c:HI (post_modify:SI (reg/f:SI 156)
                     (plus:SI (reg/f:SI 156)
                         (const_int 20 [0x14]))) [5 g+4 S2 A32]) 0)
         (const_int 1 [0x1]))
     (const_int -1 [0xffffffffffffffff]))

------------>>>>>>>>>>>>>>>>>>

(const_int 1 [0x1])

This particular case falls into category 1 mentioned above. -1, when 
regarded
as unsigned integer, is the largest unsigned integer. So the result is 
always
a const_true_rtx in this case. However, the first operand of the comparison
has POST_MODIFY side-effect.

In this case, the simplifications should be checked against side-effect.

x86_64 bootstrapping is Okay and arm-none-eabi regression test runs 
without any new issues.

Okay to commit and backport to branch 5?

Regards,
Renlin Li

gcc/ChangeLog:

2015-07-08  Renlin Li  <renlin.li@arm.com>

         PR rtl/66556
         * simplify-rtx.c (simplify_const_relational_operation): Add
         side_effects_p check.

gcc/testsuite/ChangeLog:

2015-07-08  Renlin Li  <renlin.li@arm.com>

         PR rtl/66556
         * gcc.c-torture/execute/pr66556.c: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new.diff
Type: text/x-patch
Size: 2097 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150708/c2d4da12/attachment.bin>


More information about the Gcc-patches mailing list