[v2] gcc: xtensa: fix NAND code in xtensa_expand_atomic

Message ID 20180904164222.28820-1-jcmvbkbc@gmail.com
State New
Headers show
Series
  • [v2] gcc: xtensa: fix NAND code in xtensa_expand_atomic
Related show

Commit Message

Max Filippov Sept. 4, 2018, 4:42 p.m.
NAND is ~(a1 & a2), but xtensa_expand_atomic does ~a1 & a2.
That fixes libatomic tests atomic-op-{1,2}.

gcc/
2018-09-04  Max Filippov  <jcmvbkbc@gmail.com>

	* config/xtensa/xtensa.c (xtensa_expand_atomic): Reorder AND and
	XOR operations in NAND case.
---
Changes v1->v2:
- put final inversion result into the new_rtx avoiding unneeded move

 gcc/config/xtensa/xtensa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.11.0

Comments

augustine.sterling@gmail.com Sept. 4, 2018, 5:35 p.m. | #1
On Tue, Sep 4, 2018 at 9:42 AM Max Filippov <jcmvbkbc@gmail.com> wrote:

> NAND is ~(a1 & a2), but xtensa_expand_atomic does ~a1 & a2.

> That fixes libatomic tests atomic-op-{1,2}.

>

> gcc/

> 2018-09-04  Max Filippov  <jcmvbkbc@gmail.com>

>

>         * config/xtensa/xtensa.c (xtensa_expand_atomic): Reorder AND and

>         XOR operations in NAND case.

>


Approved.
Max Filippov Sept. 4, 2018, 6:07 p.m. | #2
On Tue, Sep 4, 2018 at 10:35 AM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Tue, Sep 4, 2018 at 9:42 AM Max Filippov <jcmvbkbc@gmail.com> wrote:

>>

>> NAND is ~(a1 & a2), but xtensa_expand_atomic does ~a1 & a2.

>> That fixes libatomic tests atomic-op-{1,2}.

>>

>> gcc/

>> 2018-09-04  Max Filippov  <jcmvbkbc@gmail.com>

>>

>>         * config/xtensa/xtensa.c (xtensa_expand_atomic): Reorder AND and

>>         XOR operations in NAND case.

>

>

> Approved.


Thanks. Applied to trunk and gcc-[678] branches.

-- 
Thanks.
-- Max

Patch

diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 7cfe64d42895..080bb4ad765d 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -1614,9 +1614,9 @@  xtensa_expand_atomic (enum rtx_code code, rtx target, rtx mem, rtx val,
       break;
 
     case MULT: /* NAND */
-      tmp = expand_simple_binop (SImode, XOR, old, ac.modemask,
+      tmp = expand_simple_binop (SImode, AND, old, val,
 				 NULL_RTX, 1, OPTAB_DIRECT);
-      tmp = expand_simple_binop (SImode, AND, tmp, val,
+      tmp = expand_simple_binop (SImode, XOR, tmp, ac.modemask,
 				 new_rtx, 1, OPTAB_DIRECT);
       break;