This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH SH]: Modify predicate for 'tst' instruction
- From: Kaushik Phatak <Kaushik dot Phatak at kpitcummins dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: "kkojima at gcc dot gnu dot org" <kkojima at gcc dot gnu dot org>, Prafulla Thakare <Prafulla dot Thakare at kpitcummins dot com>
- Date: Thu, 19 Nov 2009 19:08:37 +0530
- Subject: [PATCH SH]: Modify predicate for 'tst' instruction
Hi,
The following patch replaces the predicate 'arith_operand' in the
'tst' instruction with the 'logical_operand' predicate for the SH
target. When the 'arith_operand' predicate is used, the #imm used
with the 'tst' instruction is getting sign-extended and values above
0x7F are not supported. The compiler generates something like
and #199,r0
tst r0,r0
instead, it should do something like,
tst #199,r0
Also, 'logical_operand' tests for K08 constraint which seems more
appropriate, while the 'arith_operand' tests for I08. Any reason why
the port uses the 'arith_operand' in this case? The 'logical_operand'
predicate seems to be a logical choice as the 'tst' instruction does
support zero-extended 8-bit immediate data.
I have also added a name for debug dumps.
Regression done for sh-elf-* and no new regressions found.
Please comment.
Regards,
Kaushik Phatak
KPIT Cummins Infosystems Ltd,
Pune ( INDIA )
www.kpitgnutools.com
--
2009-11-18 Kaushik Phatak <kaushik.phatak@kpitcummins.com>
=======================Start of Patch================================
ChangeLog
2009-11-18 Kaushik Phatak <kaushik.phatak@kpitcummins.com>
* config/sh/sh.md: Added debug name for insn '*tstsi_t'
* config/sh/sh.md: Changed predicate for to 'logical_operand'
--- gcc-4.5-20091112/gcc/config/sh/sh.md.orig 2009-11-18 12:03:05.000000000 +0530
+++ gcc-4.5-20091112/gcc/config/sh/sh.md 2009-11-18 12:03:34.000000000 +0530
@@ -588,10 +588,10 @@
;; SImode signed integer comparisons
;; -------------------------------------------------------------------------
-(define_insn ""
+(define_insn "*tstsi_t"
[(set (reg:SI T_REG)
(eq:SI (and:SI (match_operand:SI 0 "arith_reg_operand" "z,r")
- (match_operand:SI 1 "arith_operand" "K08,r"))
+ (match_operand:SI 1 "logical_operand" "K08,r"))
(const_int 0)))]
"TARGET_SH1"
"tst %1,%0"
=========================End Of Patch================================