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

--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #4)
> +       /* If that didn't simplify to a constant see if we have recorded
> +          temporary expressions from taken edges.  */
> +       if (!val || TREE_CODE (val) != INTEGER_CST)
> +         {
> +           tree ops[2];
> +           ops[0] = gimple_cond_lhs (stmt);
> +           ops[1] = gimple_cond_rhs (stmt);
> +           val = vn_nary_op_lookup_pieces (2, gimple_cond_code (stmt),
> +                                           boolean_type_node, ops, NULL);
> +         }
> 
> turns
> 
> <ssa_name 0x7f20520c9af8
>     type <integer_type 0x7f2055314d20 size_type sizes-gimplified asm_written
> used unsigned type_6 SI
>         size <integer_cst 0x7f2058946e58 constant 32>
>         unit size <integer_cst 0x7f2058946e70 constant 4>
>         align 32 symtab 1390664112 alias set -1 canonical type
> 0x7f205894a888 precision 32 min <integer_cst 0x7f20589670f0 0> max
> <integer_cst 0x7f20589670d8 4294967295>>
>     visited var <parm_decl 0x7f20540e7900 __n>def_stmt GIMPLE_NOP
> 
>     version 5>
>  <integer_cst 0x7f205253ce70 type <integer_type 0x7f2058aaa498 size_t>
> constant 536870911>
> 
> if (__n_5(D) > 536870911)
> 
> into
> 
>  <integer_cst 0x7f2058967210 type <boolean_type 0x7f205894ad20 bool>
> constant 0>
> 
> This can't be right.

If that's the transform done to
_ZN9__gnu_cxx20throw_allocator_baseINSt8__detail10_Hash_nodeIiLb0EEENS_15limit_conditionEE8allocateEjPKv
then that looks perfectly valid.  We have


  <bb 2>:
  if (__n_5(D) > 536870911)
    goto <bb 3>;
  else
    goto <bb 4>;

  <bb 3>:
  std::__throw_bad_alloc ();

  <bb 4>:
  _18 = _S_count;
  _19 = _S_limit;
  if (_18 == _19)
    goto <bb 5>;
  else
    goto <bb 6>;

  <bb 5>:
  __gnu_cxx::__throw_forced_error ();

  <bb 6>:
  _20 = _18 + 1;
  _S_count = _20;
  _8 = &this_2(D)->_M_allocator;
  if (__n_5(D) > 536870911)
    goto <bb 7>;
  else
    goto <bb 8>;

and we optimize the compare in bb 6 which is redundant as the one in BB2
dominates it.

Can you check whether disabling PRE fixes the runtime failure?

Maybe it is also just inlining of the above function that is enabled by
the patch and causes followup errors.

Reply via email to