From: Senthil Kumar Selvaraj Date: Mon, 17 Dec 2018 13:26:50 +0000 (+0000) Subject: backport: re PR rtl-optimization/88253 (Inlining of function incorrectly deletes... X-Git-Tag: releases/gcc-7.5.0~717 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80ad71d18983467ff41b7f99aef25e1b2b647c7c;p=thirdparty%2Fgcc.git backport: re PR rtl-optimization/88253 (Inlining of function incorrectly deletes volatile register access when using XOR in avr-gcc) 2018-12-17 Senthil Kumar Selvaraj Backport from trunk 2018-12-17 Senthil Kumar Selvaraj PR rtl-optimization/88253 * combine.c (combine_simplify_rtx): Test for side-effects before substituting by zero. 2018-12-17 Senthil Kumar Selvaraj Backport from trunk 2018-12-17 Senthil Kumar Selvaraj PR rtl-optimization/88253 * gcc.target/avr/pr88253.c: New test. From-SVN: r267201 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fc096324ec29..d1507bfb50f7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-12-17 Senthil Kumar Selvaraj + + Backport from trunk + 2018-12-17 Senthil Kumar Selvaraj + + PR rtl-optimization/88253 + * combine.c (combine_simplify_rtx): Test for side-effects before + substituting by zero. + 2018-12-15 Segher Boessenkool Backport from trunk diff --git a/gcc/combine.c b/gcc/combine.c index bc023d2f994a..56f7f4912343 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -5807,8 +5807,9 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest, && GET_MODE_PRECISION (mode) < GET_MODE_PRECISION (op0_mode) && subreg_lowpart_offset (mode, op0_mode) == SUBREG_BYTE (x) && HWI_COMPUTABLE_MODE_P (op0_mode) - && (nonzero_bits (SUBREG_REG (x), op0_mode) - & GET_MODE_MASK (mode)) == 0) + && ((nonzero_bits (SUBREG_REG (x), op0_mode) + & GET_MODE_MASK (mode)) == 0) + && !side_effects_p (SUBREG_REG (x))) return CONST0_RTX (mode); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9c464fcef2c..8344276af915 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2018-12-17 Senthil Kumar Selvaraj + + Backport from trunk + 2018-12-17 Senthil Kumar Selvaraj + + PR rtl-optimization/88253 + * gcc.target/avr/pr88253.c: New test. + 2018-12-15 Steven G. Kargl PR fortran/88138 diff --git a/gcc/testsuite/gcc.target/avr/pr88253.c b/gcc/testsuite/gcc.target/avr/pr88253.c new file mode 100644 index 000000000000..7fa7e4efc691 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr88253.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -w" } */ + +static int aRead() __attribute__((always_inline)); +static int aRead() { + unsigned char h,l; + l = (*(volatile unsigned char *)(0x78)) ; + h = (*(volatile unsigned char *)(0x79)) ; + return (h<<8) | l; +} + +int main() { + volatile unsigned char x; + x = aRead()^42; + } + /* { dg-final { scan-assembler "lds r\\d+,121" } } */