Skip to content

Commit

Permalink
rdar://12329730 (2nd part, revised)
Browse files Browse the repository at this point in the history
The type of shirt-right (logical or arithemetic) should remain unchanged 
when transforming  "X << C1 >> C2" into "X << (C1-C2)"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169209 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Shuxin Yang committed Dec 4, 2012
1 parent b715b20 commit bba3eb0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,8 @@ Value *InstCombiner::SimplifyShrShlDemandedBits(Instruction *Shr,
New->setHasNoUnsignedWrap(Orig->hasNoUnsignedWrap());
} else {
Constant *Amt = ConstantInt::get(VarX->getType(), ShrAmt - ShlAmt);
New = BinaryOperator::CreateLShr(VarX, Amt);
New = isLshr ? BinaryOperator::CreateLShr(VarX, Amt) :
BinaryOperator::CreateAShr(VarX, Amt);
}

return InsertNewInstWith(New, *Shl);
Expand Down
2 changes: 1 addition & 1 deletion test/Transforms/InstCombine/shift.ll
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ define i32 @test60(i32 %x) {
%or = or i32 %shl, 1
ret i32 %or
; CHECK: @test60
; CHECK: lshr i32 %x, 3
; CHECK: ashr i32 %x, 3
}


Expand Down

0 comments on commit bba3eb0

Please sign in to comment.