Patchwork [alpha] : Fix recent gfortran.dg/pr32533.f90 test failure

login
register
mail settings
Submitter Uros Bizjak
Date Aug. 31, 2013, 1:18 p.m.
Message ID <CAFULd4aPce4ZsYbkuTZJrh7-vB+xFqRRrDWV+7Zu3fE+NOX3_g@mail.gmail.com>
Download mbox | patch
Permalink /patch/271527/
State New
Headers show

Comments

Uros Bizjak - Aug. 31, 2013, 1:18 p.m.
Hello!

The compilation emitted following sequence for cmove with unsigned
compare, resulting in gfortran.dg/pr32533.f90 runtime failure [1]:

(insn 70 69 71 (set (reg:DI 143)
        (leu:DI (reg:DI 139)
            (const_int 18 [0x12]))) -1
     (nil))

(insn 71 70 72 (set (reg:DF 144)
        (eq:DF (subreg:DF (reg:DI 143) 0)
            (const_double:DF 0.0 [0x0.0p+0]))) -1
     (nil))

(insn 72 71 73 (set (reg:DF 137 [ D.934 ])
        (if_then_else:DF (eq (reg:DF 144)
                (const_double:DF 0.0 [0x0.0p+0]))
            (reg:DF 137 [ D.934 ])
            (reg:DF 140))) -1
     (nil))

where (insn 71) trapped with denormal operand FP exception.

The problem was in alpha_emit_conditional_move, where fixup code
didn't trigger for "code" variable, changed in "if (FLOAT_MODE_P
(cmp_mode) != FLOAT_MODE_P (mode))" part. Since cmove insns don't trap
on compare, the compare of (insn 71) should be put inside cmove
itself.

Attached patch updates "cmp" RTX for "code" changes, resulting in:

(insn 70 69 71 (set (reg:DI 143)
        (leu:DI (reg:DI 139)
            (const_int 18 [0x12]))) -1
     (nil))

(insn 71 70 72 (set (reg:DF 137 [ D.934 ])
        (if_then_else:DF (ne (subreg:DF (reg:DI 143) 0)
                (const_double:DF 0.0 [0x0.0p+0]))
            (reg:DF 137 [ D.934 ])
            (reg:DF 140))) -1
     (nil))

2013-08-31  Uros Bizjak  <ubizjak@gmail.com>

    * config/alpha/alpha.c (alpha_emit_conditional_move): Update
    "cmp" RTX before signed_comparison_operator check to account
    for "code" changes.

Patch was tested on alphaev68-pc-linux-gnu and committed to mainline.

[1] http://gcc.gnu.org/ml/gcc-testresults/2013-08/msg02997.html

Uros.

Patch

Index: config/alpha/alpha.c
===================================================================
--- config/alpha/alpha.c	(revision 202125)
+++ config/alpha/alpha.c	(working copy)
@@ -2659,6 +2659,7 @@  alpha_emit_conditional_move (rtx cmp, enum machine
       cmp_mode = cmp_mode == DImode ? DFmode : DImode;
       op0 = gen_lowpart (cmp_mode, tem);
       op1 = CONST0_RTX (cmp_mode);
+      cmp = gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
       local_fast_math = 1;
     }