mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 21:32:39 +00:00
Make !if short-circuit when possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73076 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
faf2671776
commit
77c489dcae
@ -965,9 +965,25 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
|
||||
|
||||
Init *TernOpInit::resolveReferences(Record &R, const RecordVal *RV) {
|
||||
Init *lhs = LHS->resolveReferences(R, RV);
|
||||
|
||||
if (Opc == IF && lhs != LHS) {
|
||||
IntInit *Value = dynamic_cast<IntInit*>(lhs);
|
||||
if (Value != 0) {
|
||||
// Short-circuit
|
||||
if (Value->getValue()) {
|
||||
Init *mhs = MHS->resolveReferences(R, RV);
|
||||
return (new TernOpInit(getOpcode(), lhs, mhs, RHS, getType()))->Fold(&R, 0);
|
||||
}
|
||||
else {
|
||||
Init *rhs = RHS->resolveReferences(R, RV);
|
||||
return (new TernOpInit(getOpcode(), lhs, MHS, rhs, getType()))->Fold(&R, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Init *mhs = MHS->resolveReferences(R, RV);
|
||||
Init *rhs = RHS->resolveReferences(R, RV);
|
||||
|
||||
|
||||
if (LHS != lhs || MHS != mhs || RHS != rhs)
|
||||
return (new TernOpInit(getOpcode(), lhs, mhs, rhs, getType()))->Fold(&R, 0);
|
||||
return Fold(&R, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user