On Tue, Sep 24, 2019 at 5:58 AM Richard Sandiford <richard.sandiford@xxxxxxx> wrote: > > William Tambe <tambewilliam@xxxxxxxxx> writes: > > I have defined atomic_exchangesi as follow in the machine description: > > > > (define_insn "atomic_exchangesi" > > [(set (match_operand:SI 0 "register_operand" "=r,r") > > (match_operand:SI 1 "memory_operand" "+B,W")) > > (set (match_dup 1) > > (unspec:SI > > [(match_operand:SI 2 "register_operand" "0,0") > > (match_operand:SI 3 "const_int_operand")] > > 0))] > > "+" operands have to be destinations, so I think you need to swap > the match_operand:SI 1 and match_dup 1 around. (It's OK to have > a match_dup 1 source before a match_operand 1 destination.) I changed things as follow, but got "operand 1 duplicated before defined" : (define_insn "atomic_exchange<mode>" [(set (match_operand:SI 0 "register_operand" "=r,r") (match_dup 1)) (set (match_operand:SI 1 "memory_operand" "+B,W") (unspec:SI [(match_operand:SI 2 "register_operand" "0,0") (match_operand:SI 3 "const_int_operand")] 0))] "" "@ ... ...") I then tried changing the order of the parallel operations as follow but still got the error "unable to generate reloads for" : (define_insn "atomic_exchange<mode>" [(set (match_operand:LDSTMODE 1 "memory_operand" "+B,W") (unspec:LDSTMODE [(match_operand:LDSTMODE 2 "register_operand" "0,0") (match_operand:LDSTMODE 3 "const_int_operand")] 0)) (set (match_operand:LDSTMODE 0 "register_operand" "=r,r") (match_dup 1))] "" "@ ... ...") I am using GCC 9.2.0; Any other suggestion I could try ? > > Richard > > > "" > > "@ > > ... > > ...") > > > > > > However GCC throw the following error for atomic_exchangesi: > > Any idea what could be the cause of such an error ? > > > > error: unable to generate reloads for: > > 902 | } > > | ^ > > (insn 89 86 90 12 (parallel [ > > (set (reg:SI 4 %4 [orig:36 _30 ] [36]) > > (mem/v:SI (plus:SI (reg/f:SI 0 %sp) > > (const_int 36 [0x24])) [-1 S4 A32])) > > (set (mem/v:SI (plus:SI (reg/f:SI 0 %sp) > > (const_int 36 [0x24])) [-1 S4 A32]) > > (unspec:SI [ > > (reg:SI 3 %3 [orig:34 _28 ] [34]) > > (const_int 32770 [0x8002]) > > ] 0)) > > ]) "/linux/include/asm-generic/atomic.h":118:1 35 {atomic_exchangesi} > > (nil)) > > during RTL pass: reload