public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kaushik Phatak <Kaushik.Phatak@kpitcummins.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: Jeff Law <law@redhat.com>,
	Prafulla Thakare	<Prafulla.Thakare@kpitcummins.com>
Subject: [Patch : H8300] Minor bug fix for bit instructions
Date: Fri, 29 Oct 2010 15:00:00 -0000	[thread overview]
Message-ID: <F56EA673D3E56E48804FE2B0D23EFD2D218B22C1A2@KCINPUNHJCMS01.kpit.com> (raw)

Hi,
The patch below fixes an ICE caused when 16-bit constants are used 
as operand 2 in logical operation.

MSTP.CRA.WORD  |= 0x40; -> This is OK
MSTP.CRA.WORD  |= 0x4000; -> This generates ICE

Operand 2 is right shifted by 8 so that it is in valid range to 
perform bit-operation in QI mode. 
The 'abs' is used for specific cases for constants like 0xFEFF (-257).

Regression done for h8300-elf-* and no new regressions found.
Please comment.

Regards,
Kaushik Phatak
www.kpitgnutools.com 

Changelog:

2010-10-29  Kaushik Phatak <kaushik.phatak@kpitcummins.com>

	* config/h8300/h8300.md (define_splits) : Add condition for
	16-bit const operands.

	
diff -upr trunk.orig/gcc/config/h8300/h8300.md trunk/gcc/config/h8300/h8300.md
--- trunk.orig/gcc/config/h8300/h8300.md	2010-08-26 20:55:19.000000000 +0530
+++ trunk/gcc/config/h8300/h8300.md	2010-10-28 19:57:14.000000000 +0530
@@ -1781,8 +1781,17 @@
 	(and:QI (match_dup 1)
 		(match_dup 2)))]
 {
-  operands[0] = adjust_address (operands[0], QImode, 1);
-  operands[1] = adjust_address (operands[1], QImode, 1);
+  if(abs(INTVAL(operands[2])) > 0xFF)
+  {
+    operands[0] = adjust_address (operands[0], QImode, 0);
+    operands[1] = adjust_address (operands[1], QImode, 0);
+    operands[2] = GEN_INT ((INTVAL(operands[2])) >> 8);
+  }
+  else
+   {
+   operands[0] = adjust_address (operands[0], QImode, 1);
+   operands[1] = adjust_address (operands[1], QImode, 1);
+   }
 })
 
 (define_insn "bclrhi_msx"
@@ -1916,8 +1925,17 @@
 	(ior:QI (match_dup 1)
 		(match_dup 2)))]
 {
-  operands[0] = adjust_address (operands[0], QImode, 1);
-  operands[1] = adjust_address (operands[1], QImode, 1);
+  if(abs(INTVAL(operands[2])) > 0xFF)
+  {
+    operands[0] = adjust_address (operands[0], QImode, 0);
+    operands[1] = adjust_address (operands[1], QImode, 0);
+    operands[2] = GEN_INT ((INTVAL(operands[2])) >> 8);
+  }
+  else
+   {
+   operands[0] = adjust_address (operands[0], QImode, 1);
+   operands[1] = adjust_address (operands[1], QImode, 1);
+   }
 })
 
 (define_insn "bsethi_msx"
@@ -1982,8 +2000,17 @@
 	(xor:QI (match_dup 1)
 		(match_dup 2)))]
 {
-  operands[0] = adjust_address (operands[0], QImode, 1);
-  operands[1] = adjust_address (operands[1], QImode, 1);
+  if(abs(INTVAL(operands[2])) > 0xFF)
+  {
+    operands[0] = adjust_address (operands[0], QImode, 0);
+    operands[1] = adjust_address (operands[1], QImode, 0);
+    operands[2] = GEN_INT ((INTVAL(operands[2])) >> 8);
+  }
+  else
+   {
+   operands[0] = adjust_address (operands[0], QImode, 1);
+   operands[1] = adjust_address (operands[1], QImode, 1);
+   }
 })
 
 (define_insn "bnothi_msx"


             reply	other threads:[~2010-10-29 14:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-29 15:00 Kaushik Phatak [this message]
2010-11-02  3:58 ` Jeff Law
2010-11-08  9:06   ` Kaushik Phatak
2010-11-09 15:28     ` Jeff Law
2010-12-14  7:25       ` Kaushik Phatak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F56EA673D3E56E48804FE2B0D23EFD2D218B22C1A2@KCINPUNHJCMS01.kpit.com \
    --to=kaushik.phatak@kpitcummins.com \
    --cc=Prafulla.Thakare@kpitcummins.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).