From: Bernd Edlinger Date: Mon, 23 Jul 2018 13:23:51 +0000 (+0000) Subject: re PR c/86617 (Volatile qualifier is ignored sometimes for unsigned char) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1544db9a61b6a441be68c5a6ba2504a6ccc2b956;p=gcc.git re PR c/86617 (Volatile qualifier is ignored sometimes for unsigned char) gcc: 2018-07-23 Bernd Edlinger PR c/86617 * genmatch.c (dt_operand::gen_match_op): Avoid folding volatile values. testsuite: 2018-07-23 Bernd Edlinger PR c/86617 * gcc.dg/pr86617.c: New test. From-SVN: r262933 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2cbe833dcfd..3f4283fd739 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-07-23 Bernd Edlinger + + PR c/86617 + * genmatch.c (dt_operand::gen_match_op): Avoid folding volatile values. + 2018-07-23 Bernd Edlinger * gimple-fold.c (gimple_fold_builtin_printf): Don't create a not NUL diff --git a/gcc/genmatch.c b/gcc/genmatch.c index 5d6cf0b4d3a..5848722684b 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b5e2a54e9b2..5e6b8eb87d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-23 Bernd Edlinger + + PR c/86617 + * gcc.dg/pr86617.c: New test. + 2018-07-23 Jakub Jelinek PR c++/86569 diff --git a/gcc/testsuite/gcc.dg/pr86617.c b/gcc/testsuite/gcc.dg/pr86617.c new file mode 100644 index 00000000000..72135e205bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr86617.c @@ -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" } } */