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 PR optimization/8178 (x86)


Hi,

__builtin_ffs is broken on K6 because the splitter

(define_insn_and_split "*ffs_no_cmove"
  [(set (match_operand:SI 0 "nonimmediate_operand" "=r") 
	(ffs:SI (match_operand:SI 1 "nonimmediate_operand" "rm")))
   (clobber (match_scratch:SI 2 "=&q"))
   (clobber (reg:CC 17))]
  ""
  "#"
  "reload_completed"
  [(parallel [(set (match_dup 2) (const_int 0))
	      (clobber (reg:CC 17))])
   (parallel [(set (reg:CCZ 17) (compare:CCZ (match_dup 1) (const_int 0)))
	      (set (match_dup 0) (ctz:SI (match_dup 1)))])
   (set (strict_low_part (match_dup 3))
	(eq:QI (reg:CCZ 17) (const_int 0)))
   (parallel [(set (match_dup 2) (neg:SI (match_dup 2)))
	      (clobber (reg:CC 17))])
   (parallel [(set (match_dup 0) (ior:SI (match_dup 0) (match_dup 2)))
	      (clobber (reg:CC 17))])
   (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
	      (clobber (reg:CC 17))])]
{
  operands[3] = gen_lowpart (QImode, operands[2]);
})

produces

(parallel [(set (match_dup 2) (const_int 0))
	      (clobber (reg:CC 17))])

which is only matched by

(define_insn "*movsi_xor"
  [(set (match_operand:SI 0 "register_operand" "=r")
	(match_operand:SI 1 "const0_operand" "i"))
   (clobber (reg:CC 17))]
  "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
  "xor{l}\t{%0, %0|%0, %0}"
  [(set_attr "type" "alu1")
   (set_attr "mode" "SI")
   (set_attr "length_immediate" "0")])


Now K6 is a TARGET_USE_MOV0 target so the pattern is not recognized, except 
of course at -Os.

Fixed by adding a new *movsi_zero pattern, counterpart of *movsi_xor for 
TARGET_USE_MOV0 targets. Bootstrapped/regtested on k6-redhat-linux-gnu 
(mainline, except Ada and with my previous patch for K6).

It fixes gcc.c-torture/execute/ffs-[12].c on mainline.


2003-10-17  Eric Botcazou  <ebotcazou@libertysurf.fr>

	PR optimization/8178
	* config/i386/i386.md (*movsi_zero): New insn to set
	a register to zero on TARGET_USE_MOV0 targets.


-- 
Eric Botcazou
Index: config/i386/i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.484
diff -u -p -r1.484 i386.md
--- config/i386/i386.md	11 Oct 2003 21:11:26 -0000	1.484
+++ config/i386/i386.md	16 Oct 2003 17:22:52 -0000
@@ -1162,6 +1162,15 @@
    (set_attr "mode" "SI")
    (set_attr "length_immediate" "0")])
 
+(define_insn "*movsi_zero"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+	(match_operand:SI 1 "const0_operand" "i"))
+   (clobber (reg:CC 17))]
+  "reload_completed && (TARGET_USE_MOV0 && !optimize_size)"
+  "mov{l}\t{%1, %0|%0, %1}"
+  [(set_attr "type" "imov")
+   (set_attr "mode" "SI")])
+ 
 (define_insn "*movsi_or"
   [(set (match_operand:SI 0 "register_operand" "=r")
 	(match_operand:SI 1 "immediate_operand" "i"))

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