mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
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.
This commit is contained in:
parent
dcecb46321
commit
3d6c65e75d
1 changed files with 5 additions and 1 deletions
|
@ -13114,9 +13114,13 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
||||||
result = exp.incompatibleTypes();
|
result = exp.incompatibleTypes();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
exp.e1 = integralPromotions(exp.e1, sc);
|
exp.e1 = integralPromotions(exp.e1, sc);
|
||||||
if (exp.e2.type.toBasetype().ty != Tvector)
|
if (exp.e2.type.toBasetype().ty != Tvector)
|
||||||
exp.e2 = exp.e2.castTo(sc, Type.tshiftcnt);
|
{
|
||||||
|
Type tb1 = exp.e1.type.toBasetype();
|
||||||
|
exp.e2 = exp.e2.castTo(sc, tb1.ty == Tvector ? tb1 : Type.tshiftcnt);
|
||||||
|
}
|
||||||
|
|
||||||
exp.type = exp.e1.type;
|
exp.type = exp.e1.type;
|
||||||
result = exp;
|
result = exp;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue