This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix a bug in optimize_size -> optimize_function_for_s*_p i386.md conversion (PR target/37438)


Hi!

Revision 139737 did:
@@ -3703,7 +3713,8 @@ (define_insn "*zero_extendqihi2_movzbw_a
 (define_insn "*zero_extendqihi2_movzbl"
   [(set (match_operand:HI 0 "register_operand" "=r")
      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
-  "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed" 
+  "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_speed_p (cfun))
+   && reload_completed"
   "movz{bl|x}\t{%1, %k0|%k0, %1}"
   [(set_attr "type" "imovx")
    (set_attr "mode" "SI")]) 
while all other i386.md changes look correct (change
optimize_size to optimize_function_for_size_p (cfun) or
optimize_insn_for_size_p () and !optimize_size to
optimize_function_for_speed_p (cfun) or optimize_insn_for_speed_p ().
That inverts the test and breaks the attached testcase.  Ok for trunk?

2008-09-09  Jakub Jelinek  <jakub@redhat.com>

	PR target/37438
	* config/i386/i386.md (zero_extendqihi2_movzbl): Enable when optimizing
	for size, not speed.

	* gcc.dg/pr37438.c: New test.

--- gcc/config/i386/i386.md.jj	2008-09-05 12:56:20.000000000 +0200
+++ gcc/config/i386/i386.md	2008-09-09 12:00:31.000000000 +0200
@@ -3713,7 +3713,7 @@
 (define_insn "*zero_extendqihi2_movzbl"
   [(set (match_operand:HI 0 "register_operand" "=r")
      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
-  "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_speed_p (cfun))
+  "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))
    && reload_completed"
   "movz{bl|x}\t{%1, %k0|%k0, %1}"
   [(set_attr "type" "imovx")
--- gcc/testsuite/gcc.dg/pr37438.c.jj	2008-09-09 12:06:06.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr37438.c	2008-09-09 12:05:47.000000000 +0200
@@ -0,0 +1,21 @@
+/* PR target/37438 */
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+/* { dg-options "-Os -march=i486" { target { { i686-*-* x86_64-*-* } && ilp32 } } } */
+
+extern int bar (unsigned long long int);
+extern int baz (const char *, unsigned int, unsigned short);
+
+int
+foo (unsigned long long int x)
+{
+  return (x & 0xff) | ((unsigned int) (x >> 12) & ~0xff);
+}
+
+int
+test (const char *v, unsigned int w, unsigned long long int x)
+{
+  unsigned short k;
+  k = ((bar (x) & 0xff) << 8) | (foo (x) & 0xff);
+  return baz (v, w, k);
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]