public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/105192] New: ICE: in gen_reg_rtx, at emit-rtl.cc:1167 (during RTL pass: ce3) with -O -fno-if-conversion -fharden-compares
@ 2022-04-07  7:02 zsojka at seznam dot cz
  2022-11-16 20:09 ` [Bug target/105192] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: zsojka at seznam dot cz @ 2022-04-07  7:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105192
           Summary: ICE: in gen_reg_rtx, at emit-rtl.cc:1167 (during RTL
                    pass: ce3) with -O -fno-if-conversion
                    -fharden-compares
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: mips64el-unknown-linux-gnuabi64

Created attachment 52764
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52764&action=edit
reduced testcase

Maybe related to PR102478

Compiler output:
$ mips64el-unknown-linux-gnuabi64-gcc -O -fno-if-conversion -fharden-compares
testcase.c 
testcase.c: In function 'foo':
testcase.c:6:9: warning: division by zero [-Wdiv-by-zero]
    6 |   b = a % 0 > 0;
      |         ^
during RTL pass: ce3
testcase.c:7:1: internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1167
    7 | }
      | ^
0x617bec gen_reg_rtx(machine_mode)
        /repo/gcc-trunk/gcc/emit-rtl.cc:1167
0xb25149 force_reg(machine_mode, rtx_def*)
        /repo/gcc-trunk/gcc/explow.cc:677
0x12ac906 mips_expand_conditional_trap(rtx_def*)
        /repo/gcc-trunk/gcc/config/mips/mips.cc:5815
0x16934d6 gen_ctrapsi4(rtx_def*, rtx_def*, rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/config/mips/mips.md:1222
0xde84b9 rtx_insn* insn_gen_fn::operator()<rtx_def*, rtx_def*, rtx_def*,
rtx_def*>(rtx_def*, rtx_def*, rtx_def*, rtx_def*) const
        /repo/gcc-trunk/gcc/recog.h:407
0xde84b9 gen_cond_trap(rtx_code, rtx_def*, rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/optabs.cc:5938
0x182645c find_cond_trap
        /repo/gcc-trunk/gcc/ifcvt.cc:5076
0x182645c find_if_header
        /repo/gcc-trunk/gcc/ifcvt.cc:4701
0x182645c if_convert
        /repo/gcc-trunk/gcc/ifcvt.cc:5838
0x182724d execute
        /repo/gcc-trunk/gcc/ifcvt.cc:5991
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ mips64el-unknown-linux-gnuabi64-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-mips64el/bin/mips64el-unknown-linux-gnuabi64-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r12-8030-20220406184252-g61bee6aed26-checking-yes-rtl-df-extra-mips64el/bin/../libexec/gcc/mips64el-unknown-linux-gnuabi64/12.0.1/lto-wrapper
Target: mips64el-unknown-linux-gnuabi64
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--with-cloog --with-ppl --with-isl
--with-sysroot=/usr/mips64el-unknown-linux-gnuabi64 --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=mips64el-unknown-linux-gnuabi64
--with-ld=/usr/bin/mips64el-unknown-linux-gnuabi64-ld
--with-as=/usr/bin/mips64el-unknown-linux-gnuabi64-as --disable-multilib
--with-abi=64 --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r12-8030-20220406184252-g61bee6aed26-checking-yes-rtl-df-extra-mips64el
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.1 20220406 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug target/105192] ICE: in gen_reg_rtx, at emit-rtl.cc:1167 (during RTL pass: ce3) with -O -fno-if-conversion -fharden-compares
  2022-04-07  7:02 [Bug rtl-optimization/105192] New: ICE: in gen_reg_rtx, at emit-rtl.cc:1167 (during RTL pass: ce3) with -O -fno-if-conversion -fharden-compares zsojka at seznam dot cz
@ 2022-11-16 20:09 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-16 20:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-11-16
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Something like this might fix the issue:
apinski@xeond:~/src/upstream-gcc/gcc/gcc$ git diff config/mips/mips.md
diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md
index e0f0a582732..3419f4df307 100644
--- a/gcc/config/mips/mips.md
+++ b/gcc/config/mips/mips.md
@@ -1217,7 +1217,7 @@ (define_expand "ctrap<mode>4"
                            [(match_operand:GPR 1 "reg_or_0_operand")
                             (match_operand:GPR 2 "arith_operand")])
            (match_operand 3 "const_0_operand"))]
-  "ISA_HAS_COND_TRAPI || ISA_HAS_COND_TRAP"
+  "can_create_pseudo_p () && (ISA_HAS_COND_TRAPI || ISA_HAS_COND_TRAP")
 {
   mips_expand_conditional_trap (operands[0]);
   DONE;

I have no way to test it though.
But what is happening from the backtrace and where the assert is:
* the post-reload ifcvt is detecting a conditional trap and the mips backend
didn't expect any post-reload (really !can_create_pseudo_p ()) detection of a
condtional trap happening so it thought it could use force_reg (which might
create a new pseudo register).

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-16 20:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07  7:02 [Bug rtl-optimization/105192] New: ICE: in gen_reg_rtx, at emit-rtl.cc:1167 (during RTL pass: ce3) with -O -fno-if-conversion -fharden-compares zsojka at seznam dot cz
2022-11-16 20:09 ` [Bug target/105192] " pinskia at gcc dot gnu.org

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).