Skip to content

Commit 6974dbb

Browse files
authored
Do not attempt to optimize v128s yet (#1834)
Until the `Abstract` interface gains a notion of SIMD lanes, these optimizations will crash on v128 types.
1 parent dfdae1a commit 6974dbb

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/passes/OptimizeInstructions.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,17 +1148,20 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions,
11481148
}
11491149
}
11501150
}
1151-
// note that this is correct even on floats with a NaN on the left,
1152-
// as a NaN would skip the computation and just return the NaN,
1153-
// and that is precisely what we do here. but, the same with -1
1154-
// (change to a negation) would be incorrect for that reason.
1155-
if (right->value == Literal::makeFromInt32(1, type)) {
1156-
if (binary->op == Abstract::getBinary(type, Abstract::Mul) ||
1157-
binary->op == Abstract::getBinary(type, Abstract::DivS) ||
1158-
binary->op == Abstract::getBinary(type, Abstract::DivU)) {
1159-
return binary->left;
1151+
if (isIntegerType(type) || isFloatType(type)) {
1152+
// note that this is correct even on floats with a NaN on the left,
1153+
// as a NaN would skip the computation and just return the NaN,
1154+
// and that is precisely what we do here. but, the same with -1
1155+
// (change to a negation) would be incorrect for that reason.
1156+
if (right->value == Literal::makeFromInt32(1, type)) {
1157+
if (binary->op == Abstract::getBinary(type, Abstract::Mul) ||
1158+
binary->op == Abstract::getBinary(type, Abstract::DivS) ||
1159+
binary->op == Abstract::getBinary(type, Abstract::DivU)) {
1160+
return binary->left;
1161+
}
11601162
}
11611163
}
1164+
// TODO: v128 not implemented yet
11621165
return nullptr;
11631166
}
11641167

@@ -1191,9 +1194,9 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions,
11911194
// x + 5 == 7
11921195
// =>
11931196
// x == 2
1194-
if (binary->op == Abstract::getBinary(type, Abstract::Eq) ||
1195-
binary->op == Abstract::getBinary(type, Abstract::Ne)) {
1196-
if (isIntegerType(binary->left->type)) {
1197+
if (isIntegerType(binary->left->type)) {
1198+
if (binary->op == Abstract::getBinary(type, Abstract::Eq) ||
1199+
binary->op == Abstract::getBinary(type, Abstract::Ne)) {
11971200
if (auto* left = binary->left->dynCast<Binary>()) {
11981201
if (left->op == Abstract::getBinary(type, Abstract::Add) ||
11991202
left->op == Abstract::getBinary(type, Abstract::Sub)) {

0 commit comments

Comments
 (0)