1
0
mirror of https://github.com/c64scene-ar/llvm-6502.git synced 2024-12-14 11:32:34 +00:00

fix PR5978 by peeling the loop so that we avoid shifting the

result int by 8 for the first byte.  While normally harmless,
if the result is smaller than a byte, this shift is invalid.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93018 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-08 19:02:23 +00:00
parent 54a57045eb
commit b31189f262
2 changed files with 12 additions and 2 deletions
lib/Analysis
test/Transforms/ConstProp

View File

@ -398,8 +398,8 @@ static Constant *FoldReinterpretLoadFromConstPtr(Constant *C,
BytesLoaded, TD))
return 0;
APInt ResultVal(IntType->getBitWidth(), 0);
for (unsigned i = 0; i != BytesLoaded; ++i) {
APInt ResultVal = APInt(IntType->getBitWidth(), RawBytes[BytesLoaded-1]);
for (unsigned i = 1; i != BytesLoaded; ++i) {
ResultVal <<= 8;
ResultVal |= APInt(IntType->getBitWidth(), RawBytes[BytesLoaded-1-i]);
}

View File

@ -110,3 +110,13 @@ define i16 @test12() {
; CHECK: @test12
; CHECK: ret i16 98
}
; PR5978
@g5 = constant i8 4
define i1 @test13() {
%A = load i1* bitcast (i8* @g5 to i1*)
ret i1 %A
; CHECK: @test13
; CHECK: ret i1 false
}