Bug 26743 - gcc generates unreachable branch
Summary: gcc generates unreachable branch
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 11254
Blocks:
  Show dependency treegraph
 
Reported: 2006-03-18 10:13 UTC by Randolph Chung
Modified: 2006-04-12 01:23 UTC (History)
2 users (show)

See Also:
Host: hppa-unknown-linux
Target: hppa-unknown-linux
Build: hppa-unknown-linux
Known to work:
Known to fail: 3.3.6 3.4.5 4.0.3 4.1.0
Last reconfirmed:


Attachments
testcase (146.85 KB, application/gzip)
2006-03-18 10:14 UTC, Randolph Chung
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Randolph Chung 2006-03-18 10:13:18 UTC
gcc -O2 -c hamlibperl_wrap.i gives:
/tmp/ccxskRBB.s: Assembler messages:
/tmp/ccxskRBB.s:232018: Error: Field out of range [-262144..262143] (319532).
/tmp/ccxskRBB.s:312290: Error: Field out of range [-262144..262143] (-320952).

The problem happens with gcc-3.3.6, gcc-3.4.5, gcc-4.0.3 and gcc-4.1.0
Comment 1 Randolph Chung 2006-03-18 10:14:15 UTC
Created attachment 11066 [details]
testcase
Comment 2 Andrew Pinski 2006-03-18 15:06:01 UTC
Looks related to PR 11254.
Comment 3 Randolph Chung 2006-03-19 15:52:10 UTC
I think this is a bit different, the bit of code that causes the problem is:

 339796         .loc 1 38663 0
 339797         or,<> %r28,%r0,%r3
 339798         b .L25049
 339799         copy %r4,%r19

This bit of code is (I think) generated by output_movb() in pa.c, which doesn't check if the branch target is reachable.
Comment 4 dave 2006-03-19 17:09:01 UTC
Subject: Re:  gcc generates unreachable branch

> ------- Comment #3 from tausq at debian dot org  2006-03-19 15:52 -------
> I think this is a bit different, the bit of code that causes the problem is:
> 
>  339796         .loc 1 38663 0
>  339797         or,<> %r28,%r0,%r3
>  339798         b .L25049
>  339799         copy %r4,%r19
> 
> This bit of code is (I think) generated by output_movb() in pa.c, which doesn't
> check if the branch target is reachable.

Looks like the same issue.

I'm somewhat swamped at the moment.  The code in output_cbranch provides
an example of how to fix this bug.  It was fixed in this patch:

2003-03-18  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

        PR 10062
        * config/pa/pa-hpux.h (TARGET_HPUX_UNWIND_LIBRARY): Redefine.
	* pa-protos.h (output_lbranch): New prototype.
	* pa.c (compute_frame_size): Change size of the frame marker on the
	64-bit ports to 48 bytes.
	(pa_output_function_prologue): Document why SAVE_SP is set.
	(hppa_expand_prologue): Save previous stack pointer into frame marker
	on targets which use the hpux unwind library.
	(output_cbranch): Use output_lbranch.
	(output_lbranch): New function to output long unconditional branches.
	* pa.h (TARGET_HPUX_UNWIND_LIBRARY): Define.
	(STACK_POINTER_OFFSET): Update offset for 48-byte frame marker on
	64-bit ports.
	* pa.md (jump): Use output_lbranch.
	(allocate_stack): New expander for dynamic stack allocation.

A new length alternative may need to be needed to the patterns that
use output_movb.

Dave
Comment 5 John David Anglin 2006-04-09 17:19:47 UTC
Subject: Bug 26743

Author: danglin
Date: Sun Apr  9 17:19:42 2006
New Revision: 112805

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112805
Log:
	PR target/26743
	PR target/11254
	PR target/10274
	* pa.md (cbranch patterns): Revise arguments used in calls to
	output_cbranch, output_bb and output_bvd.  Add long branch length
	attributes.
	(fbranch patterns): Handle long branches.
	(jump): Revise length check.  Revise arguments for output_lbranch call.
	Add long branch length attributes.
	(decrement_and_branch_until_zero): Add long branch length attributes.
	(output_movb, output_parallel_addb and output_parallel_movb patterns):
	Likewise.  Revise arguments for output_parallel_addb and
	output_parallel_movb calls.
	* pa-protos.h (output_cbranch, output_lbranch, output_bb, output_bvb,
	output_parallel_movb and output_parallel_addb): Update prototypes.
	* pa.c (output_cbranch): Revise arguments.  Correct handling of
	nullification in long branches.
	(output_lbranch): Add new argument to control extraction of delay
	instruction.
	(output_bb): Handle long branches.
	(output_bvb, output_dbra, output_movb, output_parallel_movb,
	output_parallel_addb): Likewise.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/pa/pa-protos.h
    trunk/gcc/config/pa/pa.c
    trunk/gcc/config/pa/pa.md

Comment 6 John David Anglin 2006-04-09 17:42:05 UTC
Fixed on trunk (hopefully).