public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* mach pass deleting instructions?
@ 2013-07-22 17:29 David Given
  2013-07-23 16:42 ` David Given
  0 siblings, 1 reply; 2+ messages in thread
From: David Given @ 2013-07-22 17:29 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 2267 bytes --]

So I'm trying to get compare-and-branch working on my architecture. I
have the following patterns:

(define_expand "cbranchsf4"
  [(set
      (reg:CC CC_REGNO)
      (compare:CC
        (match_operand:SF 1 "register_operand")
        (match_operand:SF 2 "register_operand")))
   (set
      (pc)
      (if_then_else
        (match_operator 0 "comparison_operator"
          [(reg:CC CC_REGNO)
           (const_int 0)]
        )
        (label_ref
          (match_operand 3 "" ""))
        (pc))
   )]
  ""
  {}
)

(define_insn "*test_sf"
  [(set
   (reg:CC CC_REGNO)
   (compare
     (match_operand:SF 0 "register_operand" "r")
     (match_operand:SF 1 "register_operand" "r")))]
  ""
  "fcmp %0, %1, %1"
  [(set_attr "length" "4")]
)

(define_insn "*branch_<condition:code>"
  [(set
     (pc)
     (if_then_else
       (condition
         (reg:CC CC_REGNO)
         (const_int 0))
       (label_ref
         (match_operand 0))
       (pc)))]
  ""
  "b<condition:condition_code> %0"
  [(set_attr "length" "4")]
)

The architecture is utterly traditional and the code above is stolen
pretty much intact from the moxie port (which I'm using as a reference
because it seems to be simple and easy to understand).

When I actually try to build stuff, however, the branch gets emitted but
then silently deleted during the mach pass. The debug tracing (as
produced by -da) doesn't say why; it just removes it. Naturally the
resulting program doesn't work. Example:

int cmp(float a, float b)
{ return a>b; }

->

cmp:
  push r6, lr
  mov r6, #1 ; fast
  fcmp r0, r1, r1
  <--- branch instruction to .L2 should be here
  mov r6, #0 ; fast
.L2:
  mov r0, r6 ; fast
  pop r6, pc

Does anyone have any suggestions as to what I'm doing wrong, and where
to start looking? For example, what is the mach pass actually trying to
do, and is there any way to get it to give me more information about why
it's doing it?

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "USER'S MANUAL VERSION 1.0:  The information presented in this
│ publication has been carefully for reliability." --- anonymous
│ computer hardware manual


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: mach pass deleting instructions?
  2013-07-22 17:29 mach pass deleting instructions? David Given
@ 2013-07-23 16:42 ` David Given
  0 siblings, 0 replies; 2+ messages in thread
From: David Given @ 2013-07-23 16:42 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

David Given wrote:
[...]
> When I actually try to build stuff, however, the branch gets emitted but
> then silently deleted during the mach pass.

Solved: turned out to be old code in the TARGET_MACHINE_DEPENDENT_REORG,
dating from the port I was basing my backend on, which was mangling my
code. I disabled the target hook and it all works now.

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "USER'S MANUAL VERSION 1.0:  The information presented in this
│ publication has been carefully for reliability." --- anonymous
│ computer hardware manual


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-23 16:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-22 17:29 mach pass deleting instructions? David Given
2013-07-23 16:42 ` David Given

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).