forked from OSchip/llvm-project
[Thumb1] AND with a constant operand can be converted into BIC
So model the cost of materializing the constant operand C as the minimum of C and ~C. llvm-svn: 280929
This commit is contained in:
parent
7c7255e40b
commit
753c18f5c0
|
@ -69,6 +69,10 @@ int ARMTTIImpl::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
|
|||
Idx == 1)
|
||||
return 0;
|
||||
|
||||
if (Opcode == Instruction::And)
|
||||
// Conversion to BIC is free, and means we can use ~Imm instead.
|
||||
return std::min(getIntImmCost(Imm, Ty), getIntImmCost(~Imm, Ty));
|
||||
|
||||
return getIntImmCost(Imm, Ty);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,3 +19,21 @@ true:
|
|||
ret:
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: Function: h
|
||||
; CHECK-NOT: Collect constant i32 -193 from
|
||||
define void @h(i1 %cond, i32 %p, i32 %q) {
|
||||
entry:
|
||||
%a = and i32 %p, 4294967103
|
||||
call void @g(i32 %a)
|
||||
br i1 %cond, label %true, label %ret
|
||||
|
||||
true:
|
||||
%b = and i32 %q, 4294967103
|
||||
call void @g(i32 %b)
|
||||
br label %ret
|
||||
|
||||
ret:
|
||||
ret void
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue