Skip to content

Commit d21070e

Browse files
committed
code simplifications [NFC]
1 parent efbe689 commit d21070e

File tree

1 file changed

+12
-31
lines changed

1 file changed

+12
-31
lines changed

ir/instr.cpp

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,10 @@ StateValue FpBinOp::toSMT(State &s) const {
817817
break;
818818
}
819819

820-
auto scalar = [&](auto &a, auto &ap, auto &b, auto &bp) {
821-
return round_value([&](auto rm) { return fn(a, ap, b, bp, rm); }, s, rm);
820+
auto scalar = [&](const auto &a, const auto &b) {
821+
return round_value([&](auto rm) {
822+
return fn(a.value, a.non_poison, b.value, b.non_poison, rm);
823+
}, s, rm);
822824
};
823825

824826
auto &a = s[*lhs];
@@ -828,14 +830,11 @@ StateValue FpBinOp::toSMT(State &s) const {
828830
auto retty = getType().getAsAggregateType();
829831
vector<StateValue> vals;
830832
for (unsigned i = 0, e = retty->numElementsConst(); i != e; ++i) {
831-
auto ai = retty->extract(a, i);
832-
auto bi = retty->extract(b, i);
833-
vals.emplace_back(
834-
scalar(ai.value, ai.non_poison, bi.value, bi.non_poison));
833+
vals.emplace_back(scalar(retty->extract(a, i), retty->extract(b, i)));
835834
}
836835
return retty->aggregateVals(vals);
837836
}
838-
return scalar(a.value, a.non_poison, b.value, b.non_poison);
837+
return scalar(a, b);
839838
}
840839

841840
expr FpBinOp::getTypeConstraints(const Function &f) const {
@@ -1142,24 +1141,10 @@ StateValue UnaryReductionOp::toSMT(State &s) const {
11421141
}
11431142

11441143
expr UnaryReductionOp::getTypeConstraints(const Function &f) const {
1145-
expr instrconstr = getType() == val->getType();
1146-
switch(op) {
1147-
case Add:
1148-
case Mul:
1149-
case And:
1150-
case Or:
1151-
case Xor:
1152-
case SMax:
1153-
case SMin:
1154-
case UMax:
1155-
case UMin:
1156-
instrconstr = getType().enforceIntType();
1157-
instrconstr &= val->getType().enforceVectorType(
1158-
[this](auto &scalar) { return scalar == getType(); });
1159-
break;
1160-
}
1161-
1162-
return Value::getTypeConstraints() && move(instrconstr);
1144+
return Value::getTypeConstraints() &&
1145+
getType().enforceIntType() &&
1146+
val->getType().enforceVectorType(
1147+
[this](auto &scalar) { return scalar == getType(); });
11631148
}
11641149

11651150
unique_ptr<Instr> UnaryReductionOp::dup(const string &suffix) const {
@@ -1199,14 +1184,10 @@ StateValue TernaryOp::toSMT(State &s) const {
11991184

12001185
switch (op) {
12011186
case FShl:
1202-
fn = [](auto &a, auto &b, auto &c) -> expr {
1203-
return expr::fshl(a, b, c);
1204-
};
1187+
fn = expr::fshl;
12051188
break;
12061189
case FShr:
1207-
fn = [](auto &a, auto &b, auto &c) -> expr {
1208-
return expr::fshr(a, b, c);
1209-
};
1190+
fn = expr::fshr;
12101191
break;
12111192
}
12121193

0 commit comments

Comments
 (0)