------- Additional Comments From schlie at comcast dot net  2004-10-20 18:34 -------
Subject: Re:  wrong code emitted

Hi Andrew,

Please correct the failure mode description to " critical, wrong code",
as upon reviewing the avr.md file, it's now clear that this isn't a
"missed optimization"; GCC is failing to properly emit the instruction
explicitly matching it's specified QI mode operand constraints as specified
by a corresponding identically constrained C statement; more specifically:

(this behavior should be deterministic, and relies on no optimizations)

The explicit C declaration statement (which also fails for %):

signed char ss = (signed char)s / (signed char)s ;

Incorrectly emits an HI vs. QI mode instruction as specified avr.md

//uses <__divmodhi4> wrong, should be 8-bit <__divmodqi4>

  ce:    99 81           ldd    r25, Y+1    ; 0x01
  d0:    89 81           ldd    r24, Y+1    ; 0x01
  d2:    28 2f           mov    r18, r24
  d4:    33 27           eor    r19, r19
  d6:    27 fd           sbrc    r18, 7
  d8:    30 95           com    r19
  da:    89 2f           mov    r24, r25
  dc:    99 27           eor    r25, r25
  de:    87 fd           sbrc    r24, 7
  e0:    90 95           com    r25
  e2:    b9 01           movw    r22, r18
  e4:    0e 94 81 01     call    __divmodhi4
  e8:    6b 83           std    Y+3, r22    ; 0x03

Where the corresponding avr.md specifications are:

(define_expand "divmodqi4"
  [(set (reg:QI 24) (match_operand:QI 1 "register_operand" ""))
   (set (reg:QI 22) (match_operand:QI 2 "register_operand" ""))
   (parallel [(set (reg:QI 24) (div:QI (reg:QI 24) (reg:QI 22)))
              (set (reg:QI 25) (mod:QI (reg:QI 24) (reg:QI 22)))
              (clobber (reg:QI 22))
              (clobber (reg:QI 23))])
   (set (match_operand:QI 0 "register_operand" "") (reg:QI 24))
   (set (match_operand:QI 3 "register_operand" "") (reg:QI 25))]
  ""
  "")

(define_insn "*divmodqi4_call"
  [(set (reg:QI 24) (div:QI (reg:QI 24) (reg:QI 22)))
   (set (reg:QI 25) (mod:QI (reg:QI 24) (reg:QI 22)))
   (clobber (reg:QI 22))
   (clobber (reg:QI 23))]
  ""
  "%~call __divmodqi4"
  [(set_attr "type" "xcall")
   (set_attr "cc" "clobber")])


(define_expand "divmodhi4"
  [(set (reg:HI 24) (match_operand:HI 1 "register_operand" ""))
   (set (reg:HI 22) (match_operand:HI 2 "register_operand" ""))
   (parallel [(set (reg:HI 22) (div:HI (reg:HI 24) (reg:HI 22)))
              (set (reg:HI 24) (mod:HI (reg:HI 24) (reg:HI 22)))
              (clobber (reg:HI 26))
              (clobber (reg:QI 21))])
   (set (match_operand:HI 0 "register_operand" "") (reg:HI 22))
   (set (match_operand:HI 3 "register_operand" "") (reg:HI 24))]
  ""
  "")

(define_insn "*divmodhi4_call"
  [(set (reg:HI 22) (div:HI (reg:HI 24) (reg:HI 22)))
   (set (reg:HI 24) (mod:HI (reg:HI 24) (reg:HI 22)))
   (clobber (reg:HI 26))
   (clobber (reg:QI 21))]
  ""
  "%~call __divmodhi4"
  [(set_attr "type" "xcall")
   (set_attr "cc" "clobber")])

Which seems correct, but for some reason GCC is not able to recognize
when it's lhs operand is a QI mode operand when attempting to match
this specification when emitting code?

Thanks again, -paul-


> From: pinskia at gcc dot gnu dot org <[EMAIL PROTECTED]>
> Reply-To: <[EMAIL PROTECTED]>
> Date: 19 Oct 2004 20:39:44 -0000
> To: <[EMAIL PROTECTED]>
> Subject: [Bug target/18065] wrong built-in functions selected
> 
> 
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-19
> 20:39 -------
>     char ss = s % s ; //<__divmodhi4> wrong, should be 8-bit <__divmodqi4>
> This is not wrong as we sign extend the arguments as required by the C
> standard (to int).
> 
> So this is just an missed-optimization.
> 
> -- 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>            Severity|critical                    |minor
>           Component|c                           |target
>            Keywords|                            |missed-optimization
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065

Reply via email to