[Bug target/53315] simple xtest program generates ICE

2013-03-15 Thread andi-gcc at firstfloor dot org


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



Andi Kleen andi-gcc at firstfloor dot org changed:



   What|Removed |Added



 Status|NEW |RESOLVED

 Resolution||FIXED



--- Comment #20 from Andi Kleen andi-gcc at firstfloor dot org 2013-03-15 
13:55:28 UTC ---

Fixed for some time


[Bug target/53315] simple xtest program generates ICE

2012-08-22 Thread eraman at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #19 from eraman at gcc dot gnu.org 2012-08-22 21:07:40 UTC ---
Author: eraman
Date: Wed Aug 22 21:07:30 2012
New Revision: 190601

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=190601
Log:
2012-08-22   Easwaran Raman  era...@google.com
Backport r187387 and r187477 from trunk.

r187387:
2012-05-11  Uros Bizjak  ubiz...@gmail.com
PR target/53291
* config/i386/i386.md (xtest): Use NE condition in ix86_expand_setcc.

r187477:
2012-05-14  Andrew Pinski  apin...@cavium.com
H.J. Lu  hongjiu...@intel.com
Jakub Jelinek  ja...@redhat.com
PR target/53315
* config/i386/i386.md (xbegin_1): Use + in constraint and
match_dup.
(xbegin): Updated.

gcc/testsuite/ChangeLog.google-4_7:
2012-08-22   Easwaran Raman  era...@google.com
Backport r187477 from trunk:

2012-05-14  Andi Kleen a...@linux.intel.com
Jakub Jelinek  ja...@redhat.com

PR target/53315
* gcc.target/i386/i386.exp (check_effective_target_rtm): New.
* gcc.target/i386/rtm-check.h: New file.
* gcc.target/i386/pr53315.c: New test.


Added:
branches/google/gcc-4_7/gcc/testsuite/gcc.target/i386/pr53315.c
  - copied unchanged from r187477,
trunk/gcc/testsuite/gcc.target/i386/pr53315.c
branches/google/gcc-4_7/gcc/testsuite/gcc.target/i386/rtm-check.h
  - copied unchanged from r187477,
trunk/gcc/testsuite/gcc.target/i386/rtm-check.h
Modified:
branches/google/gcc-4_7/gcc/ChangeLog.google-4_7
branches/google/gcc-4_7/gcc/config/i386/i386.md
branches/google/gcc-4_7/gcc/testsuite/ChangeLog.google-4_7
branches/google/gcc-4_7/gcc/testsuite/gcc.target/i386/i386.exp


[Bug target/53315] simple xtest program generates ICE

2012-05-14 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #18 from Jakub Jelinek jakub at gcc dot gnu.org 2012-05-14 
18:47:09 UTC ---
Author: jakub
Date: Mon May 14 18:47:05 2012
New Revision: 187477

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=187477
Log:
2012-05-14  Andrew Pinski  apin...@cavium.com
H.J. Lu  hongjiu...@intel.com
Jakub Jelinek  ja...@redhat.com

PR target/53315
* config/i386/i386.md (xbegin_1): Use + in constraint and
match_dup.
(xbegin): Updated.

2012-05-14  Andi Kleen a...@linux.intel.com
Jakub Jelinek  ja...@redhat.com

PR target/53315
* gcc.target/i386/i386.exp (check_effective_target_rtm): New.
* gcc.target/i386/rtm-check.h: New file.
* gcc.target/i386/pr53315.c: New test.

Added:
trunk/gcc/testsuite/gcc.target/i386/pr53315.c
trunk/gcc/testsuite/gcc.target/i386/rtm-check.h
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/i386.md
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.target/i386/i386.exp


[Bug target/53315] simple xtest program generates ICE

2012-05-12 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #11 from Jakub Jelinek jakub at gcc dot gnu.org 2012-05-12 
09:14:53 UTC ---
Created attachment 27385
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=27385
gcc48-pr53315.patch

That is because the patch is buggy.  Fixed thusly, though haven't tested it on
Haswell (obviously) nor sim.

