]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/88253 (Inlining of function incorrectly deletes...
authorSenthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com>
Mon, 17 Dec 2018 13:26:50 +0000 (13:26 +0000)
committerSenthil Kumar Selvaraj <saaadhu@gcc.gnu.org>
Mon, 17 Dec 2018 13:26:50 +0000 (13:26 +0000)
2018-12-17  Senthil Kumar Selvaraj  <senthilkumar.selvaraj@microchip.com>

Backport from trunk
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  Senthil Kumar Selvaraj  <senthilkumar.selvaraj@microchip.com>

Backport from trunk
2018-12-17  Senthil Kumar Selvaraj  <senthilkumar.selvaraj@microchip.com>

PR rtl-optimization/88253
* gcc.target/avr/pr88253.c: New test.

From-SVN: r267201

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

index fc096324ec293f115c0a3bf0b66b8e9210a87328..d1507bfb50f772f1126cf26cc0879b3742c24c65 100644 (file)
@@ -1,3 +1,12 @@
+2018-12-17  Senthil Kumar Selvaraj  <senthilkumar.selvaraj@microchip.com>
+
+       Backport from trunk
+       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-15  Segher Boessenkool  <segher@kernel.crashing.org>
 
        Backport from trunk
index bc023d2f994aa891b95a9a730a93b8fbe8a365e5..56f7f4912343fff019d1eb4716328ecf51d3237f 100644 (file)
@@ -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);
       }
 
index c9c464fcef2c28534eebedcf5a68b70e33e7ab70..8344276af91553f85c2b5d7c68efe6fc940adb0c 100644 (file)
@@ -1,3 +1,11 @@
+2018-12-17  Senthil Kumar Selvaraj  <senthilkumar.selvaraj@microchip.com>
+
+       Backport from trunk
+       2018-12-17  Senthil Kumar Selvaraj  <senthilkumar.selvaraj@microchip.com>
+
+       PR rtl-optimization/88253
+       * gcc.target/avr/pr88253.c: New test.
+
 2018-12-15  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        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 (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" } } */