Skip to content

Commit

Permalink
fix bug of shl
Browse files Browse the repository at this point in the history
Addresses #642.
  • Loading branch information
PeiMu committed Feb 25, 2023
1 parent 646e829 commit fbf4365
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 33 deletions.
46 changes: 46 additions & 0 deletions analysis/statistics/658fcc1fa3686f0d5fee443c41ef15f6cc736acf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

changeset: 1431:658fcc1fa3686f0d5fee443c41ef15f6cc736acf
char kNewtonVersion[] = "0.3-alpha-1431 (658fcc1fa3686f0d5fee443c41ef15f6cc736acf) (build 02-25-2023-15:[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)




62 changes: 29 additions & 33 deletions src/newton/newton-irPass-LLVMIR-rangeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2079,8 +2079,7 @@ rangeAnalysis(State * N, llvm::Function & llvmIrFunction, BoundInfo * boundInfo,
assert(false);
}
boundInfo->virtualRegisterRange.emplace(llvmIrBinaryOperator,
std::make_pair((int)vrRangeIt->second.first << constValue,
(int)vrRangeIt->second.second << constValue));
std::make_pair(resMin, resMax));
}
else
{
Expand Down Expand Up @@ -2148,7 +2147,6 @@ rangeAnalysis(State * N, llvm::Function & llvmIrFunction, BoundInfo * boundInfo,
static_cast<int64_t>(leftMin) >> static_cast<uint64_t>(rightMax)),
static_cast<int64_t>(leftMax) >> static_cast<uint64_t>(rightMin)),
static_cast<int64_t>(leftMax) >> static_cast<uint64_t>(rightMax));
int a = 0;
}
else
{
Expand Down Expand Up @@ -2320,37 +2318,35 @@ rangeAnalysis(State * N, llvm::Function & llvmIrFunction, BoundInfo * boundInfo,
if (vrRangeIt != boundInfo->virtualRegisterRange.end())
{
double rightMin = 0, rightMax = 0;
rightMin = vrRangeIt->second.first;
rightMax = vrRangeIt->second.second;
// switch (bitWidth)
// {
// case 8:
// rightMin = static_cast<uint8_t>(vrRangeIt->second.first);
// rightMax = static_cast<uint8_t>(vrRangeIt->second.second);
// break;
// case 16:
// rightMin = static_cast<uint16_t>(vrRangeIt->second.first);
// rightMax = static_cast<uint16_t>(vrRangeIt->second.second);
// break;
// case 32:
// rightMin = static_cast<uint32_t>(vrRangeIt->second.first);
// rightMax = static_cast<uint32_t>(vrRangeIt->second.second);
// break;
// case 64:
// rightMin = static_cast<uint64_t>(vrRangeIt->second.first);
// rightMax = static_cast<uint64_t>(vrRangeIt->second.second);
// break;
// default:
// assert(false);
// }
lowerBound = min(min(min((int64_t)leftMin >> (uint64_t)rightMin,
(int64_t)leftMin >> (uint64_t)rightMax),
(int64_t)leftMax >> (uint64_t)rightMin),
(int64_t)leftMax >> (uint64_t)rightMax);
upperBound = max(max(max((int64_t)leftMin >> (uint64_t)rightMin,
(int64_t)leftMin >> (uint64_t)rightMax),
switch (bitWidth)
{
case 8:
rightMin = static_cast<uint8_t>(vrRangeIt->second.first);
rightMax = static_cast<uint8_t>(vrRangeIt->second.second);
break;
case 16:
rightMin = static_cast<uint16_t>(vrRangeIt->second.first);
rightMax = static_cast<uint16_t>(vrRangeIt->second.second);
break;
case 32:
rightMin = static_cast<uint32_t>(vrRangeIt->second.first);
rightMax = static_cast<uint32_t>(vrRangeIt->second.second);
break;
case 64:
rightMin = static_cast<uint64_t>(vrRangeIt->second.first);
rightMax = static_cast<uint64_t>(vrRangeIt->second.second);
break;
default:
assert(false);
}
lowerBound = min(min(min((uint64_t)leftMin >> (uint64_t)rightMin,
(uint64_t)leftMin >> (uint64_t)rightMax),
(uint64_t)leftMax >> (uint64_t)rightMin),
(uint64_t)leftMax >> (uint64_t)rightMax);
upperBound = max(max(max((uint64_t)leftMin >> (uint64_t)rightMin,
(uint64_t)leftMin >> (uint64_t)rightMax),
(int64_t)leftMax >> (uint64_t)rightMin),
(int64_t)leftMax >> (uint64_t)rightMax);
(uint64_t)leftMax >> (uint64_t)rightMax);
}
else
{
Expand Down

0 comments on commit fbf4365

Please sign in to comment.