This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH:[darwin] fix load of a misaligned double word
- From: "Hartmut Penner" <HPENNER at de dot ibm dot com>
- To: Bradley Lucier <lucier at math dot purdue dot edu>
- Cc: David Edelsohn <dje at watson dot ibm dot com>, fjahanian at apple dot com, gcc-patches at gcc dot gnu dot org, geoffk at geoffk dot org, Bradley Lucier <lucier at math dot purdue dot edu>, Andrew Pinski <pinskia at physics dot uc dot edu>
- Date: Mon, 19 Jan 2004 13:10:26 +0100
- Subject: Re: PATCH:[darwin] fix load of a misaligned double word
> Hartmut:
> Thank you for the patch. I think, however, it may be related to the
> following failure:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13674
> which seems to occur in situations that your patch otherwise handles
> well.
> Brad
Brad,
thanks for the nice small testcase. Looks like
a combined reload / backend insn problem.
Did some instrumentation on find_reloads, especially
on the caculation of 'losers'. Alternative with
lowest 'losers' is taken. This is part
of the output, when compiling
'gcc -O1 -mcpu=G5' for a powerpc-apple-darwin7.2.0 gcc.
Output:
(insn 108 332 111 8 (set (reg/v:DF 126 [ ___F64V1 ])
(mem:DF (plus:SI (reg/v:SI 31 r31 [orig:125 ___r1 ] [125])
(const_int 3 [0x3])) [0 S8 A64])) 318 {*movdf_hardfloat64} (nil)
(nil))
contraint '=Y'<->'r':
op[1] 1: reject 2
Summe: reject 2 losers 8
contraint '??r'<->'Y':
op[0] 2: reject 13
op[1] 1: reject 15
Summe: reject 15 losers 27
contraint '!r'<->'r':
op[0] 2: reject 601
op[1] 1: reject 603
Summe: reject 603 losers 615
contraint 'f'<->'f':
op[0] 2: reject 1
op[0] 3: reject 5
op[1] 1: reject 7
op[1] 3: reject 11
Summe: reject 11 losers 23
contraint 'f'<->'m':
op[0] 2: reject 1
op[0] 3: reject 5
Summe: reject 5 losers 11
contraint 'm'<->'f':
op[1] 1: reject 2
op[1] 3: reject 6
Summe: reject 6 losers 12
contraint '!cl'<->'r':
op[0] 2: reject 601
op[0] 3: reject 605
op[1] 1: reject 607
Summe: reject 607 losers 619
contraint '!r'<->'h':
op[0] 2: reject 601
op[1] 1: reject 603
op[1] 3: reject 607
Summe: reject 607 losers 619
contraint '!r'<->'G':
op[0] 2: reject 601
op[1] 1: reject 603
Summe: reject 603 losers 615
contraint '!r'<->'H':
op[0] 2: reject 601
op[1] 1: reject 603
Summe: reject 603 losers 615
contraint '!r'<->'F':
op[0] 2: reject 601
op[1] 1: reject 603
Summe: reject 603 losers 615
tttt.c: In function `___H__23__23_integer_3f_':
tttt.c:119: error: insn does not satisfy its constraints:
(insn 385 332 108 8 (set (reg:DF 0 r0)
(mem:DF (plus:SI (reg/v:SI 31 r31 [orig:125 ___r1 ] [125])
(const_int 3 [0x3])) [0 S8 A64])) 318 {*movdf_hardfloat64} (nil)
(nil))
tttt.c:119: internal compiler error: in reload_cse_simplify_operands, at postreload.c:378
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Result:
Alternative 0 has the lowest 'losers' value, and is taken as alternative.
Second operands constraint is 'r', operand itself is memory.
Reload will generate a reload insn (insn 385), which itself
does not satisfy its constraints -> crash.
There are at least two problems:
Alternative 0 is worst, better would be alternative 1 (r Y),
best 4 (f m). Alternative 1 would need a address reload,
since address is not valid for 'Y' (dividable by 4 displacment).
Alternative 4 gets such a bad value, because
preferred_class[i] is GENERAL_REGS and
this_alternative[i] is FLOAT_REGS. Since these two classes
don't intersect, reject is incremented by 4.
The solution should be to fix reload, to not generate
invalid reloads (-:.
Before we have that, we should change the constraints to give
floating point register preference over general purpose register.
Bootstrap / Regtest Ongoing on PCC64 linux.
Please bootstrap on darwin.
OK to commit, if all of above goes thru ?
ChangeLog:
2004-01-12 Hartmut Penner <hpenner@de.ibm.com>
PR target/13674
* gcc/config/rs6000/rs6000.md (*movdf_hardfloat64):
Disregard memory - general register alternative.
Index: rs6000.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.md,v
retrieving revision 1.284
diff -u -p -r1.284 rs6000.md
--- rs6000.md 12 Jan 2004 18:37:40 -0000 1.284
+++ rs6000.md 19 Jan 2004 11:47:31 -0000
@@ -8163,7 +8163,7 @@
; ld/std require word-aligned displacements -> 'Y' constraint.
; List Y->r and r->Y before r->r for reload.
(define_insn "*movdf_hardfloat64"
- [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,??r,!r,f,f,m,!cl,!r,!r,!r,!r")
+ [(set (match_operand:DF 0 "nonimmediate_operand" "=?Y,?r,!r,f,f,m,!cl,!r,!r,!r,!r")
(match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,G,H,F"))]
"TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
&& (gpc_reg_operand (operands[0], DFmode)