From 9cb96754ae0a6af89ec8286d6a68d76c70698a65 Mon Sep 17 00:00:00 2001
From: "Naveen.H.S" <naveenh@kpitcummins.com>
Date: Tue, 30 May 2006 22:53:48 +0000
Subject: [PATCH] m32c.c (m32c_expand_insv): Check that the value we're
 inserting is a singlt-bit constant.

* config/m32c/m32c.c (m32c_expand_insv): Check that the value
we're inserting is a singlt-bit constant.

Co-Authored-By: DJ Delorie <dj@redhat.com>

From-SVN: r114250
---
 gcc/ChangeLog          | 6 ++++++
 gcc/config/m32c/m32c.c | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ed782e16ee66..04a83735875f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-30  Naveen.H.S  <naveenh@kpitcummins.com>
+	    DJ Delorie  <dj@redhat.com>
+
+	* config/m32c/m32c.c (m32c_expand_insv): Check that the value
+	we're inserting is a singlt-bit constant.
+
 2006-05-30  Roger Sayle  <roger@eyesopen.com>
 
 	* simplify-rtx.c (simplify_binary_operation_1) <LSHIFTRT>: Cast
diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c
index 186f666d0fbc..6fddc4b27607 100644
--- a/gcc/config/m32c/m32c.c
+++ b/gcc/config/m32c/m32c.c
@@ -3435,6 +3435,14 @@ m32c_expand_insv (rtx *operands)
   if (INTVAL (operands[1]) != 1)
     return 1;
 
+  /* Our insv opcode (bset, bclr) can only insert a one-bit constant.  */
+  if (GET_CODE (operands[3]) != CONST_INT)
+    return 1;
+  if (INTVAL (operands[3]) != 0
+      && INTVAL (operands[3]) != 1
+      && INTVAL (operands[3]) != -1)
+    return 1;
+
   mask = 1 << INTVAL (operands[2]);
 
   op0 = operands[0];
-- 
GitLab