On 01/14/15 16:52, Vladimir Makarov wrote:
   The problem of unexpected code generation is discussed on

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64110

   The following patch introduces 2 new constraints '^' and '$'  which
are analogous to '?' and '!' but disfavor given alternative when *the
operand with the new constraint* needs a reload ('?' and '!' disfavor
the alternative if *any* operand needs a reload).  I hope the new
constraints will be useful for other insns and targets.
Right. This gives us finer grained control over when to disparage an alternative.

Reloading some of the operands in an alternative may not be a big deal, but there may be other operands in the alternative that if a reload was needed for that operand would be so bad that we'd want to reject the entire alternative.

The example I had in mind when I read Vlad's analysis in the BZ were the old movb and addb patterns on the PA. Basically we have some side effect like addition/subtraction/register copy along with a conditional jump.

(define_insn ""
  [(set (pc)
        (if_then_else
          (match_operator 2 "movb_comparison_operator"
[(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
          (label_ref (match_operand 3 "" ""))
          (pc)))
   (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
        (match_dup 1))]

Needing a reload for operand 1 really isn't a big deal here, but reloading operand 0 is a disaster. This would be a good place to use the new constraint modifiers.

I can distinctly recall running into similar issues on other ports through the years. I wouldn't be at all surprised if a notable percentage of the "!" and "?"s that appear in our machine descriptions would be better off as "^" and "$".



2015-01-14  Vladimir Makarov <vmaka...@redhat.com>

         PR rtl-optimization/64110
         * stmt.c (parse_output_constraint): Process '^' and '$'.
         (parse_input_constraint): Ditto.
         * lra-constraints.c (process_alt_operands): Process the new
         constraints.
         * ira-costs.c (record_reg_classes): Process the new constraint
         '^'.
         * genoutput.c (indep_constraints): Add '^' and '$'.
         * config/i386/sse.md (*vec_dup<mode>): Use '$' instead of '!'.
         * doc/md.texi: Add description of the new constraints.

2015-01-14  Vladimir Makarov <vmaka...@redhat.com>

         PR rtl-optimization/64110
         * gcc.target/i386/pr64110.c: Add scan-assembler.


pr64110-3.patch


Index: config/i386/sse.md
===================================================================
--- config/i386/sse.md  (revision 219262)
+++ config/i386/sse.md  (working copy)
@@ -16713,7 +16713,7 @@
  (define_insn "*vec_dup<mode>"
    [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand" "=x,x,x")
        (vec_duplicate:AVX2_VEC_DUP_MODE
-         (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,x,!r")))]
+         (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,x,$r")))]
    "TARGET_AVX2"
    "@
     v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
Index: doc/md.texi
===================================================================
--- doc/md.texi (revision 219262)
+++ doc/md.texi (working copy)
@@ -1503,6 +1503,18 @@ in it.
  Disparage severely the alternative that the @samp{!} appears in.
  This alternative can still be used if it fits without reloading,
  but if reloading is needed, some other alternative will be used.
+
+@cindex @samp{^} in constraint
+@cindex caret
+@item ^
+This constraint is analogous to @samp{?} but it disparages slightly
+the alternative only unless the corresponding operand applies exactly.
+
+@cindex @samp{$} in constraint
+@cindex dollar sign
+@item $
+This constraint is analogous to @samp{!} but it disparages severely
+the alternative only unless the corresponding operand applies exactly.
  @end table
I found these hard to parse.

This disparages severely the alternative if the operand with the @samp{$} needs a reload.

Seems clearer to me.

With the doc update this is good for the trunk.

Jeff

Reply via email to