------- Additional Comments From mostrows at watson dot ibm dot com  2004-10-13 21:45 
-------
Subject: Re:  const/pure functions result in
        bad asm

For starters, when compiling without -DBUG, the resulting assembly is
much longer (correct assembly, with -DBUG below, that is without
pure/const).

Basically, most of the assembly code one would expect is missing.
Further more, of the assembly output in my last mail, execution of that
code leads to one of several infinite loops, all of which take the form
of a branch instruction targeting itself.

I expect that pure/const functions to not be called more than once, the
problem is that the sample assembly in my original mail shows that the
body of the function being compiler is pretty much all gone.

On Wed, 2004-10-13 at 14:51 +0000, pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-13 14:51 
> -------
> What do you think is wrong, attach the difference.  Also const/pure functions can 
> changed so that they 
> are only called once.  And since they are pure (or is it const) is known not to 
> access memory, the 
> barrier:
>              __asm__ __volatile__("": : :"memory"); 
> 
> does not make a difference.
> 
-- 
Michal Ostrowski <[EMAIL PROTECTED]>



   0:   7c 08 02 a6     mflr    r0
   4:   fb 81 ff e0     std     r28,-32(r1)
   8:   fb a1 ff e8     std     r29,-24(r1)
   c:   fb c1 ff f0     std     r30,-16(r1)
  10:   fb e1 ff f8     std     r31,-8(r1)
  14:   f8 01 00 10     std     r0,16(r1)
  18:   f8 21 ff 61     stdu    r1,-160(r1)
  1c:   7c 7d 1b 78     mr      r29,r3
  20:   7c 9e 23 78     mr      r30,r4
  24:   3b 80 00 00     li      r28,0
  28:   7d bf 6b 78     mr      r31,r13
  2c:   e9 3f 00 00     ld      r9,0(r31)
  30:   88 09 00 03     lbz     r0,3(r9)
  34:   2f a0 00 00     cmpdi   cr7,r0,0
  38:   40 be 00 20     bne+    cr7,58
<._Z10queue_workP16workqueue_structP11work_struct+0x58>
  3c:   48 00 00 01     bl      3c
<._Z10queue_workP16workqueue_structP11work_struct+0x3c>
  40:   60 00 00 00     nop
  44:   e9 7f 00 00     ld      r11,0(r31)
  48:   81 2b 00 00     lwz     r9,0(r11)
  4c:   39 29 00 01     addi    r9,r9,1
  50:   91 2b 00 00     stw     r9,0(r11)
  54:   48 00 00 18     b       6c
<._Z10queue_workP16workqueue_structP11work_struct+0x6c>
  58:   7d a9 6b 78     mr      r9,r13
  5c:   e9 69 00 00     ld      r11,0(r9)
  60:   81 2b 00 00     lwz     r9,0(r11)
  64:   39 29 00 01     addi    r9,r9,1
  68:   91 2b 00 00     stw     r9,0(r11)
  6c:   e9 22 00 00     ld      r9,0(r2)
  70:   eb e9 00 06     lwa     r31,4(r9)
  74:   7b e0 17 64     rldicr  r0,r31,2,61
  78:   7f e0 ea 14     add     r31,r0,r29
  7c:   38 60 00 00     li      r3,0
  80:   7f c4 f3 78     mr      r4,r30
  84:   48 00 00 01     bl      84
<._Z10queue_workP16workqueue_structP11work_struct+0x84>
  88:   60 00 00 00     nop
  8c:   2f a3 00 00     cmpdi   cr7,r3,0
  90:   40 9e 00 3c     bne-    cr7,cc
<._Z10queue_workP16workqueue_structP11work_struct+0xcc>
  94:   e8 1e 00 18     ld      r0,24(r30)
  98:   2f a0 00 00     cmpdi   cr7,r0,0
  9c:   40 be 00 18     bne+    cr7,b4
<._Z10queue_workP16workqueue_structP11work_struct+0xb4>
  a0:   38 60 00 67     li      r3,103
  a4:   e8 82 00 08     ld      r4,8(r2)
  a8:   e8 a2 00 10     ld      r5,16(r2)
  ac:   48 00 00 01     bl      ac
<._Z10queue_workP16workqueue_structP11work_struct+0xac>
  b0:   60 00 00 00     nop
  b4:   fb fe 00 18     std     r31,24(r30)
  b8:   7f e3 fb 78     mr      r3,r31
  bc:   38 81 00 70     addi    r4,r1,112
  c0:   48 00 00 01     bl      c0
<._Z10queue_workP16workqueue_structP11work_struct+0xc0>
  c4:   60 00 00 00     nop
  c8:   3b 80 00 01     li      r28,1
  cc:   7d a9 6b 78     mr      r9,r13
  d0:   e9 29 00 00     ld      r9,0(r9)
  d4:   81 69 00 00     lwz     r11,0(r9)
  d8:   79 60 06 20     clrldi  r0,r11,56
  dc:   2f a0 00 01     cmpdi   cr7,r0,1
  e0:   40 be 00 18     bne+    cr7,f8
<._Z10queue_workP16workqueue_structP11work_struct+0xf8>
  e4:   38 0b ff ff     addi    r0,r11,-1
  e8:   90 09 00 00     stw     r0,0(r9)
  ec:   48 00 00 01     bl      ec
<._Z10queue_workP16workqueue_structP11work_struct+0xec>
  f0:   60 00 00 00     nop
  f4:   48 00 00 18     b       10c
<._Z10queue_workP16workqueue_structP11work_struct+0x10c>
  f8:   7d a9 6b 78     mr      r9,r13
  fc:   e9 69 00 00     ld      r11,0(r9)
 100:   81 2b 00 00     lwz     r9,0(r11)
 104:   39 29 ff ff     addi    r9,r9,-1
 108:   91 2b 00 00     stw     r9,0(r11)
 10c:   7f 83 e3 78     mr      r3,r28
 110:   38 21 00 a0     addi    r1,r1,160
 114:   e8 01 00 10     ld      r0,16(r1)
 118:   7c 08 03 a6     mtlr    r0
 11c:   eb 81 ff e0     ld      r28,-32(r1)
 120:   eb a1 ff e8     ld      r29,-24(r1)
 124:   eb c1 ff f0     ld      r30,-16(r1)
 128:   eb e1 ff f8     ld      r31,-8(r1)
 12c:   4e 80 00 20     blr
 130:   00 00 00 00     .long 0x0
 134:   00 09 00 01     .long 0x90001
 138:   80 04 00 00     lwz     r0,0(r4)



-- 


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

Reply via email to