public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/114044] ICE: in expand_fn_using_insn, at internal-fn.cc:208 with _BitInt() and -O -fno-tree-dce
Date: Thu, 22 Feb 2024 17:07:54 +0000	[thread overview]
Message-ID: <bug-114044-4-zYn5oOohN2@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114044-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Smaller testcase:
void
foo (void)
{
  unsigned _BitInt(256) a = 3;
  __builtin_clzg (a);
}

The thing is that in this testcase bitint lowering doesn't even know it should
do anything.
The whole behavior of the pass is keyed on there being any SSA_NAMEs for
middle/large/huge BITINT_TYPE with some extra exceptions (it looks at virtual
SSA_NAMEs to see if there isn't a memory store of a middle+ _BitInt INTEGER_CST
and for scalar floating point SSA_NAMEs if they aren't computed from conversion
from middle+ _BitInt INTEGER_CSTs), and even if the pass for some other reason
triggers in the function,
it will not look at statements which don't have any large+ _BitInt SSA_NAMEs,
or are large+ _BitInt INTEGER_CST store or FLOAT_EXPR from large+ _BitInt
INTEGER_CST or the overflow ifns with _Complex large+ _BitInt result.
We really don't want to lower those ifns like
.CLZ/.CTZ/.CLRSB/.POPCOUNT/.PARITY/.FFS
with INTEGER_CST operands, or after all even say .ADD_OVERFLOW (0, 1) where
just operands are large/huge _BitInt but say _Complex int result, those are all
expected to be folded instead.
Now, if s/^void/int;s/__builtin/return &/' above, we fold it in
gimple_fold_stmt_to_constant_1:
#0  wi::clz (x=...) at ../../gcc/wide-int.cc:2164
#1  0x00000000008a9d9b in fold_const_call_ss (result=0x7fffffffc4e0,
fn=CFN_CLZ, arg=..., precision=32, arg_type=<bitint_type 0x7fffea2db5e8>) at
../../gcc/fold-const-call.cc:1029
#2  0x00000000008aa9a5 in fold_const_call_1 (fn=CFN_CLZ, type=<integer_type
0x7fffea14c5e8 int>, arg=<integer_cst 0x7fffea2e5c18>) at
../../gcc/fold-const-call.cc:1254
#3  0x00000000008ab4d6 in fold_const_call (fn=CFN_CLZ, type=<integer_type
0x7fffea14c5e8 int>, arg=<integer_cst 0x7fffea2e5c18>) at
../../gcc/fold-const-call.cc:1385
#4  0x000000000189d6e0 in gimple_resimplify1 (seq=0x0, res_op=0x7fffffffc980,
valueize=0xf42f7d <valueize_op_1(tree)>) at
../../gcc/gimple-match-exports.cc:925
#5  0x000000000189b419 in gimple_match_op::resimplify (this=0x7fffffffc980,
seq=0x0, valueize=0xf42f7d <valueize_op_1(tree)>) at
../../gcc/gimple-match-exports.cc:111
#6  0x000000000189d5b3 in gimple_simplify (stmt=<gimple_call 0x7fffea13aea0>,
res_op=0x7fffffffc980, seq=0x0, valueize=0xf42f7d <valueize_op_1(tree)>, 
    top_valueize=0xf42f41 <valueize_op(tree)>) at
../../gcc/gimple-match-exports.cc:898
#7  0x000000000090986a in gimple_fold_stmt_to_constant_1 (stmt=<gimple_call
0x7fffea13aea0>, valueize=0xf42f41 <valueize_op(tree)>, gvalueize=0xf42f7d
<valueize_op_1(tree)>)
    at ../../gcc/gimple-fold.cc:7551
#8  0x0000000000f4308a in ccp_fold (stmt=<gimple_call 0x7fffea13aea0>) at
../../gcc/tree-ssa-ccp.cc:1290
#9  0x0000000000f48d1b in evaluate_stmt (stmt=<gimple_call 0x7fffea13aea0>) at
../../gcc/tree-ssa-ccp.cc:2228
or with extra -fno-tree-ccp in:
#0  wi::clz (x=...) at ../../gcc/wide-int.cc:2164
#1  0x00000000008a9d9b in fold_const_call_ss (result=0x7fffffffceb0,
fn=CFN_CLZ, arg=..., precision=32, arg_type=<bitint_type 0x7fffea2db5e8>) at
../../gcc/fold-const-call.cc:1029
#2  0x00000000008aa9a5 in fold_const_call_1 (fn=CFN_CLZ, type=<integer_type
0x7fffea14c5e8 int>, arg=<integer_cst 0x7fffea2e5c18>) at
../../gcc/fold-const-call.cc:1254
#3  0x00000000008ab4d6 in fold_const_call (fn=CFN_CLZ, type=<integer_type
0x7fffea14c5e8 int>, arg=<integer_cst 0x7fffea2e5c18>) at
../../gcc/fold-const-call.cc:1385
#4  0x000000000189d6e0 in gimple_resimplify1 (seq=0x7fffffffd278,
res_op=0x7fffffffd200, valueize=0xf811c3 <fwprop_ssa_val(tree)>) at
../../gcc/gimple-match-exports.cc:925
#5  0x000000000189b419 in gimple_match_op::resimplify (this=0x7fffffffd200,
seq=0x7fffffffd278, valueize=0xf811c3 <fwprop_ssa_val(tree)>) at
../../gcc/gimple-match-exports.cc:111
#6  0x000000000189d5b3 in gimple_simplify (stmt=<gimple_call 0x7fffea13ae10>,
res_op=0x7fffffffd200, seq=0x7fffffffd278, valueize=0xf811c3
<fwprop_ssa_val(tree)>, 
    top_valueize=0xf811c3 <fwprop_ssa_val(tree)>) at
