https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110200

            Bug ID: 110200
           Summary: genmatch generating questionable code with convert and
                    !
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: build
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Add these two patterns to match.pd:
```
/* (convert)(a ? b : CST) -> (a ? (convert)b : CST1) */
(simplify
 (convert (cond @0 @1 CONSTANT_CLASS_P@2))
 (cond @0 (convert @1) (convert! @2)))

 /* (convert)(a ? CST : b) -> (a ? CST1 : (convert)b) */
(simplify
 (convert (cond @0 CONSTANT_CLASS_P@1 @2))
 (cond @0 (convert! @1) (convert @2)))
```

And the code produced by genmatch for generic is:
```
                {
                  tree _o1[1], _r1;
                  _o1[0] = captures[2];
                  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];
                  res_op2 = _r1;
                }

```

I think there is a missing `{`/`}` pair around the fold_build1_loc/if/goto
statements.

Reply via email to