[LLVMbugs] [Bug 2107] New: Bad middle-end optimization for insertelement

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Feb 27 11:21:56 PST 2008


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

           Summary: Bad middle-end optimization for insertelement
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


Testcase:
#include <xmmintrin.h>
__m128i doload64(unsigned long long x) { return _mm_loadl_epi64(&x);}

Generated il:
define <2 x i64> @doload64(i64 %x) nounwind  {
entry:
        %tmp717 = bitcast i64 %x to double
        %tmp8 = insertelement <2 x double> undef, double %tmp717, i32 0
        %tmp9 = insertelement <2 x double> %tmp8, double 0.000000e+00, i32 1
        %tmp11 = bitcast <2 x double> %tmp9 to <2 x i64>
        ret <2 x i64> %tmp11
}

This seems somewhat less than ideal.  Ideally, it would look something like the
following:

define <2 x i64> @doload64(i64 %x) nounwind  {
entry:
        %tmp8 = insertelement <2 x i64> zeroinitializer, i64 %x, i32 0
        ret <2 x i64> %tmp8
}

Note that this affects the codegen for this construct on x86-64: the orginial
codegens to the following:
doload64:
        movd    %rdi, %xmm1
        xorps   %xmm0, %xmm0
        movsd   %xmm1, %xmm0
        ret

and the simplified version codegens to the following:
doload64:
        movd    %rdi, %xmm0
        ret

Although maybe the backend should be smarter about this sort of thing as well.


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