21716 – [3.4/4.0/4.1 Regression] ICE in reg-stack.c's swap_rtx_condition (original) (raw)
Description Jakub Jelinek 2005-05-23 08:58:44 UTC
Attached testcase ICEs at -m32 -march=i386 -O2 -ffast-math in swap_rtx_condition. Cross jumping there merges testqi_ext_0/jcc_1 from 2 different BB's, but keeps the %ax setters (cmpfp_2_df_1) in the original blocks. (insn:HI 2037 4155 2038 55 (set (reg:HI 0 ax [783]) (unspec:HI [ (compare:CCFP (reg/v:DF 10 st(2) [orig:354 cf0d2 ] [354]) (reg:DF 12 st(4))) ] 24)) 22 {*cmpfp_2_df_1} (insn_list 4399 (insn_list 4400 (nil))) (expr_list:REG_DEAD (reg:DF 12 st(4)) (nil)))
(note:HI 2038 2037 4525 55 NOTE_INSN_DELETED) ;; End of basic block 55, registers live: 0 [ax] 3 [bx] 4 [si] 5 [di] 6 [bp] 7 [sp] 10 [st(2)] 11 [st(3)] 13 [st(5)] 14 [st(6)] 15 [st(7)] 16 [argp] 20 [frame]
;; Start of basic block 56, registers live: 0 [ax] 3 [bx] 4 [si] 5 [di] 6 [bp] 7 [sp] 10 [st(2)] 11 [st(3)] 13 [st(5)] 14 [st(6)] 15 [st(7)] 16 [argp] 20 [frame] (code_label 4525 2038 4523 56 173 "" [1 uses])
(note 4523 4525 2448 56 [bb 56] NOTE_INSN_BASIC_BLOCK)
(note:HI 2448 4523 2449 56 NOTE_INSN_DELETED)
(note:HI 2449 2448 2450 56 NOTE_INSN_DELETED)
(note:HI 2450 2449 4359 56 NOTE_INSN_DELETED)
(insn 4359 2450 2453 56 (set (reg:CCZ 17 flags) (compare:CCZ (and:SI (zero_extract:SI (reg:SI 0 ax [834]) (const_int 8 [0x8]) (const_int 8 [0x8])) (const_int 1 [0x1])) (const_int 0 [0x0]))) 278 {*testqi_ext_0} (nil) (expr_list:REG_DEAD (reg:SI 0 ax [834]) (nil)))
(jump_insn:HI 2453 4359 4454 56 (set (pc) (if_then_else (eq (reg:CCZ 17 flags) (const_int 0 [0x0])) (label_ref 1835) (pc))) 494 {*jcc_1} (insn_list 4359 (nil)) (expr_list:REG_DEAD (reg:CCZ 17 flags) (expr_list:REG_BR_PROB (const_int 8448 [0x2100]) (nil))))
When swap_rtx_condition is called on insn 2037, it doesn't find the %ax user in the same BB, but as the last instruction in the BB is not INSN_P(), it crashes when trying to dereference it's PATTERN.
Comment 2 Drea Pinski 2005-05-23 13:52:52 UTC
Confirmed.
Comment 3 Volker Reichelt 2005-05-23 16:39:07 UTC
Here's a reduced testcase that might be appropriate for the testsuite:
====================================================================== /* PR target/21716 / / { dg-do compile } / / { dg-options "-march=i386 -m32 -O2 -ffast-math" { i?86-- } } */
double atan (double);
void foo() { double x, y;
do { goto L2; L1: if (x) goto L1; L2: x += atan (y); goto L1; } while (1); }
For me the original testcase and the reduced one only crash with the 3.4 branch on a native i686-pc-linux-gnu box.
Comment 7 Drea Pinski 2005-05-26 12:05:55 UTC
Fixed.
Comment 8 Volker Reichelt 2005-06-02 16:05:51 UTC
The testcase from comment #3 still crashes on the 3.4 branch:
ePR21716.c: In function `foo': ePR21716.c:21: internal compiler error: in subst_stack_regs_pat, at reg-stack.c:1445 Please submit a full bug report, [etc.]
Comment 9 Jakub Jelinek 2005-06-02 16:07:48 UTC
Yeah, it is a different bug, one that does not exhibit on the original testcase. Therefore IMHO a separate PR is needed...
Comment 10 Drea Pinski 2005-06-02 19:00:24 UTC
(In reply to comment #8)
The testcase from comment #3 still crashes on the 3.4 branch:
Please open a new bug.