Hi Jakub!

On Thu, 18 Dec 2014 12:33:11 +0100, Jakub Jelinek <ja...@redhat.com> wrote:
> On Thu, Dec 18, 2014 at 11:46:00AM +0100, Thomas Schwinge wrote:
> > > just
> > >   rtx v1 = GEN_INT (...);
> > >   rtx v2 = GEN_INT (...);
> > >   machine_mode mode = TYPE_MODE (TREE_TYPE (arg));
> > >   rtx ret = gen_reg_rtx (TYPE_MODE (integer_type_node));
> > >   emit_move_insn (ret, const0_rtx);
> > >   rtx_code_label *done_label = gen_label_rtx ();
> > >   emit_cmp_and_jump_insns (op, v1, NE, NULL_RTX, mode,
> > >                      false, done_label, PROB_EVEN);
> > >   emit_cmp_and_jump_insns (op, v2, NE, NULL_RTX, mode,
> > >                      false, done_label, PROB_EVEN);
> > >   emit_move_insn (ret, const1_rtx);
> > >   emit_label (done_label);
> > >   return ret;
> > > or similar.
> > 
> > Thanks for the review/suggestion/code!
> 
> Note, as I found later, emit_cmp_and_jump_insns is good enough only
> for certain modes on certain architectures (in particular, for
> cases where can_compare_p returns true).
> So it is better to use do_compare_rtx_and_jump instead of
> emit_cmp_and_jump_insns, because it handles also the cases which
> emit_cmp_and_jump_insns silently mishandles.  You'll need to reorder
> the arguments a little bit and add one NULL_RTX argument.
> See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63848#c4

Thanks again; committed to gomp-4_0-branch in r218862:

commit a58e1475324e6dd6c34a95883f5efc854e204fde
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Dec 18 13:13:06 2014 +0000

    OpenACC acc_on_device: Harden builtin expansion.
    
        gcc/
        * builtins.c (expand_builtin_acc_on_device): Use
        do_compare_rtx_and_jump instead of emit_cmp_and_jump_insns.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@218862 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.gomp | 3 +++
 gcc/builtins.c     | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp
index a3650c5..1e6df5f 100644
--- gcc/ChangeLog.gomp
+++ gcc/ChangeLog.gomp
@@ -1,6 +1,9 @@
 2014-12-18  Thomas Schwinge  <tho...@codesourcery.com>
            Jakub Jelinek  <ja...@redhat.com>
 
+       * builtins.c (expand_builtin_acc_on_device): Use
+       do_compare_rtx_and_jump instead of emit_cmp_and_jump_insns.
+
        * builtins.c (expand_builtin_acc_on_device): Make more RTXy.
 
 2014-12-17  Thomas Schwinge  <tho...@codesourcery.com>
diff --git gcc/builtins.c gcc/builtins.c
index e946521..33025a5 100644
--- gcc/builtins.c
+++ gcc/builtins.c
@@ -5911,10 +5911,10 @@ expand_builtin_acc_on_device (tree exp, rtx target)
     target = gen_reg_rtx (target_mode);
   emit_move_insn (target, const0_rtx);
   rtx_code_label *done_label = gen_label_rtx ();
-  emit_cmp_and_jump_insns (v, v1, NE, NULL_RTX, v_mode,
-                          false, done_label, PROB_EVEN);
-  emit_cmp_and_jump_insns (v, v2, NE, NULL_RTX, v_mode,
-                          false, done_label, PROB_EVEN);
+  do_compare_rtx_and_jump (v, v1, NE, false, v_mode, NULL_RTX,
+                          NULL_RTX, done_label, PROB_EVEN);
+  do_compare_rtx_and_jump (v, v2, NE, false, v_mode, NULL_RTX,
+                          NULL_RTX, done_label, PROB_EVEN);
   emit_move_insn (target, const1_rtx);
   emit_label (done_label);
 


Grüße,
 Thomas

Attachment: pgpybie4WoKNR.pgp
Description: PGP signature

Reply via email to