今回は、bit7の場合です。
0000 FB E2 00 00 00 00     mov.L   #_bar1, r14
0006 CC EE                 mov.B   [r14], r14
0008 61 0E                 cmp     #0, r14
000a FB E2 00 00 00 00     mov.L   #_bar, r14
0010 29 05                 blt     .L5
0012 F0 E7                 bset    #7, [r14].B
0014 02                    rts
                       .L5:
0015 F0 EF                 bclr    #7, [r14].B
0017 02                    rts
ちょっと違うやり方になります。
Failed to match this instruction:
(set (pc)
    (if_then_else (ge (subreg:SI (mem/c:QI (reg/f:SI 30) [0 bar1+0 S1 A8]) 0)
            (const_int 0 [0]))
        (label_ref 17)
        (pc)))
コンバインパターンはこうなっています。
(define_insn_and_split "*cbranchqi4_tst_ext_bitmem_msb"
  [(set (pc)
    (if_then_else
      (match_operator 2 "rx_zs_comparison_operator"
        [(subreg:SI
        (match_operand:QI 0 "rx_restricted_mem_operand" "Q") 0)
         (const_int 0)])
      (match_operand 1 "label_ref_operand" "")
      (pc)))]
  ""
  "#"
  "reload_completed"
  [(const_int 0)]
{
  rtx x;
  enum rtx_code code;
  x = gen_rtx_AND (SImode, operands[0], gen_int_mode (0x80, SImode));
  code = GET_CODE (operands[2]);
  if (code == GE) code = EQ;
  if (code == LT) code = NE;
  rx_split_cbranch (CC_ZSmode, code,
            x, const0_rtx, operands[1]);
  DONE;
})
rx.mdにこれを追加します。(*tstqi_bitmemをちょっと修正しています。)
コンパイルしたコードはこうなります。
 0000 FB E2 00 00 00 00     mov.L   #_bar1, r14
0006 F4 E7                 btst    #7, [r14].B
0008 FB E2 00 00 00 00     mov.L   #_bar, r14
000e 1C                    bne     .L5
000f F0 E7                 bset    #7, [r14].B
0011 02                    rts
                       .L5:
0012 F0 EF                 bclr    #7, [r14].B
0014 02                    rts
btst-rx.patch  まとめたpatch
[0回]
PR