On 05/07/2015 02:38 PM, Richard Henderson wrote:
> Here's a prototype for i386 only, which stands up to light testing.
> I'd rather post this tonight rather than wait until tomorrow when I
> can write more proper dejagnu tests.
> 
> I've tested the intermedate patches via config-list.mk, so despite
> mucking around with vec.h vs target.h, all targets still compile.
> 
> That said, quite a bit of cleanup in expand_asm_stmt was required
> in order to make the target hook not be completely unintelligable,
> so depsite full regression testing on x86_64 and ppc64, I could
> well have broken something.

Hi!  I took this for a spin, and:

a) It seems to work correctly; haven't been able to break it yet.
b) It seems very easy to provoke it into producing pretty bad code.

(b) is obviously not at all unexpected, this is working impressively
well for a first RFC.  Here is a piece of test code I used for this.

I'm very impressed to see this happen so quickly, thank you!

        -hpa







extern void alpha(void);
extern void beta(void);

/* This case really should produce good code in both cases */

void good1(int x, int y)
{
  _Bool pf;

  asm("cmpl %2,%1"
      : "=@ccp" (pf)
      : "r" (x), "g" (y));

  if (pf)
    beta();
}

void bad1(int x, int y)
{
  _Bool le, pf;

  asm("cmpl %3,%2"
      : "=@ccle" (le), "=@ccp" (pf)
      : "r" (x), "g" (y));

  if (le)
    alpha();
  else if (pf)
    beta();
}

/* This case really is too much to ask... */

_Bool good2(int x, int y)
{
  _Bool le;

  asm("cmpl %2,%1"
      : "=@ccle" (le)
      : "r" (x), "g" (y));

  return le;
}

_Bool bad2(int x, int y)
{
  _Bool zf, of, sf;

  asm("cmpl %4,%3"
      : "=@ccz" (zf), "=@cco" (of), "=@ccs" (sf)
      : "r" (x), "g" (y));

  return zf | (sf ^ of);
}

/* One should expect this shouldn't produce *worse* code than the above... */

int good3(int x, int y, int a, int b)
{
  _Bool le;

  asm("cmpl %2,%1"
      : "=@ccle" (le)
      : "r" (x), "g" (y));

  return le ? b : a;
}

int bad3(int x, int y, int a, int b)
{
  _Bool zf, of, sf;

  asm("cmpl %4,%3"
      : "=@ccz" (zf), "=@cco" (of), "=@ccs" (sf)
      : "r" (x), "g" (y));

  return zf | (sf ^ of) ? b : a;
}

Reply via email to