http://llvm.org/bugs/show_bug.cgi?id=12173

             Bug #: 12173
           Summary: incorrect shrdq instruction from __asm__() directive
           Product: clang
           Version: 3.0
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


Created attachment 8139
  --> http://llvm.org/bugs/attachment.cgi?id=8139
minimal c code to demonstrate __asm__() shrdq bug

This issue was discovered on clang 3.0, and reproduced on clang 3.1 in Xcode
4.3:
>>Apple clang version 3.1 (tags/Apple/clang-318.0.45) (based on LLVM 3.1svn)
>>Target: x86_64-apple-darwin11.3.0
/*
 * Using the 2-argument form of the shrdq instruction (i.e. with %cl implicit),
 * clang generates the following __asm__() directive as:
 *     shrdq $0x01,%rax,%rdx  // shift %rdx right 1 bit (immediate addressing!)
filling from %rax
 * Expected instruction:
 *     shrdq %cl,%rdx,%rax    // shift %rax right by %cl bits, filling from
%rdx
 *
 * Gcc generates the expected instruction from this __asm__() directive.
 */
unsigned long long
badshift(unsigned long long lo64,
         unsigned long long hi64,
         unsigned char shift)
{
   __asm__("shrdq   %1, %0"      /* XXX => shrdq $0x01,%rax,%rdx */
           : "=a" (lo64),
             "=d" (hi64)
           : "c"  (shift)
           : "cc");
   return lo64;
}

/*
 * Using the 3-argument form of the shrdq instruction (i.e. with %cl explicit),
 * clang correctly generates the following __asm__() directive as written.
 */
unsigned long long
goodshift(unsigned long long lo64,
          unsigned long long hi64,
          unsigned char shift)
{
   __asm__("shrdq   %2, %1, %0"  /* OK => shrdq %cl,%rdx,%rax */
           : "=a" (lo64),
             "=d" (hi64)
           : "c"  (shift)
           : "cc");
   return lo64;
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to