[LLVMbugs] [Bug 4216] Consecutive small memory accesses not merged in a bigger access

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Sep 22 06:53:56 PDT 2009


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


Sylvère Teissier <quickslyver at free.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




--- Comment #11 from Sylvère Teissier <quickslyver at free.fr>  2009-09-22 08:53:56 ---
that's stange with my target:

with -01 I have this: 

clang-cc test2.c -emit-llvm -o - -O1
; ModuleID = 'test2.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"

%struct.control_reg = type { i8, i8, [2 x i8] }

define void @test_bitfield(%struct.control_reg* noalias nocapture sret
%agg.result, %struct.control_reg* nocapture byval %c) nounwind {
entry:
  %tmp = bitcast %struct.control_reg* %c to i32*  ; <i32*> [#uses=1]
  %bf.prev.low = load i32* %tmp                   ; <i32> [#uses=1]
  %bf.prev.lo.cleared10 = or i32 %bf.prev.low, 32962 ; <i32> [#uses=1]
  %bf.new.lo11 = and i32 %bf.prev.lo.cleared10, -25350 ; <i32> [#uses=1]
  %0 = bitcast %struct.control_reg* %agg.result to i32* ; <i32*> [#uses=1]
  store i32 %bf.new.lo11, i32* %0, align 4
  ret void
}

that's ok,
but with -O2 / -O3 I have this:

$ clang-cc test2.c -emit-llvm -o - -O2
; ModuleID = 'test2.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"

%struct.control_reg = type { i8, i8, [2 x i8] }

define void @test_bitfield(%struct.control_reg* noalias nocapture sret
%agg.result, %struct.control_reg* nocapture byval %c) nounwind {
entry:
  %tmp = bitcast %struct.control_reg* %c to i32*  ; <i32*> [#uses=1]
  %bf.prev.low = load i32* %tmp                   ; <i32> [#uses=3]
  %bf.prev.lo.cleared10 = or i32 %bf.prev.low, 32962 ; <i32> [#uses=1]
  %bf.new.lo11 = and i32 %bf.prev.lo.cleared10, -25350 ; <i32> [#uses=2]
  %trunc = trunc i32 %bf.new.lo11 to i8           ; <i8> [#uses=1]
  %tmp28 = lshr i32 %bf.new.lo11, 8               ; <i32> [#uses=1]
  %tmp29 = trunc i32 %tmp28 to i8                 ; <i8> [#uses=1]
  %tmp30 = lshr i32 %bf.prev.low, 16              ; <i32> [#uses=1]
  %tmp31 = trunc i32 %tmp30 to i8                 ; <i8> [#uses=1]
  %tmp32 = lshr i32 %bf.prev.low, 24              ; <i32> [#uses=1]
  %tmp33 = trunc i32 %tmp32 to i8                 ; <i8> [#uses=1]
  %agg.result.0 = getelementptr %struct.control_reg* %agg.result, i32 0, i32 0
; <i8*> [#uses=1]
  store i8 %trunc, i8* %agg.result.0, align 4
  %agg.result.1 = getelementptr %struct.control_reg* %agg.result, i32 0, i32 1
; <i8*> [#uses=1]
  store i8 %tmp29, i8* %agg.result.1, align 1
  %agg.result.2.0 = getelementptr %struct.control_reg* %agg.result, i32 0, i32
2, i32 0 ; <i8*> [#uses=1]
  store i8 %tmp31, i8* %agg.result.2.0, align 2
  %agg.result.2.1 = getelementptr %struct.control_reg* %agg.result, i32 0, i32
2, i32 1 ; <i8*> [#uses=1]
  store i8 %tmp33, i8* %agg.result.2.1, align 2
  ret void
}

that's very bad :(
do you have the same behavior ?


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