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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@267199 138bc75d-0d04-0410-961f-82ee72b054a4
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 613052e..64b299d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/combine.c b/gcc/combine.c
index f81f44a..b24e2b9 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -5910,8 +5910,9 @@
&& 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 f4aa444..31af10f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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-18 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88116
diff --git a/gcc/testsuite/gcc.target/avr/pr88253.c b/gcc/testsuite/gcc.target/avr/pr88253.c
new file mode 100644
index 0000000..a41ca0f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/pr88253.c
@@ -0,0 +1,32 @@
+/* { 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" } } */
+/* { 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" } } */