[Bug target/28691] missed optimization, redundant scalar SSE comparisons

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Aug 11 05:52:00 GMT 2006



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-08-11 05:52 -------
The problem is obvious from the RTL:
(insn:TI 47 7 48 (set (reg:CCFP 17 flags)
        (compare:CCFP (reg/v:SF 22 xmm1 [orig:59 a ] [59])
            (reg/v:SF 21 xmm0 [orig:60 b ] [60]))) 23 {*cmpfp_i_sse}
(insn_list:REG_DEP_OUTPUT 46 (insn_list:REG_DEP_TRUE 6 (insn_list:REG_DEP_TRUE
7 (nil))))
    (nil))

(insn 48 47 43 (set (strict_low_part (reg:QI 0 ax [62]))
        (unlt:QI (reg:CCFP 17 flags)
            (const_int 0 [0x0]))) 347 {*setcc_2} (insn_list:REG_DEP_TRUE 47
(insn_list:REG_DEP_TRUE 46 (nil)))
    (expr_list:REG_DEAD (reg:CCFP 17 flags)
        (nil)))

(insn 43 48 44 (parallel [
            (set (reg:SI 1 dx [64])
                (const_int 0 [0x0]))
            (clobber (reg:CC 17 flags))
        ]) 32 {*movsi_xor} (insn_list:REG_DEP_ANTI 48 (insn_list:REG_DEP_OUTPUT
47 (nil)))
    (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))

(insn:TI 44 43 45 (set (reg:CCFP 17 flags)
        (compare:CCFP (reg/v:SF 22 xmm1 [orig:59 a ] [59])
            (reg/v:SF 21 xmm0 [orig:60 b ] [60]))) 23 {*cmpfp_i_sse}
(insn_list:REG_DEP_ANTI 48 (insn_list:REG_DEP_OUTPUT 43
(insn_list:REG_DEP_OUTPUT 47 (insn_list:REG_DEP_TRUE 6 (insn_list:REG_DEP_TRUE
7 (nil))))))
    (expr_list:REG_DEAD (reg/v:SF 22 xmm1 [orig:59 a ] [59])
        (expr_list:REG_DEAD (reg/v:SF 21 xmm0 [orig:60 b ] [60])
            (nil))))

(insn 45 44 18 (set (strict_low_part (reg:QI 1 dx [64]))
        (uneq:QI (reg:CCFP 17 flags)
            (const_int 0 [0x0]))) 347 {*setcc_2} (insn_list:REG_DEP_TRUE 44
(insn_list:REG_DEP_TRUE 43 (nil)))
    (expr_list:REG_DEAD (reg:CCFP 17 flags)
        (nil)))

But the question is xor really setting the flags?
Maybe even just getting the expansion of setting the int.

Anyways here is a work around:
int test(float a, float b)
{
 unsigned char lt = a < b;
 unsigned char eq = a == b;

 unsigned char a1 = (lt + eq);
 return a1;
}
Using unsigned char and a temp variable removes the problem of zero extending
the grabbing of the flags.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-08-11 05:52:26
               date|                            |


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



More information about the Gcc-bugs mailing list