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]

Re: [RFC PATCH for 9] rs6000: Ordered comparisons (PR56864)


Hello!

+(define_insn "*cmpdd_cmpo"
+  [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
+ (compare:CCFP (match_operand:DD 1 "gpc_reg_operand" "d")
+      (match_operand:DD 2 "gpc_reg_operand" "d")))
+   (unspec [(match_dup 1) (match_dup 2)] UNSPEC_CMPO)]
+  "TARGET_DFP"
+  "dcmpo %0,%1,%2"
+  [(set_attr "type" "dfp")])

I have had some problems when adding UNSPEC tags as a parallel to a
compare for x86. For the testcase:

int testo (double a, double b)
{
  return a == b;
}

middle end code emits sequence like:

(insn 7 4 8 2 (set (reg:CCFP 17 flags)
        (unspec:CCFP [
                (compare:CCFP (reg/v:DF 89 [ a ])
                    (reg/v:DF 90 [ b ]))
            ] UNSPEC_NOTRAP)) "cmpdf.c":3 -1
     (nil))
(insn 8 7 9 2 (set (reg:QI 96)
        (ordered:QI (reg:CCFP 17 flags)
            (const_int 0 [0]))) "cmpdf.c":3 -1
     (nil))
(insn 9 8 11 2 (set (reg:SI 95)
        (zero_extend:SI (reg:QI 96))) "cmpdf.c":3 -1
     (nil))
(insn 11 9 10 2 (set (reg:SI 97)
        (const_int 0 [0])) "cmpdf.c":3 -1
     (nil))
(insn 10 11 12 2 (set (reg:CCFP 17 flags)
        (unspec:CCFP [
                (compare:CCFP (reg/v:DF 89 [ a ])
                    (reg/v:DF 90 [ b ]))
            ] UNSPEC_NOTRAP)) "cmpdf.c":3 -1
     (nil))
(insn 12 10 13 2 (set (reg:SI 92)
        (if_then_else:SI (uneq (reg:CCFP 17 flags)
                (const_int 0 [0]))
            (reg:SI 95)
            (reg:SI 97))) "cmpdf.c":3 -1
     (nil))

and postreload pass removes (insn 10). This was not the case when the
compare was implemented with a parallel.

Also, -ffast-math on x86 emits trapping compares for all cases. For
that reason, unordered (non-trapping) compares were wrapped in an
unspec, with the expectation that -ffast-math can perform some more
optimizations with patterns using naked compare RTX without unspec.

Uros.


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