[LLVMbugs] [Bug 6194] New: inlining of MRV function does not remove bitcast-/shift-/ zext-/trunc-operations on x64

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Feb 1 02:51:50 PST 2010


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

           Summary: inlining of MRV function does not remove bitcast-/shift-
                    /zext-/trunc-operations on x64
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: karrenberg at cs.uni-saarland.de
                CC: llvmbugs at cs.uiuc.edu


For the code below, llvm-gcc generates non-optimal code for accessing and
returning structs on x64.

In order to conform to ABI requirements, a struct parameter which holds 3
floats is split into two parameters: a double and a float.
Accessing the first two struct-values results in a series of bitcast-, zext-,
lshr-, and trunc-operations (test1).

It should be possible to reduce this to bitcast(i64)-shift-bitcast(float).


More importantly however, if code that returns a struct is inlined into a
function that defines that same struct, the corresponding series of operations
as above are entirely redundant (float ->
bitcast/zext/shl/zext/lshr/trunc/bitcast -> float) but do not get optimized
away (test3):

define void @test2(float %aX, float %aY, float %aZ, %struct.float3* nocapture
%res) nounwind noinline {
entry:
  %tmp27 = bitcast float %aY to i32               ; <i32> [#uses=1]
  %tmp28 = zext i32 %tmp27 to i96                 ; <i96> [#uses=1]
  %tmp29 = shl i96 %tmp28, 32                     ; <i96> [#uses=1]
  %tmp21 = zext i96 %tmp29 to i128                ; <i128> [#uses=1]
  %0 = getelementptr inbounds %struct.float3* %res, i64 0, i32 0 ; <float*>
[#uses=1]
  store float %aX, float* %0, align 4
  %1 = getelementptr inbounds %struct.float3* %res, i64 0, i32 1 ; <float*>
[#uses=1]
  %tmp10 = lshr i128 %tmp21, 32                   ; <i128> [#uses=1]
  %tmp11 = trunc i128 %tmp10 to i32               ; <i32> [#uses=1]
  %tmp12 = bitcast i32 %tmp11 to float            ; <float> [#uses=1]
  store float %tmp12, float* %1, align 4
  %2 = getelementptr inbounds %struct.float3* %res, i64 0, i32 2 ; <float*>
[#uses=1]
  store float %aZ, float* %2, align 4
  ret void
}


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