forked from OSchip/llvm-project
PR10267: Don't combine an equality compare with an AND into an inequality compare when the AND has more than one use.
This can pessimize code, inequalities are generally more expensive. llvm-svn: 134379
This commit is contained in:
parent
1052fd76ab
commit
9eca5feff1
|
@ -1455,6 +1455,10 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
ICmpInst::ICMP_NE, LHSI,
|
||||
Constant::getNullValue(RHS->getType()));
|
||||
|
||||
// Don't perform the following transforms if the AND has multiple uses
|
||||
if (!BO->hasOneUse())
|
||||
break;
|
||||
|
||||
// Replace (and X, (1 << size(X)-1) != 0) with x s< 0
|
||||
if (BOC->getValue().isSignBit()) {
|
||||
Value *X = BO->getOperand(0);
|
||||
|
|
|
@ -547,3 +547,15 @@ define i1 @test56(i32 %a) {
|
|||
%cmp = icmp eq i32 %sub, 123
|
||||
ret i1 %cmp
|
||||
}
|
||||
|
||||
; PR10267 Don't make icmps more expensive when no other inst is subsumed.
|
||||
declare void @foo(i32)
|
||||
; CHECK: @test57
|
||||
; CHECK: %and = and i32 %a, -2
|
||||
; CHECK: %cmp = icmp ne i32 %and, 0
|
||||
define i1 @test57(i32 %a) {
|
||||
%and = and i32 %a, -2
|
||||
%cmp = icmp ne i32 %and, 0
|
||||
call void @foo(i32 %and)
|
||||
ret i1 %cmp
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue