https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116200
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- On x86_64 we are crashing on: => 0x0000000000a01bb6 <+2278>: mov 0x2612db0(,%rax,8),%rdx (insn:TI 1615 3377 1617 104 (set (reg:DI 0 ax [690]) (zero_extend:DI (reg:SI 2 cx [681]))) "/home/apinski/src/upstream-gcc-isel/gcc/gcc/fortran/module.cc":6796:6 168 {*zero_extendsidi2} (nil)) (insn:TI 1617 1615 5449 104 (set (reg:DI 1 dx [691]) (mem/u/c:DI (plus:DI (ashift:DI (reg:DI 0 ax [690]) (const_int 3 [0x3])) (label_ref:DI 1620)) [0 S8 A8])) "/home/apinski/src/upstream-gcc-isel/gcc/gcc/fortran/module.cc":6796:6 88 {*movdi_internal} (expr_list:REG_DEAD (reg:DI 0 ax [690]) rax here is -9 . This was pulled out before the comparison to make sure eax/ecx is range of [0..2]: (insn:TI 1613 4828 1614 105 (set (reg:CC 17 flags) (compare:CC (reg:SI 2 cx [681]) (const_int 2 [0x2]))) "/home/apinski/src/upstream-gcc-isel/gcc/gcc/fortran/module.cc":6796:6 15 {*cmpsi_1} (nil)) (jump_insn 1614 1613 3282 105 (set (pc) (if_then_else (gtu (reg:CC 17 flags) (const_int 0 [0])) (label_ref 1986) (pc))) "/home/apinski/src/upstream-gcc-isel/gcc/gcc/fortran/module.cc":6796:6 1246 {*jcc} (expr_list:REG_DEAD (reg:CC 17 flags) (int_list:REG_BR_PROB 5572 (nil))) -> 1986)