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

            Bug ID: 97939
           Summary: ICE on sparc64 with UBsan for "i + 4096" on long:
                    unrecognizable insn during RTL pass: vregs
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
  Target Milestone: ---

On the following code:

long f (long i)
{
  return i + 4096;
}

I get:

vinc17@gcc202:~$ gcc -fsanitize=undefined -c tst.c
tst.c: In function ‘f’:
tst.c:4:1: error: unrecognizable insn:
    4 | }
      | ^
(insn 7 6 8 2 (parallel [
            (set (reg:CCXV 100 %icc)
                (compare:CCXV (plus:DI (reg:DI 113)
                        (const_int 4096 [0x1000]))
                    (unspec:DI [
                            (reg:DI 113)
                            (const_int 4096 [0x1000])
                        ] UNSPEC_ADDV)))
            (set (reg:DI 112)
                (plus:DI (reg:DI 113)
                    (const_int 4096 [0x1000])))
        ]) "tst.c":3:12 -1
     (nil))
during RTL pass: vregs
tst.c:4:1: internal compiler error: in extract_insn, at recog.c:2294
0xfff8000100e72803 __libc_start_main
        ./csu/libc-start.c:308

I don't get any error on the following constants: 2048, 4095, 4097, 8192.
4096 seems special!

Note: I found this issue when trying to build GMP 6.2.1 with UBsan. The failure
occurs on extract-dbl.c at line

  exp = (exp + 64 * GMP_NUMB_BITS) / GMP_NUMB_BITS - 64 * GMP_NUMB_BITS /
GMP_NUMB_BITS + 1;

due to the "exp + 64 * GMP_NUMB_BITS" with GMP_NUMB_BITS = 64.

Reply via email to