../../gcc/gimple-match-exports.cc:898
#7  0x00000000009060dd in fold_stmt_1 (gsi=0x7fffffffd630, inplace=false,
valueize=0xf811c3 <fwprop_ssa_val(tree)>) at ../../gcc/gimple-fold.cc:6359
#8  0x0000000000906833 in fold_stmt (gsi=0x7fffffffd630, valueize=0xf811c3
<fwprop_ssa_val(tree)>) at ../../gcc/gimple-fold.cc:6525
or with extra -fno-tree-ccp -fno-tree-forwprop in:
#0  wi::clz (x=...) at ../../gcc/wide-int.cc:2164
#1  0x00000000008a9d9b in fold_const_call_ss (result=0x7fffffffcd50,
fn=CFN_CLZ, arg=..., precision=32, arg_type=<bitint_type 0x7fffea2db5e8>) at
../../gcc/fold-const-call.cc:1029
#2  0x00000000008aa9a5 in fold_const_call_1 (fn=CFN_CLZ, type=<integer_type
0x7fffea14c5e8 int>, arg=<integer_cst 0x7fffea2e5c18>) at
../../gcc/fold-const-call.cc:1254
#3  0x00000000008ab4d6 in fold_const_call (fn=CFN_CLZ, type=<integer_type
0x7fffea14c5e8 int>, arg=<integer_cst 0x7fffea2e5c18>) at
../../gcc/fold-const-call.cc:1385
#4  0x000000000189d6e0 in gimple_resimplify1 (seq=0x0, res_op=0x7fffffffd1f0,
valueize=0x906784 <no_follow_ssa_edges(tree_node*)>) at
../../gcc/gimple-match-exports.cc:925
#5  0x000000000189b419 in gimple_match_op::resimplify (this=0x7fffffffd1f0,
seq=0x0, valueize=0x906784 <no_follow_ssa_edges(tree_node*)>) at
../../gcc/gimple-match-exports.cc:111
#6  0x000000000189d5b3 in gimple_simplify (stmt=<gimple_call 0x7fffea13ae10>,
res_op=0x7fffffffd1f0, seq=0x0, valueize=0x906784
<no_follow_ssa_edges(tree_node*)>, 
    top_valueize=0x106aeba <rpo_vn_valueize(tree_node*)>) at
../../gcc/gimple-match-exports.cc:898
#7  0x000000000090986a in gimple_fold_stmt_to_constant_1 (stmt=<gimple_call
0x7fffea13ae10>, valueize=0x106aeba <rpo_vn_valueize(tree_node*)>, 
    gvalueize=0x906784 <no_follow_ssa_edges(tree_node*)>) at
../../gcc/gimple-fold.cc:7551
#8  0x000000000106502d in visit_stmt (stmt=<gimple_call 0x7fffea13ae10>,
backedges_varying_p=false) at ../../gcc/tree-ssa-sccvn.cc:6419
etc.
But somehow none of that triggers if the internal fn doesn't have lhs, we just
rely on DCE and DCE can be disabled.
Dunno, shall we just ignore those during expansion if they don't have lhs?

  parent reply	other threads:[~2024-02-22 17:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22  7:01 [Bug rtl-optimization/114044] New: " zsojka at seznam dot cz
2024-02-22  7:24 ` [Bug rtl-optimization/114044] " pinskia at gcc dot gnu.org
2024-02-22 12:06 ` rguenth at gcc dot gnu.org
2024-02-22 17:07 ` jakub at gcc dot gnu.org [this message]
2024-02-26 15:24 ` jakub at gcc dot gnu.org
2024-02-27  8:55 ` cvs-commit at gcc dot gnu.org
2024-02-27  9:04 ` jakub 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-114044-4-zYn5oOohN2@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).