[PATCH] Fix MIPS LHX in mips-dsp.md
Fu, Chao-Ying
fu@mips.com
Wed Nov 11 01:08:00 GMT 2009
Hi,
I found a bug for the MIPS DSP LHX pattern in mips-dsp.md.
We should use sign_extend, because LHX loads a halfword as a signed value.
This patch is for GCC mainline and GCC 4.4.
Ok to check in? Thanks a lot!
Regards,
Chao-ying
gcc/ChangeLog
2009-11-10 Chao-ying Fu <fu@mips.com>
* config/mips/mips-dsp.md (mips_lhx_<mode>): Use sign_extend.
gcc/testsuite/ChangeLog
2009-11-10 Chao-ying Fu <fu@mips.com>
* gcc.target/mips/dsp-lhx.c: New test.
* gcc.target/mips/dsp-no-lhx.c: New test.
Index: mips-dsp.md
===================================================================
--- mips-dsp.md (revision 154055)
+++ mips-dsp.md (working copy)
@@ -1066,7 +1066,7 @@
(define_insn "mips_lhx_<mode>"
[(set (match_operand:SI 0 "register_operand" "=d")
- (zero_extend:SI
+ (sign_extend:SI
(mem:HI (plus:P (match_operand:P 1 "register_operand" "d")
(match_operand:P 2 "register_operand" "d")))))]
"ISA_HAS_DSP"
Index: dsp-lhx.c
===================================================================
--- dsp-lhx.c (revision 0)
+++ dsp-lhx.c (revision 0)
@@ -0,0 +1,10 @@
+/* Test MIPS32 DSP LHX instruction */
+/* { dg-do compile } */
+/* { dg-options "-mgp32 -mdsp -O2" } */
+
+/* { dg-final { scan-assembler "\tlhx\t" } } */
+
+NOMIPS16 signed short test (signed short *a, int index)
+{
+ return a[index];
+}
Index: dsp-no-lhx.c
===================================================================
--- dsp-no-lhx.c (revision 0)
+++ dsp-no-lhx.c (revision 0)
@@ -0,0 +1,10 @@
+/* Test MIPS32 DSP LHX instruction */
+/* { dg-do compile } */
+/* { dg-options "-mgp32 -mdsp -O2" } */
+
+/* { dg-final { scan-assembler-not "\tlhx\t" } } */
+
+NOMIPS16 unsigned short test (unsigned short *a, int index)
+{
+ return a[index];
+}
More information about the Gcc-patches
mailing list