This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mach pass deleting instructions?


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?

-- 
ââââ ïïïïïïïïïïïïïï âââââ 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: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]