mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Added instcombine for 'MIN(MIN(A, 27), 93)' and 'MAX(MAX(A, 93), 27)'
MIN(MIN(A, 23), 97) -> MIN(A, 23) MAX(MAX(A, 97), 23) -> MAX(A, 97) Differential Revision: http://reviews.llvm.org/D3629 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -683,11 +683,27 @@ Instruction *InstCombiner::FoldSPFofSPF(Instruction *Inner,
|
||||
return ReplaceInstUsesWith(Outer, C);
|
||||
}
|
||||
|
||||
// TODO: MIN(MIN(A, 23), 97)
|
||||
// MIN(MIN(A, 23), 97) -> MIN(A, 23)
|
||||
// MAX(MAX(A, 97), 23) -> MAX(A, 97)
|
||||
if (SPF1 == SPF2) {
|
||||
if (ConstantInt *CB = dyn_cast<ConstantInt>(B)) {
|
||||
if (ConstantInt *CC = dyn_cast<ConstantInt>(C)) {
|
||||
APInt ACB = CB->getValue();
|
||||
APInt ACC = CC->getValue();
|
||||
if ((SPF1 == SPF_UMIN && ACB.ule(ACC)) ||
|
||||
(SPF1 == SPF_SMIN && ACB.sle(ACC)) ||
|
||||
(SPF1 == SPF_UMAX && ACB.uge(ACC)) ||
|
||||
(SPF1 == SPF_SMAX && ACB.sge(ACC)))
|
||||
return ReplaceInstUsesWith(Outer, Inner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: MIN(MIN(A, 97), 23) -> MIN(A, 23)
|
||||
// TODO: MAX(MAX(A, 23), 97) -> MAX(A, 97)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
/// foldSelectICmpAnd - If one of the constants is zero (we know they can't
|
||||
/// both be) and we have an icmp instruction with zero, and we have an 'and'
|
||||
/// with the non-constant value and a power of two we can turn the select
|
||||
|
Reference in New Issue
Block a user