[LLVMbugs] [Bug 13799] New: Poor optimization of bitfield initialization
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Sep 8 11:08:45 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13799
Bug #: 13799
Summary: Poor optimization of bitfield initialization
Product: new-bugs
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: baldrick at free.fr
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 9184
--> http://llvm.org/bugs/attachment.cgi?id=9184
unoptimized testcase .ll
This testcase could be optimized to a succession of three i8 stores of -1 to
successive memory locations. In particular all the loads just load bits which
were either stored to just a few lines before, or are uninitialized, so could
be computed at compile time - but they aren't. In short it should be possible
to optimize down to
define void @bar() nounwind uwtable {
entry:
%foo = alloca %struct.Foo, align 4
%0 = getelementptr %struct.Foo* %foo, i64 0, i32 1
store i8 -1, i8* %0, align 4
%1 = getelementptr %struct.Foo* %foo, i64 0, i32 2
store i8 -1, i8* %1, align 1
%2 = getelementptr %struct.Foo* %foo, i64 0, i32 3
store i8 -1, i8* %2, align 2
call void @baz(%struct.Foo* %foo) nounwind
ret void
}
Currently -std-compile-opts gives:
define void @bar(...) nounwind uwtable {
entry:
%foo = alloca %struct.Foo, align 8
%0 = getelementptr inbounds %struct.Foo* %foo, i64 0, i32 1
store i8 -1, i8* %0, align 4
%1 = bitcast i8* %0 to i16*
%2 = load i16* %1, align 4
%3 = or i16 %2, 448
store i16 %3, i16* %1, align 4
%4 = getelementptr inbounds %struct.Foo* %foo, i64 0, i32 2
%5 = lshr i16 %3, 8
%6 = trunc i16 %5 to i8
%7 = or i8 %6, 126
store i8 %7, i8* %4, align 1
%8 = bitcast i8* %4 to i16*
%9 = load i16* %8, align 1
%10 = or i16 %9, 896
store i16 %10, i16* %8, align 1
%11 = getelementptr inbounds %struct.Foo* %foo, i64 0, i32 3
%12 = lshr i16 %10, 8
%13 = trunc i16 %12 to i8
%14 = or i8 %13, 28
store i8 %14, i8* %11, align 2
call void @baz(%struct.Foo* %foo) nounwind
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