[PATCH, middle end]: Fix PR 37908, thinko with atomic NAND operation

Uros Bizjak ubizjak@gmail.com
Fri Oct 24 11:24:00 GMT 2008


Hello!

Currently, we are expanding atomic NAND operation as "target =
(~target & val)", whic is simply not NAND operation. Correct operation
would be "target = ~(target & val)".

Attached patch corrects this thinko.

2008-10-24  Uros Bizjak  <ubizjak@gmail.com>

	PR middle-end/37908
	* optabs.c (expand_sync_operation): Properly handle NAND case
	by calculating ~(t1 & val) instead of (~t1 & val).

testsuite/ChangeLog:

2008-10-24  Uros Bizjak  <ubizjak@gmail.com>

	PR middle-end/37908
	* gcc.dg/pr37908.c: New test.

_However_, this patch fails following tests:

FAIL: gcc.dg/ia64-sync-1.c execution test
FAIL: gcc.dg/ia64-sync-2.c execution test
FAIL: gcc.dg/sync-2.c execution test
FAIL: gcc.dg/sync-3.c execution test

In these tests, we check for target = (~target & val), where NAND (0,
7) becomes 7. Correct NAND operation would produce -1, calculated as
~(0 & 7).

Attached patch was bootstrapped and tested on x86-pc-linux-gnu. I
would like to ask for a second opinion, if failed tests are in fact
correct or not.

Uros.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: p.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20081024/1097a8b3/attachment.txt>


More information about the Gcc-patches mailing list