public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jamborm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/114985] [15 regression] internal compiler error: in discriminator_fail during stage2
Date: Wed, 15 May 2024 20:49:04 +0000	[thread overview]
Message-ID: <bug-114985-4-2opNBs9FQt@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114985-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #20 from Martin Jambor <jamborm at gcc dot gnu.org> ---
The IL we generate the jump function from is:
  <bb 2>
  _1 = cclauses_2(D) != 0B;
  c_parser_omp_all_clauses (_1);

Which translates to the expected jump function:
  callsite  void c_parser_omp_teams(int**)/3 -> int*
c_parser_omp_all_clauses(bool)/1 :
     param 0: PASS THROUGH: 0, op ne_expr 0B

so IPA looks like it's doing what it should.

(In reply to Aldy Hernandez from comment #6)
> I wonder if something like this would work.
> 
> diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
> index 5781f50..ea8a685 100644
> --- a/gcc/ipa-cp.cc
> +++ b/gcc/ipa-cp.cc
> @@ -1730,6 +1730,8 @@ ipa_value_range_from_jfunc (vrange &vr,
>         }
>        else
>         {
> +         if (TREE_CODE_CLASS (operation) == tcc_comparison)
> +           vr_type = boolean_type_node;
>           Value_Range op_res (vr_type);
>           Value_Range res (vr_type);
>           tree op = ipa_get_jf_pass_through_operand (jfunc);

This looks OKish and we also do a similar thing in
ipa_get_jf_arith_result.

Also note that the ipa_value_range_from_jfunc already has a parameter
that tells it what type the result should be.  It is called parm_type,
which is boolean_type in the case that ICEs.  So we can even bail out
if we really encounter jump function created from bad IL.

I was thinking of using use parm_type from the beginning, to
initialize op_res with it, but there are jump functions representing
an operation followed by a truncation, for example for:

  _2 = complain_6(D) & 1;
  _3 = (int) std_alignof_7(D);
  cxx_sizeof_or_alignof_type (_3, _2);

where _r is in fact bool (has smaller size and precision) and trying
to make ranger do the bit_and_expr directly to bool leads to a failed
assert in fold_range (the test of m_operator->operand_check_p).

So doing the operation in the original type - unless it is a
comparison - and then using ipa_vr_operation_and_type_effects seems to
be the right thing to do.

But I am really curious why propagate_vr_across_jump_function does not
need the same check for tcc_comparison operators and generally why is
it so different (in the non-scc case)?  Why is ipa_supports_p (this
predicate has a really really really bad name BTW and I am completely
at loss as to what it does and how or why) used there and not in
ipa_value_range_from_jfunc?

(I also cannot prevent myself from ranting a little that it would
really help if all the ranger (helper) classes and functions were
better documented.)

  parent reply	other threads:[~2024-05-15 20:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08 12:59 [Bug bootstrap/114985] New: " seurer at gcc dot gnu.org
2024-05-08 15:00 ` [Bug bootstrap/114985] " seurer at gcc dot gnu.org
2024-05-08 15:35 ` aldyh at gcc dot gnu.org
2024-05-08 16:34 ` seurer at gcc dot gnu.org
2024-05-08 16:34 ` aldyh at gcc dot gnu.org
2024-05-08 17:06 ` [Bug ipa/114985] " pinskia at gcc dot gnu.org
2024-05-08 20:33 ` aldyh at gcc dot gnu.org
2024-05-08 22:28 ` seurer at gcc dot gnu.org
2024-05-09 14:21 ` seurer at gcc dot gnu.org
2024-05-09 16:27 ` dje at gcc dot gnu.org
2024-05-09 21:54 ` aldyh at gcc dot gnu.org
2024-05-09 22:36 ` aldyh at gcc dot gnu.org
2024-05-10  9:27 ` aldyh at gcc dot gnu.org
2024-05-10 12:13 ` ro at CeBiTec dot Uni-Bielefeld.DE
2024-05-10 12:49 ` hubicka at gcc dot gnu.org
2024-05-10 14:38 ` segher at gcc dot gnu.org
2024-05-10 16:15 ` jamborm at gcc dot gnu.org
2024-05-11  9:47 ` aldyh at gcc dot gnu.org
2024-05-11  9:48 ` aldyh at gcc dot gnu.org
2024-05-13 14:06 ` jamborm at gcc dot gnu.org
2024-05-15 20:49 ` jamborm at gcc dot gnu.org [this message]
2024-05-15 21:06 ` amacleod at redhat dot com
2024-05-16  8:16 ` aldyh at gcc dot gnu.org
2024-05-16  9:59 ` cvs-commit at gcc dot gnu.org
2024-05-16  9:59 ` cvs-commit at gcc dot gnu.org
2024-05-16 10:07 ` aldyh at gcc dot gnu.org
2024-05-16 10:58 ` ro at CeBiTec dot Uni-Bielefeld.DE
2024-05-16 11:49 ` aldyh at gcc dot gnu.org
2024-05-16 11:58 ` ro at CeBiTec dot Uni-Bielefeld.DE
2024-05-16 12:50 ` aldyh at gcc dot gnu.org
2024-05-16 12:56 ` aldyh at gcc dot gnu.org
2024-05-16 13:04 ` ro at CeBiTec dot Uni-Bielefeld.DE
2024-05-16 14:24 ` aldyh at gcc dot gnu.org
2024-05-16 19:06 ` segher at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-114985-4-2opNBs9FQt@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).