* [PATCH] Fix PR optimization/9888 (part #3)
@ 2003-03-09 22:34 Eric Botcazou
2003-03-11 19:59 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2003-03-09 22:34 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]
Hi,
The purpose of this part is to let the immediate jump instructions be
recognized as variable length instructions. This is currently not the case
because the computation of the "length" attribute is done through two
indirections
length <- length_immediate <- type
and the attribute machinery is not smart enough to detect that the "length"
ultimately depends upon an if-then-else.
It turns out that this was fixed on 3.3 and mainline by Jan back in November:
Tue Nov 19 23:50:56 CET 2002 Jan Hubicka <jh@suse.cz>
* i386.md (length_immediate): Do not refer to insn address.
(jcc*, jmp patterns): Compute length explicitly.
The ChangeLog entry is actually incomplete, it lacks:
(doloop_end_internal pattern): Unconditionally set the type to "ibr".
According to the comments in the patch (I couldn't locate the related message
in the gcc-patches mailling-list), the purpose was probably to improve
scheduling only. But, as a side-effect, the patch does turn the immediate
jump instructions into variable length instructions. And the others bits are
pretty safe.
Bootstrapped/regtested on k6-redhat-linux-gnu (c,c++,objc,f77). Ok for the
3.2 branch?
With this patch, 35 out of 35 insns are now given the right length for the
loop in the PR (again manually verified). But this is still not sufficient
to let the testcase pass because the condition used to switch between short
and long branches is too permissive.
--
Eric Botcazou
2003-03-09 Eric Botcazou <ebotcazou@libertysurf.fr>
PR optimization/9888
Backport patch from mainline:
Tue Nov 19 23:50:56 CET 2002 Jan Hubicka <jh@suse.cz>
* i386.md (length_immediate): Do not refer to insn address.
(jcc*, jmp patterns): Compute length explicitly.
(doloop_end_internal pattern): Unconditionally set the type to "ibr".
[-- Attachment #2: pr9888-2.diff --]
[-- Type: text/x-diff, Size: 2809 bytes --]
Index: config/i386/i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.339.2.13.2.3
diff -u -r1.339.2.13.2.3 i386.md
--- config/i386/i386.md 9 Mar 2003 15:51:39 -0000 1.339.2.13.2.3
+++ config/i386/i386.md 9 Mar 2003 17:09:38 -0000
@@ -147,13 +147,10 @@
(if_then_else (match_operand 1 "constant_call_address_operand" "")
(const_int 4)
(const_int 0))
+ ;; We don't know the size before shorten_branches. Expect
+ ;; the instruction to fit for better scheduling.
(eq_attr "type" "ibr")
- (if_then_else (and (ge (minus (match_dup 0) (pc))
- (const_int -128))
- (lt (minus (match_dup 0) (pc))
- (const_int 124)))
- (const_int 1)
- (const_int 4))
+ (const_int 1)
]
(symbol_ref "/* Update immediate_length and other attributes! */ abort(),1")))
@@ -12968,13 +12965,13 @@
"%+j%C1\t%l0"
[(set_attr "type" "ibr")
(set_attr "modrm" "0")
- (set (attr "prefix_0f")
+ (set (attr "length")
(if_then_else (and (ge (minus (match_dup 0) (pc))
(const_int -128))
(lt (minus (match_dup 0) (pc))
(const_int 124)))
- (const_int 0)
- (const_int 1)))])
+ (const_int 2)
+ (const_int 6)))])
(define_insn "*jcc_2"
[(set (pc)
@@ -12986,13 +12983,13 @@
"%+j%c1\t%l0"
[(set_attr "type" "ibr")
(set_attr "modrm" "0")
- (set (attr "prefix_0f")
+ (set (attr "length")
(if_then_else (and (ge (minus (match_dup 0) (pc))
(const_int -128))
(lt (minus (match_dup 0) (pc))
(const_int 124)))
- (const_int 0)
- (const_int 1)))])
+ (const_int 2)
+ (const_int 6)))])
;; In general it is not safe to assume too much about CCmode registers,
;; so simplify-rtx stops when it sees a second one. Under certain
@@ -13253,6 +13250,13 @@
""
"jmp\t%l0"
[(set_attr "type" "ibr")
+ (set (attr "length")
+ (if_then_else (and (ge (minus (match_dup 0) (pc))
+ (const_int -128))
+ (lt (minus (match_dup 0) (pc))
+ (const_int 124)))
+ (const_int 2)
+ (const_int 5)))
(set_attr "modrm" "0")])
(define_expand "indirect_jump"
@@ -13374,14 +13378,9 @@
(const_int 124))))
(const_int 2)
(const_int 16)))
- (set (attr "type")
- (if_then_else (and (eq_attr "alternative" "0")
- (and (ge (minus (match_dup 0) (pc))
- (const_int -128))
- (lt (minus (match_dup 0) (pc))
- (const_int 124))))
- (const_string "ibr")
- (const_string "multi")))])
+ ;; We don't know the type before shorten branches. Optimistically expect
+ ;; the loop instruction to match.
+ (set (attr "type") (const_string "ibr"))])
(define_split
[(set (pc)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix PR optimization/9888 (part #3)
2003-03-09 22:34 [PATCH] Fix PR optimization/9888 (part #3) Eric Botcazou
@ 2003-03-11 19:59 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2003-03-11 19:59 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
On Sun, Mar 09, 2003 at 11:32:10PM +0100, Eric Botcazou wrote:
> * i386.md (length_immediate): Do not refer to insn address.
> (jcc*, jmp patterns): Compute length explicitly.
> (doloop_end_internal pattern): Unconditionally set the type to "ibr".
Ok.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-03-11 19:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-09 22:34 [PATCH] Fix PR optimization/9888 (part #3) Eric Botcazou
2003-03-11 19:59 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).