[Bug middle-end/55195] [4.8 Regression] shorten_branches generates incorrect forward branch distances

dave.anglin at bell dot net gcc-bugzilla@gcc.gnu.org
Tue Nov 6 12:26:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55195

--- Comment #10 from dave.anglin at bell dot net 2012-11-06 12:26:06 UTC ---
On 5-Nov-12, at 11:20 AM, amylaar at gcc dot gnu.org wrote:

> I take back that statement about this being straightforward.  We  
> need valid
> minimum and maximum instruction lengths.  The opaque dummy clause  
> automatically
> provides a value to be included in these calculations.

This is failing at -O0:

(define_insn ""
   [(set (reg:SI 29)
         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
    (clobber (match_operand:SI 1 "register_operand" "=a"))
    (clobber (match_operand:SI 2 "register_operand" "=&r"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 31))]
   "!TARGET_64BIT"
   "*
    return pa_output_div_insn (operands, 0, insn);"
   [(set_attr "type" "milli")
    (set (attr "length")
         (cond [(and (match_test "0") (eq (const_int 0) (pc)))  
(const_int 24)]
               (symbol_ref "pa_attr_length_millicode_call (insn)")))])

The insn is actually a millicode call (branch) which needs to be able
to reach stub table.  Different variants are generated depending on
pc.  I modified the opaque clause a bit as I decided I didn't want to it
to depend on operand 0.  Don't see how a negative length can arise.

spawn /home/dave/gnu/gcc/objdir/gcc/xgcc -B/home/dave/gnu/gcc/objdir/ 
gcc/ -fno-d
iagnostics-show-caret -O0 -w -c -o 20000427-1.o /home/dave/gnu/gcc/gcc/ 
gcc/tests
uite/gcc.c-torture/compile/20000427-1.c/home/dave/gnu/gcc/gcc/gcc/ 
testsuite/gcc.c-torture/compile/20000427-1.c: In func
tion 'ConvertFor3dDriver':
/home/dave/gnu/gcc/gcc/gcc/testsuite/gcc.c-torture/compile/ 
20000427-1.c:9:1: err
or: negative insn length
(insn 47 46 48 (parallel [
             (set (reg:SI 29 %r29)
                 (div:SI (reg:SI 26 %r26)
                     (reg:SI 25 %r25)))
             (clobber (reg:SI 1 %r1))
             (clobber (reg:SI 19 %r19 [125]))
             (clobber (reg:SI 26 %r26))            (clobber (reg:SI 25  
%r25))
             (clobber (reg:SI 31 %r31))
         ]) /home/dave/gnu/gcc/gcc/gcc/testsuite/gcc.c-torture/compile/ 
20000427-1.c:8 122 {*pa.md:5433}
      (nil))
/home/dave/gnu/gcc/gcc/gcc/testsuite/gcc.c-torture/compile/ 
20000427-1.c:9:1: int
ernal compiler error: in shorten_branches, at final.c:1162
0x537f7b _fatal_insn(char const*, rtx_def const*, char const*, int,  
char const*)
         ../../gcc/gcc/rtl-error.c:110
0x308df7 shorten_branches(rtx_def*)
         ../../gcc/gcc/final.c:1162
0x3094e3 rest_of_handle_shorten_branches
         ../../gcc/gcc/final.c:4368

Dave
--
John David Anglin    dave.anglin@bell.net



More information about the Gcc-bugs mailing list