This is the mail archive of the gcc-patches@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]

Re: [RFT] PR19154: New AVR bit extraction patter


> Roger Sayle <roger@eyesopen.com> writes:
>
> The following patch is my attempt to resolve PR middle-end/19154.  The
> proposed solution is to introduce new patterns to the AVR backend that
> can be used to efficiently extract a bit from a register. ...

How about something like: (both a little smaller and register agnostic)

For control flow: if (x & (1 << b)) { } else { } ;

  BST    Rd:4, b:3   ; save Rd bit b in T flag
  BRTS/C offset:7    ; branch if T set/clear

For bool values: (x & (1 << b)) ? 1 : 0 ;
  
  BST    Rd:4, b:3   ; save Rd bit b in T flag
  CLR    Rd:4        ; clear Rd bool target
  BLD    Rd:4, b:3   ; load Rd bit b from T flag




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