]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc:
authoredlinger <edlinger@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Jul 2018 13:23:51 +0000 (13:23 +0000)
committeredlinger <edlinger@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Jul 2018 13:23:51 +0000 (13:23 +0000)
2018-07-23  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c/86617
        * genmatch.c (dt_operand::gen_match_op): Avoid folding volatile values.

testsuite:
2018-07-23  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c/86617
        * gcc.dg/pr86617.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262933 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/genmatch.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr86617.c [new file with mode: 0644]

index 2cbe833dcfd3d8cc85afa34bf8e5632be9ab1f72..3f4283fd739277885e9ab271376c580d25523f7a 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-23  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       PR c/86617
+       * genmatch.c (dt_operand::gen_match_op): Avoid folding volatile values.
+
 2018-07-23  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * gimple-fold.c (gimple_fold_builtin_printf): Don't create a not NUL
index 5d6cf0b4d3a75ec1d3e64d814df829feff399f29..5848722684b0d66bf86c2c75d043007be219fb2d 100644 (file)
@@ -2748,12 +2748,14 @@ dt_operand::gen_match_op (FILE *f, int indent, const char *opname, bool)
   char match_opname[20];
   match_dop->get_name (match_opname);
   if (value_match)
-    fprintf_indent (f, indent, "if (%s == %s || operand_equal_p (%s, %s, 0))\n",
-                   opname, match_opname, opname, match_opname);
+    fprintf_indent (f, indent, "if ((%s == %s && ! TREE_SIDE_EFFECTS (%s)) "
+                   "|| operand_equal_p (%s, %s, 0))\n",
+                   opname, match_opname, opname, opname, match_opname);
   else
-    fprintf_indent (f, indent, "if (%s == %s || (operand_equal_p (%s, %s, 0) "
+    fprintf_indent (f, indent, "if ((%s == %s && ! TREE_SIDE_EFFECTS (%s)) "
+                   "|| (operand_equal_p (%s, %s, 0) "
                    "&& types_match (%s, %s)))\n",
-                   opname, match_opname, opname, match_opname,
+                   opname, match_opname, opname, opname, match_opname,
                    opname, match_opname);
   fprintf_indent (f, indent + 2, "{\n");
   return 1;
index b5e2a54e9b2f93c5fac7e9e1bf5b7e55ff5a9723..5e6b8eb87d1693f129edb1b641f8e6f54d0056ae 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-23  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       PR c/86617
+       * gcc.dg/pr86617.c: New test.
+
 2018-07-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/86569
diff --git a/gcc/testsuite/gcc.dg/pr86617.c b/gcc/testsuite/gcc.dg/pr86617.c
new file mode 100644 (file)
index 0000000..72135e2
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-options "-Os -fdump-rtl-final" } */
+
+volatile unsigned char u8;
+
+void test (void)
+{
+  u8 = u8 + u8;
+  u8 = u8 - u8;
+}
+
+/* { dg-final { scan-rtl-dump-times "mem/v" 6 "final" } } */