optabs: Fix up checking for CALLs in newly added code by double-word divmod [PR103838]
authorJakub Jelinek <jakub@redhat.com>
Tue, 28 Dec 2021 16:39:23 +0000 (17:39 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 28 Dec 2021 16:39:23 +0000 (17:39 +0100)
commit78ee8381bf0ebd09a92936bdb9e1b5c9fc85ad88
tree032675bfeb3a109a91ad922bbb271b09a5344097
parentcff8fa9a44062b3b05bbfc8b077214dd6c50710a
optabs: Fix up checking for CALLs in newly added code by double-word divmod [PR103838]

These two spots are meant to punt if the newly added code contains
any CALL_INSNs, because in that case having a large sequence of insns
that also calls something is undesirable, better have one call that
is optimized in itself well.
The functions do last = get_last_insn (); before emitting any insns
(and expand_binop as the ultimate caller uses delete_insns_since if
the expansion fails), but the checks were incorrect for 2 reasons:
1) it checked not just what follows after that last insn, but also
   the last insn itself; so, if the division or modulo is immediately
   preceded by a CALL_INSN, then we punt; this also causes -fcompare-debug
   failures if the CALL_INSN is with -g followed by one or more DEBUG_INSNs
2) if get_last_insn () is NULL (i.e. emitting into a new sequence), then
   we didn't check anything

2021-12-28  Jakub Jelinek  <jakub@redhat.com>

PR debug/103838
* optabs.c (expand_doubleword_mod, expand_doubleword_divmod): Only
check newly added insns for CALL_P, not the last insn of previous
code.

* gcc.dg/pr103838.c: New test.
gcc/optabs.c
gcc/testsuite/gcc.dg/pr103838.c [new file with mode: 0644]