re PR rtl-optimization/88253 (Inlining of function incorrectly deletes volatile regis...
authorSenthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com>
Mon, 17 Dec 2018 10:50:54 +0000 (10:50 +0000)
committerSenthil Kumar Selvaraj <saaadhu@gcc.gnu.org>
Mon, 17 Dec 2018 10:50:54 +0000 (10:50 +0000)
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

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/avr/pr88253.c [new file with mode: 0644]

index 83900c5b67465f9d5c31e1f9064a34c69f1c2e2c..e63c4c9b50bfa46632f00c6fb73848bec93f7084 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-17  Senthil Kumar Selvaraj  <senthilkumar.selvaraj@microchip.com>
+
+       PR rtl-optimization/88253
+       * combine.c (combine_simplify_rtx): Test for side-effects before
+       substituting by zero.
+
 2018-12-17  Richard Sandiford  <richard.sandiford@arm.com>
 
        * doc/invoke.texi (-fversion-loops-for-strides): Document
index 7e611399f2cd7a7ab60b780a2f6a24cb317004cb..220c3a45631bf9b36aa409ba5c47d7229169ca23 100644 (file)
@@ -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);
       }
 
index 6fc2f0c9e5acc612de7ee94c0d6e6c51d4ddd3a5..8ba858b51778e7a8bb3446e89e4f23f6e2eebf26 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-17  Senthil Kumar Selvaraj  <senthilkumar.selvaraj@microchip.com>
+
+       PR rtl-optimization/88253
+       * gcc.target/avr/pr88253.c: New test.
+
 2018-12-17  Richard Sandiford  <richard.sandiford@arm.com>
 
        * 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 (file)
index 0000000..7fa7e4e
--- /dev/null
@@ -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" } } */