1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

Move ashr optimization from InstCombineShift to InstSimplify.

Refactor code, no functionality change, test case moved from instcombine to instsimplify.

Differential Revision: http://reviews.llvm.org/D4102
 

llvm-svn: 213231
This commit is contained in:
Suyog Sarda 2014-07-17 06:28:15 +00:00
parent 45d9529fe9
commit e62b39fcd0
4 changed files with 15 additions and 13 deletions

View File

@ -1346,6 +1346,11 @@ static Value *SimplifyAShrInst(Value *Op0, Value *Op1, bool isExact,
cast<OverflowingBinaryOperator>(Op0)->hasNoSignedWrap())
return X;
// Arithmetic shifting an all-sign-bit value is a no-op.
unsigned NumSignBits = ComputeNumSignBits(Op0);
if (NumSignBits == Op0->getType()->getScalarSizeInBits())
return Op0;
return nullptr;
}

View File

@ -815,10 +815,5 @@ Instruction *InstCombiner::visitAShr(BinaryOperator &I) {
APInt::getSignBit(I.getType()->getScalarSizeInBits())))
return BinaryOperator::CreateLShr(Op0, Op1);
// Arithmetic shifting an all-sign-bit value is a no-op.
unsigned NumSignBits = ComputeNumSignBits(Op0);
if (NumSignBits == Op0->getType()->getScalarSizeInBits())
return ReplaceInstUsesWith(I, Op0);
return nullptr;
}

View File

@ -1,8 +0,0 @@
; RUN: opt < %s -instcombine -S | not grep ashr
define i32 @foo(i32 %x) {
%o = and i32 %x, 1
%n = add i32 %o, -1
%t = ashr i32 %n, 17
ret i32 %t
}

View File

@ -0,0 +1,10 @@
; RUN: opt < %s -instsimplify -S | FileCheck %s
; CHECK-LABEL: @foo
; CHECK-NOT: ashr
define i32 @foo(i32 %x) {
%o = and i32 %x, 1
%n = add i32 %o, -1
%t = ashr i32 %n, 17
ret i32 %t
}