Skip to content

Commit 6aac702

Browse files
authored
more cases of 80 floats that should be 64 (#21888)
1 parent c203d97 commit 6aac702

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

compiler/src/dmd/glue/e2ir.d

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4627,7 +4627,7 @@ elem* toElemCast(CastExp ce, elem* e, bool isLvalue, ref IRState irs)
46274627
* information available to do it.
46284628
*
46294629
* Casting from a C++ interface to a non-C++ interface
4630-
* always results in null because there's no way one
4630+
* always results in null because there is no way one
46314631
* can be derived from the other.
46324632
*/
46334633
e = el_bin(OPcomma, TYnptr, e, el_long(TYnptr, 0));
@@ -4660,6 +4660,9 @@ elem* toElemCast(CastExp ce, elem* e, bool isLvalue, ref IRState irs)
46604660
if (ftym == ttym)
46614661
return Lret(ce, e);
46624662

4663+
// OSX AArch64 long doubles are 64 bits
4664+
bool RealIsDouble = target.os == Target.os.OSX && target.isAArch64;
4665+
46634666
/* Reduce combinatorial explosion by rewriting the 'to' and 'from' types to a
46644667
* generic equivalent (as far as casting goes)
46654668
*/
@@ -4676,6 +4679,10 @@ elem* toElemCast(CastExp ce, elem* e, bool isLvalue, ref IRState irs)
46764679
case Tdchar: tty = Tuns32; break;
46774680
case Tvoid: return Lpaint(ce, e, ttym);
46784681

4682+
case Tfloat80: if (RealIsDouble) tty = Tfloat64; break;
4683+
case Timaginary80: if (RealIsDouble) tty = Timaginary64; break;
4684+
case Tcomplex80: if (RealIsDouble) tty = Tcomplex64; break;
4685+
46794686
case Tbool:
46804687
{
46814688
// Construct e?true:false
@@ -4703,6 +4710,10 @@ elem* toElemCast(CastExp ce, elem* e, bool isLvalue, ref IRState irs)
47034710
case Tnoreturn:
47044711
return Lret(ce, e);
47054712

4713+
case Tfloat80: if (RealIsDouble) fty = Tfloat64; break;
4714+
case Timaginary80: if (RealIsDouble) fty = Timaginary64; break;
4715+
case Tcomplex80: if (RealIsDouble) fty = Tcomplex64; break;
4716+
47064717
default:
47074718
break;
47084719
}

compiler/src/dmd/glue/package.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Symbol* getBzeroSymbol()
239239
tym_t totym(Type tx)
240240
{
241241
// OSX AArch64 long doubles are 64 bits
242-
bool OSXAArch64 = target.os == Target.os.OSX && target.isAArch64;
242+
bool RealIsDouble = target.os == Target.os.OSX && target.isAArch64;
243243

244244
tym_t t;
245245
switch (tx.ty)
@@ -255,13 +255,13 @@ tym_t totym(Type tx)
255255
case Tuns64: t = TYullong; break;
256256
case Tfloat32: t = TYfloat; break;
257257
case Tfloat64: t = TYdouble; break;
258-
case Tfloat80: t = OSXAArch64 ? TYdouble : TYldouble; break;
258+
case Tfloat80: t = RealIsDouble ? TYdouble : TYldouble; break;
259259
case Timaginary32: t = TYifloat; break;
260260
case Timaginary64: t = TYidouble; break;
261-
case Timaginary80: t = OSXAArch64 ? TYidouble : TYildouble; break;
261+
case Timaginary80: t = RealIsDouble ? TYidouble : TYildouble; break;
262262
case Tcomplex32: t = TYcfloat; break;
263263
case Tcomplex64: t = TYcdouble; break;
264-
case Tcomplex80: t = OSXAArch64 ? TYcdouble : TYcldouble; break;
264+
case Tcomplex80: t = RealIsDouble ? TYcdouble : TYcldouble; break;
265265
case Tbool: t = TYbool; break;
266266
case Tchar: t = TYchar; break;
267267
case Twchar: t = TYwchar_t; break;

0 commit comments

Comments
 (0)