https://bugs.kde.org/show_bug.cgi?id=367543
            Bug ID: 367543
           Summary: bt/btc/btr/bts x86/x86_64 instructions are
                    poorly-handled wrt flags
           Product: valgrind
           Version: 3.10.0
          Platform: Other
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: vex
          Assignee: jsew...@acm.org
          Reporter: shortc...@fastmail.com

According to the code, O,S,Z,A,P are being forced to 0, under the rationale
that they are "undefined", with no (apparent) user-visible warnings emitted
regarding
the effects this has on future instructions with dependencies on these flags,
which is less than ideal.

Additionally, the Z flag should be unmodified, not undefined, per real-world
CPU behavior and this excerpt(for BT) from Intel's June 2016 architecture
manual:
"The CF flag contains the value of the selected bit. The ZF flag is unaffected.
The OF, SF, AF, and PF flags are undefined."

Quick and dirty test case derived from a larger program:

int main(int argc, char* argv[])
{
 unsigned a = 0;
 unsigned b = 1;

 asm volatile(
        "testl $15, %%eax\n\t"
        "bt $15, %%ebx\n\t"
        "cmovbe %%ebx, %%eax\n\t"
        : "=a"(a)
        : "a"(a), "b"(b)
        : "cc" );

 __builtin_printf("%u\n", a); 
 if(a != 1)
  __builtin_abort();

 return 0;
}


Reproducible: Always

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to