gcc: xtensa: fix NAND code in xtensa_expand_atomic
authorMax Filippov <jcmvbkbc@gmail.com>
Tue, 4 Sep 2018 17:43:20 +0000 (17:43 +0000)
committerMax Filippov <jcmvbkbc@gcc.gnu.org>
Tue, 4 Sep 2018 17:43:20 +0000 (17:43 +0000)
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.

From-SVN: r264087

gcc/ChangeLog
gcc/config/xtensa/xtensa.c

index 9b0d2d11771c573a56f5b8e30381d9be42fb9195..2b4c04b71e289ca3a2868b9159f08f7885aa8dc0 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-04  Max Filippov  <jcmvbkbc@gmail.com>
+
+       * config/xtensa/xtensa.c (xtensa_expand_atomic): Reorder AND and
+       XOR operations in NAND case.
+
 2018-09-04  Aldy Hernandez  <aldyh@redhat.com>
 
        * wide-int-range.cc (wide_int_range_convert): New.
index 7cfe64d4289594364c8318855bd61759632c3f78..080bb4ad765d1916b1200c8db14e4acdb198a185 100644 (file)
@@ -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;