Skip to content

Commit

Permalink
the range should be (-Inf, Inf) if we cannot infer its range. (PS: or…
Browse files Browse the repository at this point in the history
… maybe the range of that C-type?)

Addresses #628.
  • Loading branch information
PeiMu committed Dec 20, 2022
1 parent 8233e1e commit 4734b12
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
46 changes: 46 additions & 0 deletions analysis/statistics/76d3967245344914e39b3eb79a3a89fedf82dec0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

changeset: 1363:76d3967245344914e39b3eb79a3a89fedf82dec0
char kNewtonVersion[] = "0.3-alpha-1363 (76d3967245344914e39b3eb79a3a89fedf82dec0) (build 12-20-2022-13:[email protected]_64)";
\n./src/noisy/noisy-linux-EN -O0 applications/noisy/helloWorld.n -s
\n./src/newton/newton-linux-EN -v 0 -eP applications/newton/invariants/ViolinWithTemperatureDependence-pigroups.nt

Informational Report:
---------------------
Invariant "ViolinWithTemperatureDependenceForPiGroups" has 2 unique kernels, each with 2 column(s)...

Kernel 0 is a valid kernel:

1 1
-0.5 -0
1 0
0.5 0
0 -1
-0 -1


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 0, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^( 0) P5^(-0)

Pi group 0, Pi 1 is: P0^(-0) P1^( 1) P2^( 0) P3^( 0) P4^(-1) P5^(-1)


Kernel 1 is a valid kernel:

1 0
-0.5 1
1 -2
0.5 -1
-0 -2
0 -2


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 1, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^(-0) P5^( 0)

Pi group 1, Pi 1 is: P0^( 1) P1^( 0) P2^(-1) P3^(-2) P4^(-2) P5^(-2)




2 changes: 1 addition & 1 deletion applications/newton/llvm-ir/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif

all: default

default: application.ll simple_control_flow.ll inferBound.ll inferBoundControlFlow.ll e_exp.ll sincosf.ll e_log.ll e_acosh.ll e_j0.ll e_y0.ll e_rem_pio2.ll benchmark_suite.ll phi_two_global_arrays.ll
default: application.ll simple_control_flow.ll inferBound.ll inferBoundControlFlow.ll e_exp.ll sincosf.ll e_log.ll e_acosh.ll e_j0.ll e_y0.ll e_rem_pio2.ll benchmark_suite.ll phi_two_global_arrays.ll vec_add.ll vec_add_8.ll

%.ll : %.c
@echo Compiling $*.c
Expand Down
13 changes: 9 additions & 4 deletions src/newton/newton-irPass-LLVMIR-rangeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ getGEPArrayRange(State * N, GetElementPtrInst * llvmIrGetElePtrInstruction,
{
// todo: get range other type of array
assert(!valueRangeDebug && "implement when meet");
return std::make_pair(0, 0);
return std::make_pair(-INFINITY, INFINITY);
}
}
else
{
// todo: get range from variable array
assert(!valueRangeDebug && "implement when meet");
return std::make_pair(0, 0);
return std::make_pair(-INFINITY, INFINITY);
}
}

Expand Down Expand Up @@ -1082,6 +1082,9 @@ rangeAnalysis(State * N, BoundInfo * boundInfo, Function & llvmIrFunction, bool
break;
}
}
if (argRanges.empty()) {
break;
}
double lowRange, highRange;
// todo: reconstruct by MACRO or template
if (funcName == "log")
Expand Down Expand Up @@ -2583,8 +2586,10 @@ rangeAnalysis(State * N, BoundInfo * boundInfo, Function & llvmIrFunction, bool
{
auto resVec = getGEPArrayRange(N, llvmIrGetElePtrInstruction,
boundInfo->virtualRegisterRange);
boundInfo->virtualRegisterRange.emplace(llvmIrGetElePtrInstruction,
std::make_pair(resVec.first, resVec.second));
if (!isinf(resVec.first) || !isinf(resVec.second)) {
boundInfo->virtualRegisterRange.emplace(llvmIrGetElePtrInstruction,
std::make_pair(resVec.first, resVec.second));
}
}
else if (llvmIrGetElePtrInstruction->getPointerOperandType()
->getPointerElementType()
Expand Down
1 change: 1 addition & 0 deletions src/newton/newton-irPass-LLVMIR-rangeAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <cmath>
#include <float.h>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
Expand Down
1 change: 1 addition & 0 deletions src/newton/newton-irPass-LLVMIR-shrinkTypeByRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ getTypeInfo(State * N, Value * inValue,
switch (inInstType->getTypeID())
{
case Type::IntegerTyID:
typeInformation = getShrinkIntType(N, inValue, vrRangeIt->second);
break;
case Type::FloatTyID:
break;
Expand Down

0 comments on commit 4734b12

Please sign in to comment.