Skip to content

Commit 28707a0

Browse files
committed
a
1 parent 8d5d949 commit 28707a0

1 file changed

Lines changed: 6 additions & 45 deletions

File tree

src/jit.cpp

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6125,53 +6125,14 @@ ModuleBuild createScriptModule(const llvm::DataLayout &dataLayout, const SCompil
61256125
resultName);
61266126
return result;
61276127
}
6128-
case 7: {
6129-
llvm::Value *angle = activeBuilder.CreateFRem(
6130-
value,
6131-
llvm::ConstantFP::get(f64, 360.0),
6132-
"mathop_tan_angle");
6133-
llvm::Value *radians = activeBuilder.CreateFMul(
6134-
angle,
6135-
llvm::ConstantFP::get(f64, 3.14159265358979323846 / 180.0),
6136-
"mathop_tan_radians");
6137-
llvm::Value *tangent = activeBuilder.CreateUnaryIntrinsic(llvm::Intrinsic::tan, radians);
6138-
llvm::Value *scaled = activeBuilder.CreateFMul(
6139-
tangent,
6140-
llvm::ConstantFP::get(f64, 10000000000.0),
6141-
"mathop_tan_round_scaled");
6142-
llvm::Value *rounded = activeBuilder.CreateUnaryIntrinsic(llvm::Intrinsic::round, scaled);
6143-
llvm::Value *finiteResult = activeBuilder.CreateFDiv(
6144-
rounded,
6145-
llvm::ConstantFP::get(f64, 10000000000.0),
6146-
"mathop_tan_rounded");
6147-
llvm::Value *positiveInfinity = activeBuilder.CreateOr(
6148-
activeBuilder.CreateFCmpOEQ(angle, llvm::ConstantFP::get(f64, 90.0)),
6149-
activeBuilder.CreateFCmpOEQ(angle, llvm::ConstantFP::get(f64, -270.0)));
6150-
llvm::Value *negativeInfinity = activeBuilder.CreateOr(
6151-
activeBuilder.CreateFCmpOEQ(angle, llvm::ConstantFP::get(f64, -90.0)),
6152-
activeBuilder.CreateFCmpOEQ(angle, llvm::ConstantFP::get(f64, 270.0)));
6153-
llvm::Value *withPositiveInfinity = activeBuilder.CreateSelect(
6154-
positiveInfinity,
6155-
llvm::ConstantFP::getInfinity(f64),
6156-
finiteResult);
6157-
return activeBuilder.CreateSelect(
6158-
negativeInfinity,
6159-
llvm::ConstantFP::getInfinity(f64, true),
6160-
withPositiveInfinity,
6161-
resultName);
6162-
}
6128+
case 7:
61636129
case 8:
61646130
case 9:
6165-
case 10: {
6166-
const llvm::Intrinsic::ID inverseIntrinsic = operatorId == 8 ?
6167-
llvm::Intrinsic::asin :
6168-
(operatorId == 9 ? llvm::Intrinsic::acos : llvm::Intrinsic::atan);
6169-
llvm::Value *radians = activeBuilder.CreateUnaryIntrinsic(inverseIntrinsic, value);
6170-
return activeBuilder.CreateFMul(
6171-
radians,
6172-
llvm::ConstantFP::get(f64, 180.0 / 3.14159265358979323846),
6173-
resultName);
6174-
}
6131+
case 10:
6132+
// LLVM exposes sin/cos intrinsics, but not tan or inverse trig
6133+
// intrinsics. Return nullptr so the caller uses the runtime
6134+
// implementation, which also preserves Scratch's edge cases.
6135+
return nullptr;
61756136
case 11:
61766137
intrinsic = llvm::Intrinsic::log;
61776138
break;

0 commit comments

Comments
 (0)