Yours (Richard Kenner's) patch to genrecog

Jan Hubicka jh@suse.cz
Sun Oct 21 10:14:00 GMT 2001


>     is wrong, as it makes genrecog to generate switch over values wider
>     than host's int (this is common in case HOST_WIDE_INT is long long as
>     done for 64bit crosscompilers) that makes values to be truncated and
>     for instance (const_int 0x100000000) is recognized as (const_int 0).
> 
> But I thought I put in a subsequent patch to fix that?
> 
> Can you say *exactly* what's wrong.
We do have peep2 in i386.md:

(define_peephole2
  [(set (match_operand 0 "register_operand" "")
	(const_int -1))]
  "(GET_MODE (operands[0]) == HImode
    || GET_MODE (operands[0]) == SImode 
    || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
   && (optimize_size || TARGET_PENTIUM)
   && peep2_regno_dead_p (0, FLAGS_REG)"
  [(parallel [(set (match_dup 0) (const_int -1))
	      (clobber (reg:CC 17))])]
  "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
			      true_regnum (operands[0]));")

(define_peephole2
  [(set (match_operand 0 "register_operand" "")
	(const_int 0))]
  "(GET_MODE (operands[0]) == QImode
    || GET_MODE (operands[0]) == HImode
    || GET_MODE (operands[0]) == SImode
    || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
   && (! TARGET_USE_MOV0 || optimize_size)
   && peep2_regno_dead_p (0, FLAGS_REG)"
  [(parallel [(set (match_dup 0) (const_int 0))
	      (clobber (reg:CC 17))])]
  "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
			      true_regnum (operands[0]));")

and several other constants.  Then the genrecog generates and switch statement according
the INTVAL of the constant operand.
I have instruction (set (reg x) (const_int 0x100000000) that gets recognized as
the second peephole citet above, as the switch truncates the upper part
resulting in missoptimizations.

As discussed before there are possibilities - we can eighter disable the switches if
HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_INT
or we can make genrecog to produce the switches only when compiled by gcc that allows
switch over long
or we can verify that the value really match in each case:.

Honza



More information about the Gcc-bugs mailing list