[LLVMbugs] [Bug 3599] New: Bad-quality code passing union as argument on x86_64

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Feb 16 20:36:02 PST 2009


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

           Summary: Bad-quality code passing union as argument on x86_64
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


union UGeckoInstruction
{
unsigned hex;
};
unsigned a(union UGeckoInstruction a) {return a.hex;}

Run through clang -emit-llvm -O2 -arch=x86_64, gives the following:
; ModuleID = '-'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "x86_64-pc-linux-gnu"

define i32 @a(i64) nounwind readnone {
entry:
        %tmp5 = trunc i64 %0 to i8              ; <i8> [#uses=1]
        %tmp7 = lshr i64 %0, 8          ; <i64> [#uses=1]
        %tmp8 = trunc i64 %tmp7 to i8           ; <i8> [#uses=1]
        %tmp10 = lshr i64 %0, 16                ; <i64> [#uses=1]
        %tmp11 = trunc i64 %tmp10 to i8         ; <i8> [#uses=1]
        %tmp13 = lshr i64 %0, 24                ; <i64> [#uses=1]
        %tmp14 = trunc i64 %tmp13 to i8         ; <i8> [#uses=1]
        %1 = zext i8 %tmp5 to i32               ; <i32> [#uses=1]
        %2 = zext i8 %tmp8 to i32               ; <i32> [#uses=1]
        %3 = shl i32 %2, 8              ; <i32> [#uses=1]
        %4 = zext i8 %tmp11 to i32              ; <i32> [#uses=1]
        %5 = shl i32 %4, 16             ; <i32> [#uses=1]
        %6 = zext i8 %tmp14 to i32              ; <i32> [#uses=1]
        %7 = shl i32 %6, 24             ; <i32> [#uses=1]
        %8 = or i32 %7, %1              ; <i32> [#uses=1]
        %9 = or i32 %8, %5              ; <i32> [#uses=1]
        %10 = or i32 %9, %3             ; <i32> [#uses=1]
        ret i32 %10
}

This is rather silly.  I'm not sure whether to blame clang or the LLVM
optimizers for this result, though.


-- 
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.



More information about the llvm-bugs mailing list