Note, it would be nice to have a peephole or something similar (guess peepholes
won't do anything across multiple bbs, perhaps machine reorg) to optimize that
movl$-1, %eax
xbegin  .L2
.L2:
cmpl$-1, %eax
jne .L3
xorl%eax, %eax
into say
movl$-1, %eax
xbegin  .L3
xorl%eax, %eax
or even
xbegin  .L3
xorl%eax, %eax


[Bug target/53315] simple xtest program generates ICE

2012-05-12 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #12 from Uros Bizjak ubizjak at gmail dot com 2012-05-12 11:29:53 
UTC ---
(In reply to comment #11)
 Created attachment 27385 [details]
 gcc48-pr53315.patch

Please introduce check-rtm.h header for use in runtime testcases, as is the
case with i.e. check-sse2.h and other feature check headers.


[Bug target/53315] simple xtest program generates ICE

2012-05-12 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

  Attachment #27385|0   |1
is obsolete||

--- Comment #13 from Jakub Jelinek jakub at gcc dot gnu.org 2012-05-12 
14:05:07 UTC ---
Created attachment 27387
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=27387
gcc48-pr53315.patch

Like this?


[Bug target/53315] simple xtest program generates ICE

2012-05-12 Thread andi-gcc at firstfloor dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #14 from Andi Kleen andi-gcc at firstfloor dot org 2012-05-12 
16:04:27 UTC ---
I can confirm the simple test program works correctly with Jakub's patch.
I'll leave full bootstrap to HJ.


[Bug target/53315] simple xtest program generates ICE

2012-05-12 Thread andi-gcc at firstfloor dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #15 from Andi Kleen andi-gcc at firstfloor dot org 2012-05-12 
16:06:00 UTC ---
Oh yes and it would be really nice to have those peepholes for xbegin Jakub.

I normally use my own macros with asm goto to avoid the ugly code.

Do you think machine reorg could be done without slowing down the compiler?


[Bug target/53315] simple xtest program generates ICE

2012-05-12 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #16 from Uros Bizjak ubizjak at gmail dot com 2012-05-12 16:31:21 
UTC ---
(In reply to comment #13)

 Like this?

Yes, this is OK, after someone confirms that the testcase works as expected on
HW or simulator.


[Bug target/53315] simple xtest program generates ICE

2012-05-12 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #17 from Uros Bizjak ubizjak at gmail dot com 2012-05-12 16:36:39 
UTC ---
(In reply to comment #15)

 Do you think machine reorg could be done without slowing down the compiler?

Yes, xbegin RTM pattern can raise a flag that triggers machine reorg (so it
won't fire for functions that don't emit xbegin).


[Bug target/53315] simple xtest program generates ICE

2012-05-11 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #6 from Uros Bizjak ubizjak at gmail dot com 2012-05-11 09:41:15 
UTC ---
(In reply to comment #5)
 Created attachment 27370 [details]
 A patch

Patch looks OK to me, but please let Andi play with this a bit, so we are sure
we won't hit some other reload limitation with this pattern.


[Bug target/53315] simple xtest program generates ICE

2012-05-11 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

Uros Bizjak ubizjak at gmail dot com changed:

   What|Removed |Added

   Keywords||patch
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2012-05-11
Version|unknown |4.8.0
   Target Milestone|--- |4.8.0
 Ever Confirmed|0   |1

--- Comment #7 from Uros Bizjak ubizjak at gmail dot com 2012-05-11 09:51:46 
UTC ---
As discussed in PR 53291, please also add a runtime testcase that will cover PR
53291 as well as this PR.


[Bug target/53315] simple xtest program generates ICE

2012-05-11 Thread andi-gcc at firstfloor dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #8 from Andi Kleen andi-gcc at firstfloor dot org 2012-05-11 
18:02:43 UTC ---
I tested HJs fix on the test case and also on a more complex program and it all
works as expected. Please commit.


[Bug target/53315] simple xtest program generates ICE

2012-05-11 Thread andi-gcc at firstfloor dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #9 from Andi Kleen andi-gcc at firstfloor dot org 2012-05-11 
21:35:47 UTC ---
Sorry I was wrong earlier. Retested now fully with a full test case and HJs
patch and i always get aborts

The xbegin gets miscompiled now, the in transaction branch disappears.

  400460:   48 83 ec 08 sub$0x8,%rsp
  400464:   b8 ff ff ff ff  mov$0x,%eax
  400469:   c7 f8 00 00 00 00   xbeginq 40046f main+0xf
  40046f:   bf d8 06 40 00  mov$0x4006d8,%edi
  400474:   31 f6   xor%esi,%esi
  400476:   31 c0   xor%eax,%eax
  400478:   e8 b3 ff ff ff  callq  400430 printf@plt
  40047d:   31 ff   xor%edi,%edi
  40047f:   e8 bc ff ff ff  callq  400440 exit@plt




/* PR53315 and PR53291 */
/* { dg-do run } */
/* { dg-options -O2 -mrtm } */

#include immintrin.h
#include cpuid.h
#include stdlib.h
#include stdio.h

static int cpu_has_rtm(void)
{
if (__get_cpuid_max(0, NULL) = 7) {
unsigned a, b, c, d;
__cpuid_count(7, 0, a, b, c, d);
return !!(b  bit_RTM);
}
return 0;
}


int main(void)
{
int flag = -1;
unsigned status;

if (!cpu_has_rtm) { 
printf(no tsx support. untested\n);
exit(0);
}

if ((status = _xbegin()) == _XBEGIN_STARTED) {
flag = _xtest();
_xend();
} else {
/* Note this is legal according to the TSX spec */
printf(unexpected abort %x. untested\n, status);
exit(0);
}

if (flag != 1)
abort();
if (_xtest() != 0)
abort();
return 0;
}


[Bug target/53315] simple xtest program generates ICE

2012-05-11 Thread phpbbaid at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #10 from phpbbaid at gmail dot com 2012-05-11 23:02:22 UTC ---
please unsubscribe



-Original Message- 
From: andi-gcc at firstfloor dot org
Sent: Friday, May 11, 2012 11:35 PM
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/53315] simple xtest program generates ICE

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

--- Comment #9 from Andi Kleen andi-gcc at firstfloor dot org 2012-05-11 
21:35:47 UTC ---
Sorry I was wrong earlier. Retested now fully with a full test case and HJs
patch and i always get aborts

The xbegin gets miscompiled now, the in transaction branch disappears.

  400460:   48 83 ec 08 sub$0x8,%rsp
  400464:   b8 ff ff ff ff  mov$0x,%eax
  400469:   c7 f8 00 00 00 00   xbeginq 40046f main+0xf
  40046f:   bf d8 06 40 00  mov$0x4006d8,%edi
  400474:   31 f6   xor%esi,%esi
  400476:   31 c0   xor%eax,%eax
  400478:   e8 b3 ff ff ff  callq  400430 printf@plt
  40047d:   31 ff   xor%edi,%edi
  40047f:   e8 bc ff ff ff  callq  400440 exit@plt




/* PR53315 and PR53291 */
/* { dg-do run } */
/* { dg-options -O2 -mrtm } */

#include immintrin.h
#include cpuid.h
#include stdlib.h
#include stdio.h

static int cpu_has_rtm(void)
{
if (__get_cpuid_max(0, NULL) = 7) {
unsigned a, b, c, d;
__cpuid_count(7, 0, a, b, c, d);
return !!(b  bit_RTM);
}
return 0;
}


int main(void)
{
int flag = -1;
unsigned status;

if (!cpu_has_rtm) {
printf(no tsx support. untested\n);
exit(0);
}

if ((status = _xbegin()) == _XBEGIN_STARTED) {
flag = _xtest();
_xend();
} else {
/* Note this is legal according to the TSX spec */
printf(unexpected abort %x. untested\n, status);
exit(0);
}

if (flag != 1)
abort();
if (_xtest() != 0)
abort();
return 0;
}


[Bug target/53315] simple xtest program generates ICE

2012-05-10 Thread andi-gcc at firstfloor dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

Andi Kleen andi-gcc at firstfloor dot org changed:

   What|Removed |Added

 CC||kirill.yukhin at intel dot
   ||com

--- Comment #1 from Andi Kleen andi-gcc at firstfloor dot org 2012-05-10 
22:51:45 UTC ---
Hmm it goes away when i remove the (status = _xbegin)
so it may be actually xbegin not xtest


[Bug target/53315] simple xtest program generates ICE

2012-05-10 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #2 from Uros Bizjak ubizjak at gmail dot com 2012-05-10 23:42:05 
UTC ---
(In reply to comment #1)
 Hmm it goes away when i remove the (status = _xbegin)
 so it may be actually xbegin not xtest

Yes, it is xbegin_1 insn pattern that doesn't get registers allocated.

However, the pattern (although a bit unusual), looks correct to me.


[Bug target/53315] simple xtest program generates ICE

2012-05-10 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #3 from Andrew Pinski pinskia at gcc dot gnu.org 2012-05-10 
23:44:01 UTC ---
Reload does not know how to handle reloading into jump instructions.


[Bug target/53315] simple xtest program generates ICE

2012-05-10 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #4 from Andrew Pinski pinskia at gcc dot gnu.org 2012-05-10 
23:47:57 UTC ---
(define_expand xbegin
  [(set (match_operand:SI 0 register_operand)
(unspec_volatile:SI [(match_dup 1)] UNSPECV_XBEGIN))]
  TARGET_RTM
{
  rtx label = gen_label_rtx ();

  operands[0] = force_reg (SImode, constm1_rtx);

  emit_jump_insn (gen_xbegin_1 (operands[0], label));

  emit_label (label);
  LABEL_NUSES (label) = 1;

  DONE;
})

(define_insn xbegin_1
  [(set (pc)
(if_then_else (ne (unspec [(const_int 0)] UNSPEC_XBEGIN_ABORT)
  (const_int 0))
  (label_ref (match_operand 1))
  (pc)))
   (set (match_operand:SI 0 register_operand +a)
(unspec_volatile:SI [(match_dup 0)]
UNSPECV_XBEGIN))]
  TARGET_RTM
  xbegin\t%l2
  [(set_attr type other)
   (set_attr length 6)])

I think this is the one of the few cases where you want to use + in the
constraint and match_dup.


[Bug target/53315] simple xtest program generates ICE

2012-05-10 Thread hjl.tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315

--- Comment #5 from H.J. Lu hjl.tools at gmail dot com 2012-05-11 03:14:45 
UTC ---
Created attachment 27370
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=27370
A patch