]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/110200 - genmatch force-leaf and convert interaction
authorRichard Biener <rguenther@suse.de>
Mon, 12 Jun 2023 08:17:26 +0000 (10:17 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 12 Jun 2023 09:02:15 +0000 (11:02 +0200)
The following fixes code GENERIC generation for (convert! ...)
which currently generates

  if (TREE_TYPE (_o1[0]) != type)
    _r1 = fold_build1_loc (loc, NOP_EXPR, type, _o1[0]);
    if (EXPR_P (_r1))
      goto next_after_fail867;
  else
    _r1 = _o1[0];

where obviously braces are missing.

PR middle-end/110200
* genmatch.cc (expr::gen_transform): Put braces around
the if arm for the (convert ...) short-cut.

(cherry picked from commit 820d1aec89c43dbbc70d3d0b888201878388454c)

gcc/genmatch.cc

index 4fab4135347c43d95546a7df0bb1c4d074937288..98b429a9d0bb3130246e375a9cef46528f0f9467 100644 (file)
@@ -2568,7 +2568,8 @@ expr::gen_transform (FILE *f, int indent, const char *dest, bool gimple,
        {
          fprintf_indent (f, indent, "if (TREE_TYPE (_o%d[0]) != %s)\n",
                          depth, type);
-         indent += 2;
+         fprintf_indent (f, indent + 2, "{\n");
+         indent += 4;
        }
       if (opr->kind == id_base::CODE)
        fprintf_indent (f, indent, "_r%d = fold_build%d_loc (loc, %s, %s",
@@ -2591,7 +2592,8 @@ expr::gen_transform (FILE *f, int indent, const char *dest, bool gimple,
        }
       if (*opr == CONVERT_EXPR)
        {
-         indent -= 2;
+         fprintf_indent (f, indent - 2, "}\n");
+         indent -= 4;
          fprintf_indent (f, indent, "else\n");
          fprintf_indent (f, indent, "  _r%d = _o%d[0];\n", depth, depth);
        }