revert to using the unions. looks nicer and passes the tests.

This commit is contained in:
Axel Kohlmeyer
2022-12-29 19:10:15 -05:00
parent 67156420d4
commit 49eb9ca5fd
2 changed files with 20 additions and 12 deletions

View File

@ -33,7 +33,6 @@
#include "lepton/Operation.h"
#include "lepton/ParsedExpression.h"
#include <algorithm>
#include <cstring>
#include <utility>
using namespace Lepton;
@ -574,6 +573,12 @@ void CompiledVectorExpression::generateTwoArgCall(a64::Compiler& c, arm::Vec& de
}
#else
union int_to_float {
int_to_float(const int &_i) { i = _i; }
int i;
float f;
};
void CompiledVectorExpression::generateJitCode() {
const CpuInfo& cpu = CpuInfo::host();
if (!cpu.hasFeature(CpuFeatures::X86::kAVX))
@ -611,7 +616,7 @@ void CompiledVectorExpression::generateJitCode() {
// Find the constant value (if any) used by this operation.
Operation& op = *operation[step];
double value = 0.0;
double value;
if (op.getId() == Operation::CONSTANT)
value = dynamic_cast<Operation::Constant&> (op).getValue();
else if (op.getId() == Operation::ADD_CONSTANT)
@ -624,10 +629,8 @@ void CompiledVectorExpression::generateJitCode() {
value = 1.0;
else if (op.getId() == Operation::DELTA)
value = 1.0;
else if (op.getId() == Operation::ABS) {
int mask = 0x7FFFFFFF;
memcpy(&value, &mask, sizeof(mask));
}
else if (op.getId() == Operation::ABS)
value = int_to_float(0x7FFFFFFF).f;
else if (op.getId() == Operation::POWER_CONSTANT) {
if (stepGroup[step] == -1)
value = dynamic_cast<Operation::PowerConstant&> (op).getValue();