mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 12:50:00 +00:00
Add a microoptimization for urem.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186235 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
12c74dc2c2
commit
75681bb302
@ -1125,6 +1125,13 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) {
|
||||
return BinaryOperator::CreateAnd(Op0, Add);
|
||||
}
|
||||
|
||||
// 1 urem X -> zext(X != 1)
|
||||
if (match(Op0, m_One())) {
|
||||
Value *Cmp = Builder->CreateICmpNE(Op1, Op0);
|
||||
Value *Ext = Builder->CreateZExt(Cmp, I.getType());
|
||||
return ReplaceInstUsesWith(I, Ext);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -163,3 +163,12 @@ define i32 @test16(i32 %x, i32 %y) {
|
||||
%rem = urem i32 %x, %add
|
||||
ret i32 %rem
|
||||
}
|
||||
|
||||
define i32 @test17(i32 %X) {
|
||||
; CHECK: @test17
|
||||
; CHECK-NEXT: icmp ne i32 %X, 1
|
||||
; CHECK-NEXT: zext i1
|
||||
; CHECK-NEXT: ret
|
||||
%A = urem i32 1, %X
|
||||
ret i32 %A
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user