@@ -9900,6 +9900,17 @@
[(set_attr "type" "negnot")
(set_attr "mode" "SI")])
+(define_insn "*neg<mode>_ccc"
+ [(set (reg:CCC FLAGS_REG)
+ (ne:CCC
+ (match_operand:SWI 1 "nonimmediate_operand" "0")
+ (const_int 0)))
+ (clobber (match_scratch:SWI 0 "=<r>"))]
+ ""
+ "neg{<imodesuffix>}\t%0"
+ [(set_attr "type" "negnot")
+ (set_attr "mode" "<MODE>")])
+
;; Negate with jump on overflow.
(define_expand "negv<mode>3"
[(parallel [(set (reg:CCO FLAGS_REG)
@@ -18015,9 +18026,9 @@
(set_attr "length_immediate" "0")])
(define_insn "*x86_mov<mode>cc_0_m1_neg"
- [(set (match_operand:SWI48 0 "register_operand" "=r")
- (neg:SWI48 (match_operator 1 "ix86_carry_flag_operator"
- [(reg FLAGS_REG) (const_int 0)])))
+ [(set (match_operand:SWI 0 "register_operand" "=<r>")
+ (neg:SWI (match_operator 1 "ix86_carry_flag_operator"
+ [(reg FLAGS_REG) (const_int 0)])))
(clobber (reg:CC FLAGS_REG))]
""
"sbb{<imodesuffix>}\t%0, %0"
@@ -18045,6 +18056,33 @@
(clobber (reg:CC FLAGS_REG))])]
"operands[2] = GEN_INT (INTVAL (operands[2]) + 1);")
+(define_split
+ [(set (match_operand:SWI 0 "register_operand")
+ (neg:SWI
+ (eq:SWI
+ (match_operand 1 "int_nonimmediate_operand")
+ (const_int 0))))]
+ ""
+ [(set (reg:CC FLAGS_REG) (compare:CC (match_dup 1) (const_int 1)))
+ (parallel [(set (match_dup 0)
+ (neg:SWI (ltu:SWI (reg:CC FLAGS_REG) (const_int 0))))
+ (clobber (reg:CC FLAGS_REG))])])
+
+(define_split
+ [(set (match_operand:SWI 0 "register_operand")
+ (neg:SWI
+ (ne:SWI
+ (match_operand 1 "int_nonimmediate_operand")
+ (const_int 0))))]
+ ""
+ [(parallel [(set (reg:CCC FLAGS_REG)
+ (ne:CCC (match_dup 1) (const_int 0)))
+ (clobber (match_dup 2))])
+ (parallel [(set (match_dup 0)
+ (neg:SWI (ltu:SWI (reg:CCC FLAGS_REG) (const_int 0))))
+ (clobber (reg:CC FLAGS_REG))])]
+ "operands[2] = gen_rtx_SCRATCH (GET_MODE (operands[1]));")
+
(define_insn "*mov<mode>cc_noc"
[(set (match_operand:SWI248 0 "register_operand" "=r,r")
(if_then_else:SWI248 (match_operator 1 "ix86_comparison_operator"
new file mode 100644
@@ -0,0 +1,21 @@
+/* PR target/94795 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+char fooc (char x)
+{
+ return x ? -1 : 0;
+}
+
+short foos (short x)
+{
+ return x ? -1 : 0;
+}
+
+long fooi (long x)
+{
+ return x ? -1 : 0;
+}
+
+/* { dg-final { scan-assembler-not "test|cmp" } } */
+/* { dg-final { scan-assembler-times "sbb" 3 } } */
new file mode 100644
@@ -0,0 +1,20 @@
+/* PR target/94795 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+char fooc (char x)
+{
+ return -(x == 0);
+}
+
+short foos (short x)
+{
+ return -(x == 0);
+}
+
+long fooi (long x)
+{
+ return -(x == 0);
+}
+
+/* { dg-final { scan-assembler-times "sbb" 3 } } */