Hi, Andi discovered that xtest instruction generation is wrong. It generates xorl %esi, %esi xtest sete %sil but correct is reverse movl $1,%esi xtest setne %sil
Testcase?
(In reply to comment #1) > Testcase? It is trivial, so posting right here: #include <immintrin.h> unsigned a; int rtm_xtest (void) { if (_xtest ()) a = 1; } ./build-x86_64-linux/gcc/xgcc -B./build-x86_64-linux/gcc 1.c -S -mrtm $ cat 1.s ... xtest sete %al movsbl %al, %eax testl %eax, %eax je .L4 movl $1, a(%rip) ...
Correction. We can keep the xor %reg,%reg. We just need it because setnz only sets 8 bit to initialize the higher order bits. Alternatively the value can be zero extended afterwards or just stay at 8 bit if there is no need for it.
I am confused... is there anything wrong with current implementation or not?
Try this patch: Index: config/i386/i386.md =================================================================== --- config/i386/i386.md (revision 187372) +++ config/i386/i386.md (working copy) @@ -18422,7 +18422,7 @@ { emit_insn (gen_xtest_1 ()); - ix86_expand_setcc (operands[0], EQ, + ix86_expand_setcc (operands[0], NE, gen_rtx_REG (CCZmode, FLAGS_REG), const0_rtx); DONE; })
Uros patch fixes it and the code is correct now. Please commit. However in testing it I quickly hit PR53315
Author: uros Date: Thu May 10 23:31:03 2012 New Revision: 187387 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187387 Log: PR target/53291 * config/i386/i386.md (xtest): Use NE condition in ix86_expand_setcc. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.md
(In reply to comment #2) > (In reply to comment #1) > > Testcase? > > It is trivial, so posting right here: > We need a run-time testcase.
The example in PR53315 is a runtime test case, except: - it needs cpuid checks to be part of the test suite - the printfs need to be replaced with asserts - it needs to stop iceing first
(In reply to comment #9) > The example in PR53315 is a runtime test case, except: > - it needs cpuid checks to be part of the test suite > - the printfs need to be replaced with asserts > - it needs to stop iceing first So, let's close this PR as FIXED.
Author: eraman Date: Wed Aug 22 21:07:30 2012 New Revision: 190601 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190601 Log: 2012-08-22 Easwaran Raman <eraman@google.com> Backport r187387 and r187477 from trunk. r187387: 2012-05-11 Uros Bizjak <ubizjak@gmail.com> PR target/53291 * config/i386/i386.md (xtest): Use NE condition in ix86_expand_setcc. r187477: 2012-05-14 Andrew Pinski <apinski@cavium.com> H.J. Lu <hongjiu.lu@intel.com> Jakub Jelinek <jakub@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 <eraman@google.com> Backport r187477 from trunk: 2012-05-14 Andi Kleen <ak@linux.intel.com> Jakub Jelinek <jakub@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