From: Senthil Kumar Selvaraj Date: Mon, 17 Dec 2018 10:50:54 +0000 (+0000) Subject: re PR rtl-optimization/88253 (Inlining of function incorrectly deletes volatile regis... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d7c00826362598d636ef1eb92a1b194d46b41473;p=gcc.git re PR rtl-optimization/88253 (Inlining of function incorrectly deletes volatile register access when using XOR in avr-gcc) Fix PR 88253 gcc/ChangeLog: PR rtl-optimization/88253 * combine.c (combine_simplify_rtx): Test for side-effects before substituting by zero. gcc/testsuite/ChangeLog: PR rtl-optimization/88253 * gcc.target/avr/pr88253.c: New test. From-SVN: r267198 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 83900c5b674..e63c4c9b50b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +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 Richard Sandiford * doc/invoke.texi (-fversion-loops-for-strides): Document diff --git a/gcc/combine.c b/gcc/combine.c index 7e611399f2c..220c3a45631 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -5978,8 +5978,9 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest, && known_eq (subreg_lowpart_offset (int_mode, int_op0_mode), SUBREG_BYTE (x)) && HWI_COMPUTABLE_MODE_P (int_op0_mode) - && (nonzero_bits (SUBREG_REG (x), int_op0_mode) - & GET_MODE_MASK (int_mode)) == 0) + && ((nonzero_bits (SUBREG_REG (x), int_op0_mode) + & GET_MODE_MASK (int_mode)) == 0) + && !side_effects_p (SUBREG_REG (x))) return CONST0_RTX (int_mode); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6fc2f0c9e5a..8ba858b5177 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-17 Senthil Kumar Selvaraj + + PR rtl-optimization/88253 + * gcc.target/avr/pr88253.c: New test. + 2018-12-17 Richard Sandiford * gcc.dg/loop-versioning-1.c: New test. diff --git a/gcc/testsuite/gcc.target/avr/pr88253.c b/gcc/testsuite/gcc.target/avr/pr88253.c new file mode 100644 index 00000000000..7fa7e4efc69 --- /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" } } */