x86: Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns
In i386.md, neg patterns which set MODE_CC register like
(set (reg:CCC FLAGS_REG)
(ne:CCC (match_operand:SWI48 1 "general_reg_operand") (const_int 0)))
can lead to errors when operand 1 is a constant value. If FLAGS_REG in
(set (reg:CCC FLAGS_REG)
(ne:CCC (const_int 2) (const_int 0)))
is set to 1, RTX simplifiers may simplify
(set (reg:SI 93)
(neg:SI (ltu:SI (reg:CCC 17 flags) (const_int 0 [0]))))
as
(set (reg:SI 93)
(neg:SI (ltu:SI (const_int 1) (const_int 0 [0]))))
which leads to incorrect results since LTU on MODE_CC register isn't the
same as "unsigned less than" in x86 backend. To prevent RTL optimizers
from setting MODE_CC register to a constant, use UNSPEC_CC_NE to replace
ne:CCC/ne:CCO when setting FLAGS_REG in neg patterns.
gcc/
PR target/107172
* config/i386/i386.md (UNSPEC_CC_NE): New.
Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns.
gcc/testsuite/
PR target/107172
* gcc.target/i386/pr107172.c: New test.