Skip to content

Commit 3d6c65e

Browse files
kinkedlang-bot
authored andcommitted
Bit-shift expressions: Cast scalar right-hand-sides to vectors if needed
This promotion from scalar right-hand-sides to vectors already happens for the arithmetic binops, via `typeCombine()` side effects. Handle bit-shift expressions too now, by casting a scalar to the left-hand-side vector type. This can't be tested with DMD, as DMD's `Target.isVectorOpSupported()` doesn't support bit-shifts yet. It is ~required/useful for LDC though.
1 parent dcecb46 commit 3d6c65e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/dmd/expressionsem.d

+5-1
Original file line numberDiff line numberDiff line change
@@ -13114,9 +13114,13 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
1311413114
result = exp.incompatibleTypes();
1311513115
return;
1311613116
}
13117+
1311713118
exp.e1 = integralPromotions(exp.e1, sc);
1311813119
if (exp.e2.type.toBasetype().ty != Tvector)
13119-
exp.e2 = exp.e2.castTo(sc, Type.tshiftcnt);
13120+
{
13121+
Type tb1 = exp.e1.type.toBasetype();
13122+
exp.e2 = exp.e2.castTo(sc, tb1.ty == Tvector ? tb1 : Type.tshiftcnt);
13123+
}
1312013124

1312113125
exp.type = exp.e1.type;
1312213126
result = exp;

0 commit comments

Comments
 (0)