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

            Bug ID: 85368
           Summary: [8 regression] phi-opt-11 test fails on IBM Z
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: krebbel at gcc dot gnu.org
  Target Milestone: ---

No IF statements remain although LOGICAL_OP_NON_SHORT_CIRCUIT is not
defined on S/390 and hence defaults to true when using
-mbranch-cost=2.

The testcase appears to expect 2 IFs to remain for function
h. However, these get removed in phiopt1.

This code turns the TRUTH_ANDIF_EXPR condition into a TRUTH_AND_EXPR:

fold-const.c:8178

  if (LOGICAL_OP_NON_SHORT_CIRCUIT
      && !flag_sanitize_coverage
      && (code == TRUTH_AND_EXPR
          || code == TRUTH_ANDIF_EXPR
          || code == TRUTH_OR_EXPR
          || code == TRUTH_ORIF_EXPR))
    {
      enum tree_code ncode, icode;

      ncode = (code == TRUTH_ANDIF_EXPR || code == TRUTH_AND_EXPR)
              ? TRUTH_AND_EXPR : TRUTH_OR_EXPR;
      icode = ncode == TRUTH_AND_EXPR ? TRUTH_ANDIF_EXPR : TRUTH_ORIF_EXPR;
...

      /* Transform (A AND-IF B) into (A AND B), or (A OR-IF B)
         into (A OR B).
         For sequence point consistancy, we need to check for trapping,
         and side-effects.  */
      else if (code == icode && simple_operand_p_2 (arg0)
               && simple_operand_p_2 (arg1))
        return fold_build2_loc (loc, ncode, type, arg0, arg1);


ANDIFs would be split into two separate IFs but since it had been replaced with
and AND instead the truth value gets computed by the gimplifier:

004t.gimple

h (int a, int b, int c, int d)
{
  int D.2246;

  _1 = a == d;
  _2 = b > c;
  _3 = _1 & _2;
  if (_3 != 0) goto <D.2244>; else goto <D.2245>;
  <D.2244>:
  D.2246 = d;
  // predicted unlikely by early return (on trees) predictor.
  return D.2246;
  <D.2245>:
  D.2246 = a;
  return D.2246;
}

which eventually gets optimized in phiop1 to:

Removing basic block 3
;; basic block 3, loop depth 0
;;  pred:       2
;;  succ:       4


COND_EXPR in block 2 and PHI in block 4 converted to straightline code.
Merging blocks 2 and 4
fix_loop_structure: fixing up loops for function
h (int a, int b, int c, int d)
{
  _Bool _1;
  _Bool _2;
  _Bool _3;

  <bb 2> [local count: 1073741825]:
  _1 = a_5(D) == d_6(D);
  _2 = b_7(D) > c_8(D);
  _3 = _1 & _2;
  return a_5(D);
}

No IFs.

Reply via email to