diff mbox

[4.8,i386] : Make CCZ mode compatible with CCGOC, CCGO and CCNO modes

Message ID CAFULd4bKjA7ZHKtFSqP5izEZPT8=nMbreKk52YDJNH+Y6aAtcA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Feb. 7, 2012, 12:59 p.m. UTC
Hello!

Attached patch declares CCZmode compatible with CCGOC, CCGO and CCNO modes.

2012-02-07  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.c (ix86_cc_modes_compatible): Declare CCZmode
	compatible with CCGOCmode, CCGCmode and CCNOmode.

Bootstrapped on x86_64-pc-linux-gnu, regression test still in progress.

This patch (together with previous combine/i386 proto-patch) is still
not enough to remove redundant test instruction from

int test (int a, int b)
{
  int lt = a + b < 0;
  int eq = a + b == 0;
  if (lt)
    return 1;
  return eq;
}

It looks to me that something is wrong with compare-elim pass. Since
CCZmode is now made compatible with CCGOCmode (and results in
CCGOCmode), compare-elim pass should update the comparison mode in

> (insn 9 8 10 2 (parallel [
>            (set (reg:SI 5 di [orig:60 D.1710 ] [60])
>                (plus:SI (reg/v:SI 5 di [orig:63 a ] [63])
>                    (reg/v:SI 4 si [orig:64 b ] [64])))
>            (set (reg:CCZ 17 flags)
>                (compare:CCZ (plus:SI (reg/v:SI 5 di [orig:63 a ] [63])
>                        (reg/v:SI 4 si [orig:64 b ] [64]))
>                    (const_int 0 [0])))
>        ]) cmp.c:4 261 {*addsi_2}
>     (nil))

to CCGOCmode and eliminate CCGOC compare:

> (insn 29 30 31 2 (set (reg:CCGOC 17 flags)
>        (compare:CCGOC (reg:SI 5 di [orig:60 D.1710 ] [60])
>            (const_int 0 [0]))) cmp.c:6 2 {*cmpsi_ccno_1}
>     (nil))

Uros.
diff mbox

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 183953)
+++ config/i386/i386.c	(working copy)
@@ -17778,6 +17778,27 @@  ix86_cc_modes_compatible (enum machine_mode m1, en
       || (m1 == CCGOCmode && m2 == CCGCmode))
     return CCGCmode;
 
+  if (m1 == CCZmode)
+    switch (m2)
+      {
+      default:
+	break;
+      case CCGOCmode:
+      case CCGCmode:
+      case CCNOmode:
+	return m2;
+      }
+  else if (m2 == CCZmode)
+    switch (m1)
+      {
+      default:
+	break;
+      case CCGOCmode:
+      case CCGCmode:
+      case CCNOmode:
+	return m1;
+      }
+
   switch (m1)
     {
     default: