first commit

This commit is contained in:
Nils Hölscher 2022-04-19 10:56:42 +02:00
commit 69d9b56047
81 changed files with 32401 additions and 0 deletions

View File

@ -0,0 +1,320 @@
//=============================================================================
// FILE:
// CacheAnalysisPass.cpp
//
// DESCRIPTION:
// Visits all functions in a module, prints their names and the number of
// arguments via stderr. Strictly speaking, this is an analysis pass (i.e.
// the functions are not modified). However, in order to keep things simple
// there's no 'print' method here (every analysis pass should implement it).
//
// USAGE:
// New PM:
// opt -load-pass-plugin=libCacheAnalysisPass.dylib -passes=lru-misses `\`
// -disable-output <input-llvm-file>
//
//
// License: MIT
//=============================================================================
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Value.h"
#include "llvm/Pass.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include <cstddef>
#include <cstdlib>
#include <llvm/Support/raw_ostream.h>
#include <utility>
#include "../include/AbstractCache.h"
#include "../include/CacheType.h"
using namespace llvm;
//-----------------------------------------------------------------------------
// CacheAnalysisPass implementation
//-----------------------------------------------------------------------------
// No need to expose the internals of the pass to the outside world - keep
// everything in an anonymous namespace.
namespace {
std::string typeToName(Type::TypeID Id) {
switch (Id) {
case Type::TypeID::ArrayTyID:
return "ArrayTy";
case Type::TypeID::BFloatTyID:
return "BFloatTy";
case Type::TypeID::FloatTyID:
return "FloatTy";
case Type::TypeID::DoubleTyID:
return "DoubleTy";
case Type::TypeID::FixedVectorTyID:
return "FixedVectorTy";
case Type::TypeID::FP128TyID:
return "FP128Ty";
case Type::TypeID::FunctionTyID:
return "FunctionTy";
case Type::TypeID::HalfTyID:
return "HalfTy";
case Type::TypeID::IntegerTyID:
return "IntegerTy";
case Type::TypeID::LabelTyID:
return "LabelTy";
case Type::TypeID::MetadataTyID:
return "MetadataTy";
case Type::TypeID::PointerTyID:
return "PointerTy";
case Type::TypeID::PPC_FP128TyID:
return "PPC_FP128Ty";
case Type::TypeID::ScalableVectorTyID:
return "ScalableVectorTy";
case Type::TypeID::StructTyID:
return "StructTy";
case Type::TypeID::TokenTyID:
return "TokenTy";
case Type::TypeID::VoidTyID:
return "VoidTy";
case Type::TypeID::X86_AMXTyID:
return "X86_AMXTy";
case Type::TypeID::X86_FP80TyID:
return "X86_FP80Ty";
case Type::TypeID::X86_MMXTyID:
return "X86_MMXTy";
}
// should not reach here
return nullptr;
}
// New PM implementation
// TODO: assign Misses to CacheState
// TODO: Find longest Path, LPsolve?
// TODO: Sum up Cache misses over longest path.
struct CacheAnalysisPass : PassInfoMixin<CacheAnalysisPass> {
// Development Options
bool PrintAddresses = false;
bool PrintEdges = false;
bool PrintEdgesPost = false;
bool DumpToDot = false;
bool DumpNodes = false;
// Assume a 4kB Cache
// with 16 Sets, associativity of 4 and Cachelines fitting two
CacheType Cache = CacheType(16, 4, 128);
StringRef EntryPoint = "main";
unsigned int EntryAddress;
unsigned int AddressCounter = 0b100000;
// assume 8 Bit addressed 64 Bit instructions.
std::map<unsigned int, Value *> Addr2Value;
std::map<Value *, unsigned int> Value2Addr;
AbstractCache AC;
// TODO mark visit ed F's BB's and Inst's
std::map<Function *, bool> VisitedFunctions;
unsigned int stringRefToInt(StringRef SR) {
unsigned int Length = SR.size();
unsigned int ret = 0;
unsigned int Count = 1;
for (char C : SR) {
unsigned int Factor = (unsigned int)pow(10, (Length - Count++));
switch (C) {
case '0':
break;
case '1':
ret += Factor;
break;
case '2':
ret += 2 * Factor;
break;
case '3':
ret += 3 * Factor;
break;
case '4':
ret += 4 * Factor;
break;
case '5':
ret += 5 * Factor;
break;
case '6':
ret += 6 * Factor;
break;
case '7':
ret += 7 * Factor;
break;
case '8':
ret += 8 * Factor;
break;
case '9':
ret += 9 * Factor;
break;
default:
errs() << "StringRef is not a decimal number";
};
}
return ret;
}
void address_collector(Module &M) {
for (Function &F : M) {
if (F.getName().equals(EntryPoint)) {
EntryAddress = AddressCounter;
if (PrintAddresses)
outs() << "Found main at PseudoAddress: " << EntryAddress << " \n";
}
unsigned int InstCounter = 0;
for (BasicBlock &BB : F) {
for (Instruction &Inst : BB) {
AC.addEmptyNode(AddressCounter);
Addr2Value[AddressCounter] = &Inst;
Value2Addr[&Inst] = AddressCounter;
AddressCounter += 1;
InstCounter++;
}
}
}
}
void address_printer(Function &F) {
outs() << "F: " << Value2Addr[&F] << ".\n";
for (BasicBlock &BB : F) {
outs() << "-BB: " << Value2Addr[&BB] << "\n";
for (Instruction &Inst : BB) {
outs() << "--InstAddress:" << Value2Addr[&Inst] << "\n";
}
}
}
void init_edges(Function &F) {
for (BasicBlock &BB : F) {
// Collect Controll flow in F
for (auto Pred : predecessors(&BB)) {
AC.addEdge(Value2Addr[&Pred->getInstList().back()],
Value2Addr[&BB.getInstList().front()]);
if (PrintEdges)
outs() << Value2Addr[&Pred->getInstList().back()] << " -> "
<< Value2Addr[&BB.getInstList().front()] << "\n";
}
Instruction *PrevInst = nullptr;
for (Instruction &Inst : BB) {
// Collect function Calls in F=main
if (CallInst *Caller = dyn_cast<CallInst>(&Inst)) {
Function *Callee = Caller->getCalledFunction();
if (PrintEdges)
outs() << "F: " << Callee->getName() << "\n"
<< "Inst: " << Caller->getName() << "\n";
if (Callee != NULL) {
// Add edge on Function Call
AC.addEdge(Value2Addr[&Inst],
Value2Addr[&Callee->getBasicBlockList()
.front()
.getInstList()
.front()]);
// Add edge on Function return
AC.addEdge(
Value2Addr
[&Callee->getBasicBlockList().back().getInstList().back()],
Value2Addr[&Inst]);
if (PrintEdges) {
// Printing edge on Function Call
outs() << Callee->getName() << ": ";
outs() << Value2Addr[&Inst] << " -> "
<< Value2Addr[&Callee->getBasicBlockList()
.front()
.getInstList()
.front()]
<< "\n";
// Printing edge on Function return
outs() << Callee->getName() << ": ";
outs() << Value2Addr[&Callee->getBasicBlockList()
.back()
.getInstList()
.back()]
<< " -> " << Value2Addr[&Inst] << "\n";
}
// Resume CFG construction in called function
if (VisitedFunctions.find(Callee) == VisitedFunctions.end()) {
VisitedFunctions[Callee] = true;
init_edges(*Callee);
}
PrevInst = nullptr;
if (PrintEdges)
outs() << "Back from " << Callee->getName() << "\n";
}
}
if (PrevInst != nullptr) {
AC.addEdge(Value2Addr[PrevInst], Value2Addr[&Inst]);
if (PrintEdges)
outs() << Value2Addr[PrevInst] << " -> " << Value2Addr[&Inst]
<< "\n";
}
PrevInst = &Inst;
}
}
}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM) {
FunctionAnalysisManager &FAM =
MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
address_collector(M);
Function *EntryFunction;
for (Function &F : M.getFunctionList()) {
// Start iterating through CFG from entry point
if (F.getName().equals(EntryPoint)) {
EntryFunction = &F;
init_edges(F);
}
if (PrintAddresses)
address_printer(F);
}
if (PrintEdgesPost)
AC.dumpEdges();
if (DumpToDot)
AC.dumpDotFile();
AC.fillAbstractCache(EntryAddress);
if (DumpNodes)
AC.dumpNodes();
outs() << "MustHits: " << AC.collectHits() << "\n";
outs() << "MayMisses: " << AC.collectMisses() << "\n";
return PreservedAnalyses::all();
}
};
} // namespace
//-----------------------------------------------------------------------------
// New PM Registration
//-----------------------------------------------------------------------------
llvm::PassPluginLibraryInfo getCacheAnalysisPassPluginInfo() {
return {LLVM_PLUGIN_API_VERSION, "CacheAnalysisPass", LLVM_VERSION_STRING,
[](PassBuilder &PB) {
PB.registerPipelineParsingCallback(
[](StringRef Name, ModulePassManager &MPM,
ArrayRef<PassBuilder::PipelineElement>) {
if (Name == "lru-misses") {
MPM.addPass(CacheAnalysisPass());
return true; // only looks at CFG
}
return false; // Analysis pass.
});
}};
}
// This is the core interface for pass plugins. It guarantees that 'opt' will
// be able to recognize CacheAnalysisPass when added to the pass pipeline on
// the command line, i.e. via '-passes=lru-misses'
extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo
llvmGetPassPluginInfo() {
return getCacheAnalysisPassPluginInfo();
}

21
Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM archlinux
# 1. INSTALL DEPENDENCIES
RUN pacman -Syu --noconfirm \
git \
cmake \
ninja \
gcc \
llvm \
clang \
gdb \
python-pip \
fish \
zsh
# 2. INSTALL LIT
RUN pip3 install lit

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2022 Nils Hoelscher
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

86
README.md Normal file
View File

@ -0,0 +1,86 @@
# RTSA-lab01-CacheAnalysis
In this lab session you will learn how to implement a LRU cache in abstract representation.
The Goal is to implement an LRU must Join in include/AbstractState.h
The Project can build, tested and Evaluated with the Helper Script.
## Diclaimer
This is the first time we provide this exercise.
Should you encounter something you think is a Bug, please let me know, during lab sessions.
Also keep track of the Repository as I may add more features to the script.
## Setup
We recommend using docker and VS Code for setup.
If this is not your preferred Setup, take a look in the Docker file for the dependencies.
Also we do not support the usage of Windows, Linux is free of charge so get a copy.
### Setting Docker up:
1.) install docker and VS Code on your Distribution.
https://docs.docker.com/get-docker/
https://code.visualstudio.com/
For this setup you cannot use the OSS version of VS code or the version from Snap, as the remote development extensions will not work.
2.) We recommend you install the following extensions in vs code
C/C++,
clangd,
Docker and
Remote Development
3.) Use the helper script to build and run a Container
$ ./helper.sh docker
This will build a docker image and run a Docker container with the current directory mounted.
4.) Attach VS Code to the container, in the Docker Tab, and start developing
## Debugging
When you are using VS Code you can simply use the Debugging Tab, we prepared a debug script for you.
## Use the Helper script
### Initial Setup:
$ ./helper.sh all
To get a list of what the helper script can do simply type
$ ./helper.sh
### Run:
Run the pass on a single test.
fft1 is recommended during development.
$ ./helper.sh run fft1
### Eval:
Runs the Pass on a set of tests and also prints the expected results.
This will be used to measure correctness of you implementation.
$ ./helper.sh eval
## Use the Terminal (Obsolete if script is used)
This section is not needed, fi you are using the script but for the sake of completeness it is provided anyways.
Initial Setup:
$ mkdir build
$ cd build
$ cmake -DLT_LLVM_INSTALL_DIR=$LLVM_DIR ../CacheAnalysisPass/
$ make
$ cd ..
Run:
$ opt -load-pass-plugin build/libCacheAnalysisPass.so -passes=lru-misses test/crc.ll

172
helper.sh Executable file
View File

@ -0,0 +1,172 @@
#!/bin/bash
clean () {
echo "==== Cleaning build folder ===="
rm -rf build/
}
config () {
echo "==== Crating build folder ===="
mkdir build
cd build
echo "==== Configuring cmake ===="
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLT_LLVM_INSTALL_DIR=$LLVM_DIR ../CacheAnalysisPass/
echo "==== Done! ===="
}
compile () {
cd build
echo "==== Compiling Project ===="
ninja
cd ..
echo "==== Done! ===="
}
run () {
echo "==== Running $1 ===="
opt -load-pass-plugin build/libCacheAnalysisPass.so \
-passes='lru-misses(function(loop-unroll-and-jam))' \
test/$1.ll -o /dev/null
#llvm-dis < out.bc > out.ll
}
allBenchs=( "adpcm"
"bs"
"bsort100"
"cnt"
"compress"
"cover"
"crc"
"dijkstra"
"duff"
"edn"
"expint"
"fdct"
"fft1"
"fibcall"
"fir"
"hello"
"insertsort"
"janne_complex"
"jfdctint"
"lcdnum"
"lms"
"ludcmp"
"matmult"
"minver"
"ndes"
"nsichneu"
"ns"
"prime"
"qsort-exam"
"qurt"
"recursion"
"select"
"sqrt"
"statemate"
"ud"
"whet"
)
runall () {
for str in ${allBenchs[@]}; do
echo
run $str
done
}
case $1 in
clean)
clean
;;
config)
config
;;
c | compile)
compile
;;
cr)
compile
if [ $2 ]; then
run $2
else
echo "==== Please provide name of the test as second argument! ===="
fi
;;
r | run)
if [ $2 ]; then
run $2
else
echo "==== Please provide name of the test as second argument! ===="
fi
;;
ra | runall)
runall
;;
docker)
docker build -t rtsalab01cacheanalysis:latest .
docker run -i -d -v "$(pwd)"/.:/root:rw --name RTSAlab01 rtsalab01cacheanalysis
;;
evaluation | eval)
run "fft1"
echo "==== Correct fft1 ===="
echo "MustHits: 16"
echo "MayMisses: 280"
echo
run "bsort100"
echo "==== Correct bsort100 ===="
echo "MustHits: 1"
echo "MayMisses: 41"
echo
run "lms"
echo "==== Correct lms ===="
echo "MustHits: 5"
echo "MayMisses: 288"
echo
run "minver"
echo "==== Correct minver ===="
echo "MustHits: 6"
echo "MayMisses: 224"
echo
run "qsort-exam"
echo "==== Correct qsort-exam ===="
echo "MustHits: 2"
echo "MayMisses: 152"
echo
run "recursion"
echo "==== Correct recursion ===="
echo "MustHits: 8"
echo "MayMisses: 8"
echo
run "select"
echo "==== Correct select ===="
echo "MustHits: 4"
echo "MayMisses: 108"
echo
run "whet"
echo "==== Correct whet ===="
echo "MustHits: 5"
echo "MayMisses: 265"
echo
;;
a | all)
clean
config
ninja
echo "==== Done! ===="
;;
*)
if [ $1 ]; then
echo "Unknown argument: $1"
fi
echo "Please provide one of the following arguments:"
echo " clean Deletes the build folder"
echo " config Creates build folder and configures build System"
echo " c | compile Compiles the Project"
echo " a | all Cleans, configures and compiles the project"
echo " r | run [name] Run pass on test/[name] from the test folder"
echo " cr [name] Compile and run pass on test/[name] from the test folder"
echo " ra | runall Run pass on all tests from the test folder"
exit
;;
esac

128
include/AbstractCache.h Normal file
View File

@ -0,0 +1,128 @@
#ifndef ABSTRACHTCACHESTATE_H
#define ABSTRACHTCACHESTATE_H
#include <cassert>
#include <cstddef>
#include <fstream>
#include <iostream>
#include <llvm/IR/BasicBlock.h>
#include <llvm/Support/raw_ostream.h>
#include <map>
#include <ostream>
#include <utility>
#include "AbstractState.h"
#include "Address.h"
#include "ConcreteState.h"
// Forward declarations
namespace cacheAnaPass {
class AbstractCache;
} // namespace cacheAnaPass
class AbstractCache {
public: // everything is public, because IDGAF
// map keys are instruction Addresses.
std::map<unsigned int, std::list<unsigned int>> Edges;
std::map<unsigned int, AbstractState> Nodes;
AbstractCache() {}
/**
* @brief Add an Edge to the Abstract Cache
*
* @param Pre Predecessor Address
* @param Suc Successor Address
*/
void addEdge(unsigned int Pre, unsigned int Suc) {
Edges[Pre].push_back(Suc);
Nodes[Pre].Successors.push_back(Suc);
Nodes[Suc].Predecessors.push_back(Pre);
}
void addEmptyNode(unsigned int NodeAddr) {
Nodes[NodeAddr] = AbstractState(NodeAddr);
}
void fillAbstractCache(unsigned int NodeNr) {
Nodes[NodeNr].computed = true;
for (unsigned int SuccNr : Nodes[NodeNr].Successors) {
Nodes[SuccNr];
if (Nodes[SuccNr].computed) {
// Join don't call
Nodes[SuccNr].mustJoin(Nodes[NodeNr]);
Nodes[SuccNr].mustJoin(AbstractState(NodeNr));
} else {
// Update and fill Succ
Nodes[SuccNr].fill(Nodes[NodeNr], NodeNr);
fillAbstractCache(SuccNr);
}
}
return;
}
unsigned int collectHits() {
unsigned int Hits = 0;
for (auto const &E : Edges) {
auto predecessor = Nodes[E.first];
for (unsigned int SuccessorAddr : E.second) {
// When successors Address is in predecessor, we have a Hit.
Hits += predecessor.isHit(Address(SuccessorAddr)) ? 1 : 0;
}
}
return Hits;
}
unsigned int collectMisses() {
unsigned int Misses = 0;
for (auto const &E : Edges) {
auto predecessor = Nodes[E.first];
for (unsigned int SuccessorAddr : E.second) {
// When successors Address is in predecessor, we have a Hit.
Misses += predecessor.isHit(Address(SuccessorAddr)) ? 0 : 1;
}
}
return Misses;
}
void dumpEdges() {
llvm::outs() << "Dumping Edges:\n";
for (auto const &E : Edges) {
llvm::outs() << E.first;
bool FirstPrint = true;
for (unsigned int To : E.second) {
if (FirstPrint) {
llvm::outs() << " -> " << To;
FirstPrint = false;
} else {
llvm::outs() << ", " << To;
}
}
llvm::outs() << "\n";
}
}
void dumpDotFile() {
std::ofstream DotFile;
DotFile.open("out.dot");
DotFile << "digraph g {"
<< "\n";
for (auto const &E : Edges) {
for (unsigned int To : E.second) {
DotFile << E.first << " -> " << To << "\n";
}
}
DotFile << "}\n";
DotFile.close();
}
void dumpNodes() {
for (auto const &E : Edges) {
Nodes[E.first].dump();
}
}
}; // namespace
#endif // ABSTRACHTCACHESTATE_H

192
include/AbstractState.h Normal file
View File

@ -0,0 +1,192 @@
#ifndef ABSSTATE_H
#define ABSSTATE_H
#include <cassert>
#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <list>
#include <llvm/Support/raw_ostream.h>
#include <map>
#include <ostream>
#include <sstream>
#include <string>
#include "Address.h"
// Forward declarations
namespace cacheAnaPass {
class AbstractState;
} // namespace cacheAnaPass
class AbstractState {
public: // everything is public, because IDGAF
std::list<unsigned int> Successors;
std::list<unsigned int> Predecessors;
unsigned int Addr;
bool computed = false;
// Only entries below this comment are needed for the exercise.
/**
* @brief Containing all Abstract Cache Tags.
* Key of the list has no Meaning.
*
*/
struct Entry {
std::list<unsigned int> Blocks;
};
/**
* @brief Cache Set, Key is the Age of the Entries.
*
*/
struct Set {
// uInt in this map is the Age.
std::map<unsigned int, Entry> Associativity;
};
/**
* @brief Cache Sets, key is the Set number [0-15], derived from Address.
*
*/
std::map<unsigned int, Set> Sets;
AbstractState(AbstractState const &Copy) {
for (auto S : Copy.Sets) {
unsigned int SetNr = S.first;
for (auto E : S.second.Associativity) {
unsigned int Age = E.first;
for (auto B : E.second.Blocks) {
Sets[SetNr].Associativity[Age].Blocks.push_back(B);
}
}
}
}
AbstractState() {}
AbstractState(unsigned int AddressIn) { Addr = AddressIn; }
AbstractState(Address Addr) { Sets[Addr.Index].Associativity[0] = {{Addr.Tag}}; }
/**
* @brief Executes an Must LRU Join on the AbstractCacheState
*
* @param In, AbstractState that gets joined into the State.
*/
void mustJoin(AbstractState In) {
/**
* The exercise is to Fill this function with an LRU must Join.
* For this you need to use Sets. Associativity and Blocks.
*/
}
/**
* @brief Checks if Address Addr is in Cache
*
* @param Addr Address to check.
* @return true CacheState contains Address Addr
* @return false CacheState does not contain Address Addr
*/
bool isHit(Address Addr) {
for (auto E : Sets[Addr.Index].Associativity) {
for (auto B : E.second.Blocks) {
if (B == Addr.Tag)
return true;
}
}
return false;
}
/**
* @brief Updates the AbstractState with given Address
*
* @param Addr , Address
*/
void update(Address Addr) {
for (int i = 3; i > 0; i--) {
Sets[Addr.Index].Associativity[i] = Sets[Addr.Index].Associativity[i - 1];
}
Sets[Addr.Index].Associativity[0].Blocks = {Addr.Tag};
}
/**
* @brief Updates the AbstractState with given AbstractState
*
* @param UpdateState, State that gets merged into State with Age+1.
*/
void update(AbstractState UpdateState) {
for (auto S : UpdateState.Sets) {
unsigned int Index = S.first;
for (auto E : S.second.Associativity) {
unsigned int Age = E.first + 1;
// If updated age is greater 4 The Tag is no longer in Cache.
// Due to associativity of 4 per set.
if (Age >= 4)
break;
for (auto B : E.second.Blocks) {
Sets[Index].Associativity[Age].Blocks.push_back(B);
}
}
}
}
/**
* @brief Fills the AbstractState PreState and PreAddress.
*
* @param PreState, State that fills this state.
*
* @param PreAddr Address of PreState
*/
void fill(AbstractState PreState, Address PreAddr) {
for (auto S : PreState.Sets) {
unsigned int Index = S.first;
for (auto E : S.second.Associativity) {
unsigned int Age = E.first + 1;
// If updated age is greater 4 The Tag is no longer in Cache.
// Due to associativity of 4 per set.
if (Age >= 4)
break;
for (auto B : E.second.Blocks) {
Sets[Index].Associativity[Age].Blocks.push_back(B);
}
}
}
Sets[PreAddr.Index].Associativity[0].Blocks.push_back(PreAddr.Tag);
}
void dump() {
llvm::outs() << Addr << " {\n";
llvm::outs() << "Predecessors: ";
for (auto PreNr : Predecessors) {
llvm::outs() << PreNr << " ";
}
llvm::outs() << "\n";
llvm::outs() << "Successors: ";
for (auto SuccNr : Successors) {
llvm::outs() << SuccNr << " ";
}
llvm::outs() << "\n";
for (auto SetPair : Sets) {
llvm::outs() << "Set[" << SetPair.first << "]: \n";
for (auto EntryPair : SetPair.second.Associativity) {
llvm::outs() << " Age[" << EntryPair.first << "]: ";
for (auto Block : EntryPair.second.Blocks) {
llvm::outs() << Block << " ";
}
llvm::outs() << "\n";
}
}
llvm::outs() << "}\n";
}
}; // namespace
#endif // STATE_H

30
include/Address.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef ADDRESS_H
#define ADDRESS_H
// Forward declarations
#include <cassert>
namespace cacheAnaPass {
class Address;
} // namespace cacheAnaPass
class Address {
public: // everything is public, because IDGAF
unsigned int Addr;
unsigned int Offset;
unsigned int Index;
unsigned int Tag;
// Object holding Tag, Index and Offset for a 16Sets, 4Assoc ,2CL Cache
Address(unsigned int Addr) {
this->Addr = Addr;
// Ignoring Offset
this->Offset = Addr & 0b1;
assert(Offset <= 1);
this->Index = (Addr & 0b11110) >> 1;
assert(Index <= 15);
this->Tag = Addr >> 5;
}
}; // namespace
#endif // STATE_H

44
include/CacheType.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef CACHETYPE_H
#define CACHETYPE_H
#include <cassert>
// Forward declarations
namespace cacheAnaPass {
class CacheType;
} // namespace cacheAnaPass
/**
* @brief Class to Check if Set Associate Cache is valid.
*
*/
class CacheType {
public:
bool isPower2(int n) { return n && !(n & (n - 1)); }
int Sets; // n Sets
int Associativity; // m Associativity
int LineSize; // In Bits
int CacheSize; // In Bits, n*m*Linesize
/**
* @brief Construct a new Cache Type object
*
* @param Sets
* @param Associativity
* @param Linesize
*/
CacheType(unsigned int Sets, unsigned int Associativity,
unsigned int Linesize) {
assert(isPower2(Sets));
assert(isPower2(Associativity));
assert(isPower2(Linesize));
this->Sets = Sets;
this->Associativity = Associativity;
this->LineSize = Linesize;
this->CacheSize = Sets * Associativity * Linesize;
}
CacheType();
};
#endif // CACHETYPE_H

41
include/ConcreteState.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef CONCRETESTATE_H
#define CONCRETESTATE_H
//Currently Unused.
#include <cassert>
#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <sstream>
#include <string>
#include "Address.h"
// Forward declarations
namespace cacheAnaPass {
class ConcreteState;
} // namespace cacheAnaPass
class ConcreteState {
public: // everything is public, because IDGAF
struct Entry {
unsigned int Block;
unsigned int Age;
};
struct Set {
std::map<unsigned int, unsigned int> Entries;
};
std::map<unsigned int, Set> Sets;
ConcreteState(Address Addr) {
Sets[Addr.Index].Entries[0]= Addr.Tag;
}
}; // namespace
#endif // CONCRETESTATE_H

1584
test/adpcm.ll Normal file

File diff suppressed because it is too large Load Diff

78
test/bs.ll Normal file
View File

@ -0,0 +1,78 @@
; ModuleID = 'bs.c'
source_filename = "bs.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.DATA = type { i32, i32 }
@data = dso_local local_unnamed_addr global [15 x %struct.DATA] [%struct.DATA { i32 1, i32 100 }, %struct.DATA { i32 5, i32 200 }, %struct.DATA { i32 6, i32 300 }, %struct.DATA { i32 7, i32 700 }, %struct.DATA { i32 8, i32 900 }, %struct.DATA { i32 9, i32 250 }, %struct.DATA { i32 10, i32 400 }, %struct.DATA { i32 11, i32 600 }, %struct.DATA { i32 12, i32 800 }, %struct.DATA { i32 13, i32 1500 }, %struct.DATA { i32 14, i32 1200 }, %struct.DATA { i32 15, i32 110 }, %struct.DATA { i32 16, i32 140 }, %struct.DATA { i32 17, i32 133 }, %struct.DATA { i32 18, i32 10 }], align 16
; Function Attrs: nofree norecurse nosync nounwind readonly sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
ret i32 0
}
; Function Attrs: nofree norecurse nosync nounwind readonly sspstrong uwtable
define dso_local i32 @binary_search(i32 %0) local_unnamed_addr #0 {
br label %2
2: ; preds = %1, %22
%3 = phi i32 [ 0, %1 ], [ %25, %22 ]
%4 = phi i32 [ 14, %1 ], [ %24, %22 ]
%5 = phi i32 [ -1, %1 ], [ %23, %22 ]
%6 = add nsw i32 %3, %4
%7 = ashr i32 %6, 1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [15 x %struct.DATA], [15 x %struct.DATA]* @data, i64 0, i64 %8, i32 0
%10 = load i32, i32* %9, align 8, !tbaa !5
%11 = icmp eq i32 %10, %0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = add nsw i32 %3, -1
%14 = getelementptr inbounds [15 x %struct.DATA], [15 x %struct.DATA]* @data, i64 0, i64 %8, i32 1
%15 = load i32, i32* %14, align 4, !tbaa !10
br label %22
16: ; preds = %2
%17 = icmp sgt i32 %10, %0
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = add nsw i32 %7, -1
br label %22
20: ; preds = %16
%21 = add nsw i32 %7, 1
br label %22
22: ; preds = %18, %20, %12
%23 = phi i32 [ %15, %12 ], [ %5, %18 ], [ %5, %20 ]
%24 = phi i32 [ %13, %12 ], [ %19, %18 ], [ %4, %20 ]
%25 = phi i32 [ %3, %12 ], [ %3, %18 ], [ %21, %20 ]
%26 = icmp sgt i32 %25, %24
br i1 %26, label %27, label %2, !llvm.loop !11
27: ; preds = %22
ret i32 %23
}
attributes #0 = { nofree norecurse nosync nounwind readonly sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !7, i64 0}
!6 = !{!"DATA", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = distinct !{!11, !12, !13}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.unroll.disable"}

159
test/bsort100.ll Normal file
View File

@ -0,0 +1,159 @@
; ModuleID = 'bsort100.c'
source_filename = "bsort100.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@Array = dso_local local_unnamed_addr global [101 x i32] zeroinitializer, align 16
@factor = dso_local local_unnamed_addr global i32 0, align 4
@Seed = dso_local local_unnamed_addr global i32 0, align 4
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
store i32 -1, i32* @factor, align 4, !tbaa !5
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 1, %0 ], [ %9, %1 ]
%3 = load i8, i8* inttoptr (i64 2149580801 to i8*), align 1, !tbaa !9
%4 = sext i8 %3 to i32
%5 = trunc i64 %2 to i32
%6 = mul i32 %5, %4
%7 = sub i32 0, %6
%8 = getelementptr inbounds [101 x i32], [101 x i32]* @Array, i64 0, i64 %2
store i32 %7, i32* %8, align 4, !tbaa !5
%9 = add nuw nsw i64 %2, 1
%10 = icmp eq i64 %9, 101
br i1 %10, label %15, label %1, !llvm.loop !10
11: ; preds = %31
%12 = add nuw nsw i32 %17, 1
%13 = add nsw i64 %16, -1
%14 = icmp eq i32 %12, 100
br i1 %14, label %33, label %15, !llvm.loop !13
15: ; preds = %1, %11
%16 = phi i64 [ %13, %11 ], [ 100, %1 ]
%17 = phi i32 [ %12, %11 ], [ 1, %1 ]
br label %18
18: ; preds = %28, %15
%19 = phi i64 [ 1, %15 ], [ %23, %28 ]
%20 = phi i32 [ 1, %15 ], [ %29, %28 ]
%21 = getelementptr inbounds [101 x i32], [101 x i32]* @Array, i64 0, i64 %19
%22 = load i32, i32* %21, align 4, !tbaa !5
%23 = add nuw nsw i64 %19, 1
%24 = getelementptr inbounds [101 x i32], [101 x i32]* @Array, i64 0, i64 %23
%25 = load i32, i32* %24, align 4, !tbaa !5
%26 = icmp sgt i32 %22, %25
br i1 %26, label %27, label %28
27: ; preds = %18
store i32 %25, i32* %21, align 4, !tbaa !5
store i32 %22, i32* %24, align 4, !tbaa !5
br label %28
28: ; preds = %27, %18
%29 = phi i32 [ 0, %27 ], [ %20, %18 ]
%30 = icmp eq i64 %23, %16
br i1 %30, label %31, label %18, !llvm.loop !14
31: ; preds = %28
%32 = icmp eq i32 %29, 0
br i1 %32, label %11, label %33
33: ; preds = %11, %31
ret i32 0
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn
define dso_local i32 @ttime() local_unnamed_addr #1 {
ret i32 0
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @Initialize(i32* nocapture %0) local_unnamed_addr #0 {
store i32 -1, i32* @factor, align 4, !tbaa !5
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 1, %1 ], [ %10, %2 ]
%4 = load i8, i8* inttoptr (i64 2149580801 to i8*), align 1, !tbaa !9
%5 = sext i8 %4 to i32
%6 = trunc i64 %3 to i32
%7 = mul i32 %6, %5
%8 = sub i32 0, %7
%9 = getelementptr inbounds i32, i32* %0, i64 %3
store i32 %8, i32* %9, align 4, !tbaa !5
%10 = add nuw nsw i64 %3, 1
%11 = icmp eq i64 %10, 101
br i1 %11, label %12, label %2, !llvm.loop !10
12: ; preds = %2
ret i32 undef
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @BubbleSort(i32* nocapture %0) local_unnamed_addr #0 {
br label %6
2: ; preds = %22
%3 = add nuw nsw i32 %8, 1
%4 = add nsw i64 %7, -1
%5 = icmp eq i32 %3, 100
br i1 %5, label %24, label %6, !llvm.loop !13
6: ; preds = %1, %2
%7 = phi i64 [ 100, %1 ], [ %4, %2 ]
%8 = phi i32 [ 1, %1 ], [ %3, %2 ]
br label %9
9: ; preds = %6, %19
%10 = phi i64 [ 1, %6 ], [ %14, %19 ]
%11 = phi i32 [ 1, %6 ], [ %20, %19 ]
%12 = getelementptr inbounds i32, i32* %0, i64 %10
%13 = load i32, i32* %12, align 4, !tbaa !5
%14 = add nuw nsw i64 %10, 1
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15, align 4, !tbaa !5
%17 = icmp sgt i32 %13, %16
br i1 %17, label %18, label %19
18: ; preds = %9
store i32 %16, i32* %12, align 4, !tbaa !5
store i32 %13, i32* %15, align 4, !tbaa !5
br label %19
19: ; preds = %9, %18
%20 = phi i32 [ 0, %18 ], [ %11, %9 ]
%21 = icmp eq i64 %14, %7
br i1 %21, label %22, label %9, !llvm.loop !14
22: ; preds = %19
%23 = icmp eq i32 %20, 0
br i1 %23, label %2, label %24
24: ; preds = %22, %2
ret i32 undef
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11, !12}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !11, !12}
!14 = distinct !{!14, !11, !12}

294
test/cnt.ll Normal file
View File

@ -0,0 +1,294 @@
; ModuleID = 'cnt.c'
source_filename = "cnt.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@Array = dso_local local_unnamed_addr global [10 x [10 x i32]] zeroinitializer, align 16
@Seed = dso_local local_unnamed_addr global i32 0, align 4
@Postotal = dso_local local_unnamed_addr global i32 0, align 4
@Poscnt = dso_local local_unnamed_addr global i32 0, align 4
@Negtotal = dso_local local_unnamed_addr global i32 0, align 4
@Negcnt = dso_local local_unnamed_addr global i32 0, align 4
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
store i32 0, i32* @Seed, align 4, !tbaa !5
br label %1
1: ; preds = %13, %0
%2 = phi i32 [ 0, %0 ], [ %9, %13 ]
%3 = phi i64 [ 0, %0 ], [ %14, %13 ]
br label %4
4: ; preds = %4, %1
%5 = phi i32 [ %2, %1 ], [ %9, %4 ]
%6 = phi i64 [ 0, %1 ], [ %11, %4 ]
%7 = mul nsw i32 %5, 133
%8 = add nsw i32 %7, 81
%9 = srem i32 %8, 8095
%10 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* @Array, i64 0, i64 %3, i64 %6
store i32 %9, i32* %10, align 4, !tbaa !5
%11 = add nuw nsw i64 %6, 1
%12 = icmp eq i64 %11, 10
br i1 %12, label %13, label %4, !llvm.loop !9
13: ; preds = %4
%14 = add nuw nsw i64 %3, 1
%15 = icmp eq i64 %14, 10
br i1 %15, label %16, label %1, !llvm.loop !12
16: ; preds = %13
store i32 %9, i32* @Seed, align 4, !tbaa !5
br label %17
17: ; preds = %16, %45
%18 = phi i64 [ %46, %45 ], [ 0, %16 ]
%19 = phi i32 [ %42, %45 ], [ 0, %16 ]
%20 = phi i32 [ %41, %45 ], [ 0, %16 ]
%21 = phi i32 [ %40, %45 ], [ 0, %16 ]
%22 = phi i32 [ %39, %45 ], [ 0, %16 ]
br label %23
23: ; preds = %38, %17
%24 = phi i64 [ 0, %17 ], [ %43, %38 ]
%25 = phi i32 [ %19, %17 ], [ %42, %38 ]
%26 = phi i32 [ %20, %17 ], [ %41, %38 ]
%27 = phi i32 [ %21, %17 ], [ %40, %38 ]
%28 = phi i32 [ %22, %17 ], [ %39, %38 ]
%29 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* @Array, i64 0, i64 %18, i64 %24
%30 = load i32, i32* %29, align 4, !tbaa !5
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %23
%33 = add nsw i32 %30, %28
%34 = add nsw i32 %26, 1
br label %38
35: ; preds = %23
%36 = add nsw i32 %30, %27
%37 = add nsw i32 %25, 1
br label %38
38: ; preds = %35, %32
%39 = phi i32 [ %33, %32 ], [ %28, %35 ]
%40 = phi i32 [ %27, %32 ], [ %36, %35 ]
%41 = phi i32 [ %34, %32 ], [ %26, %35 ]
%42 = phi i32 [ %25, %32 ], [ %37, %35 ]
%43 = add nuw nsw i64 %24, 1
%44 = icmp eq i64 %43, 10
br i1 %44, label %45, label %23, !llvm.loop !13
45: ; preds = %38
%46 = add nuw nsw i64 %18, 1
%47 = icmp eq i64 %46, 10
br i1 %47, label %48, label %17, !llvm.loop !14
48: ; preds = %45
store i32 %39, i32* @Postotal, align 4, !tbaa !5
store i32 %41, i32* @Poscnt, align 4, !tbaa !5
store i32 %40, i32* @Negtotal, align 4, !tbaa !5
store i32 %42, i32* @Negcnt, align 4, !tbaa !5
ret i32 1
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn writeonly
define dso_local i32 @InitSeed() local_unnamed_addr #1 {
store i32 0, i32* @Seed, align 4, !tbaa !5
ret i32 0
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @Test([10 x i32]* nocapture %0) local_unnamed_addr #0 {
br label %2
2: ; preds = %13, %1
%3 = phi i64 [ 0, %1 ], [ %14, %13 ]
br label %4
4: ; preds = %4, %2
%5 = phi i64 [ 0, %2 ], [ %11, %4 ]
%6 = load i32, i32* @Seed, align 4, !tbaa !5
%7 = mul nsw i32 %6, 133
%8 = add nsw i32 %7, 81
%9 = srem i32 %8, 8095
store i32 %9, i32* @Seed, align 4, !tbaa !5
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %0, i64 %3, i64 %5
store i32 %9, i32* %10, align 4, !tbaa !5
%11 = add nuw nsw i64 %5, 1
%12 = icmp eq i64 %11, 10
br i1 %12, label %13, label %4, !llvm.loop !9
13: ; preds = %4
%14 = add nuw nsw i64 %3, 1
%15 = icmp eq i64 %14, 10
br i1 %15, label %16, label %2, !llvm.loop !12
16: ; preds = %13, %44
%17 = phi i64 [ %45, %44 ], [ 0, %13 ]
%18 = phi i32 [ %41, %44 ], [ 0, %13 ]
%19 = phi i32 [ %40, %44 ], [ 0, %13 ]
%20 = phi i32 [ %39, %44 ], [ 0, %13 ]
%21 = phi i32 [ %38, %44 ], [ 0, %13 ]
br label %22
22: ; preds = %37, %16
%23 = phi i64 [ 0, %16 ], [ %42, %37 ]
%24 = phi i32 [ %18, %16 ], [ %41, %37 ]
%25 = phi i32 [ %19, %16 ], [ %40, %37 ]
%26 = phi i32 [ %20, %16 ], [ %39, %37 ]
%27 = phi i32 [ %21, %16 ], [ %38, %37 ]
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %0, i64 %17, i64 %23
%29 = load i32, i32* %28, align 4, !tbaa !5
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %22
%32 = add nsw i32 %29, %27
%33 = add nsw i32 %25, 1
br label %37
34: ; preds = %22
%35 = add nsw i32 %29, %26
%36 = add nsw i32 %24, 1
br label %37
37: ; preds = %34, %31
%38 = phi i32 [ %32, %31 ], [ %27, %34 ]
%39 = phi i32 [ %26, %31 ], [ %35, %34 ]
%40 = phi i32 [ %33, %31 ], [ %25, %34 ]
%41 = phi i32 [ %24, %31 ], [ %36, %34 ]
%42 = add nuw nsw i64 %23, 1
%43 = icmp eq i64 %42, 10
br i1 %43, label %44, label %22, !llvm.loop !13
44: ; preds = %37
%45 = add nuw nsw i64 %17, 1
%46 = icmp eq i64 %45, 10
br i1 %46, label %47, label %16, !llvm.loop !14
47: ; preds = %44
store i32 %38, i32* @Postotal, align 4, !tbaa !5
store i32 %40, i32* @Poscnt, align 4, !tbaa !5
store i32 %39, i32* @Negtotal, align 4, !tbaa !5
store i32 %41, i32* @Negcnt, align 4, !tbaa !5
ret i32 0
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @Initialize([10 x i32]* nocapture %0) local_unnamed_addr #0 {
br label %2
2: ; preds = %1, %13
%3 = phi i64 [ 0, %1 ], [ %14, %13 ]
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 0, %2 ], [ %11, %4 ]
%6 = load i32, i32* @Seed, align 4, !tbaa !5
%7 = mul nsw i32 %6, 133
%8 = add nsw i32 %7, 81
%9 = srem i32 %8, 8095
store i32 %9, i32* @Seed, align 4, !tbaa !5
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %0, i64 %3, i64 %5
store i32 %9, i32* %10, align 4, !tbaa !5
%11 = add nuw nsw i64 %5, 1
%12 = icmp eq i64 %11, 10
br i1 %12, label %13, label %4, !llvm.loop !9
13: ; preds = %4
%14 = add nuw nsw i64 %3, 1
%15 = icmp eq i64 %14, 10
br i1 %15, label %16, label %2, !llvm.loop !12
16: ; preds = %13
ret i32 0
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @Sum([10 x i32]* nocapture readonly %0) local_unnamed_addr #0 {
br label %2
2: ; preds = %1, %30
%3 = phi i64 [ 0, %1 ], [ %31, %30 ]
%4 = phi i32 [ 0, %1 ], [ %27, %30 ]
%5 = phi i32 [ 0, %1 ], [ %26, %30 ]
%6 = phi i32 [ 0, %1 ], [ %25, %30 ]
%7 = phi i32 [ 0, %1 ], [ %24, %30 ]
br label %8
8: ; preds = %2, %23
%9 = phi i64 [ 0, %2 ], [ %28, %23 ]
%10 = phi i32 [ %4, %2 ], [ %27, %23 ]
%11 = phi i32 [ %5, %2 ], [ %26, %23 ]
%12 = phi i32 [ %6, %2 ], [ %25, %23 ]
%13 = phi i32 [ %7, %2 ], [ %24, %23 ]
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %0, i64 %3, i64 %9
%15 = load i32, i32* %14, align 4, !tbaa !5
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %8
%18 = add nsw i32 %15, %13
%19 = add nsw i32 %11, 1
br label %23
20: ; preds = %8
%21 = add nsw i32 %15, %12
%22 = add nsw i32 %10, 1
br label %23
23: ; preds = %17, %20
%24 = phi i32 [ %18, %17 ], [ %13, %20 ]
%25 = phi i32 [ %12, %17 ], [ %21, %20 ]
%26 = phi i32 [ %19, %17 ], [ %11, %20 ]
%27 = phi i32 [ %10, %17 ], [ %22, %20 ]
%28 = add nuw nsw i64 %9, 1
%29 = icmp eq i64 %28, 10
br i1 %29, label %30, label %8, !llvm.loop !13
30: ; preds = %23
%31 = add nuw nsw i64 %3, 1
%32 = icmp eq i64 %31, 10
br i1 %32, label %33, label %2, !llvm.loop !14
33: ; preds = %30
store i32 %24, i32* @Postotal, align 4, !tbaa !5
store i32 %26, i32* @Poscnt, align 4, !tbaa !5
store i32 %25, i32* @Negtotal, align 4, !tbaa !5
store i32 %27, i32* @Negcnt, align 4, !tbaa !5
ret void
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn
define dso_local i32 @RandomInteger() local_unnamed_addr #2 {
%1 = load i32, i32* @Seed, align 4, !tbaa !5
%2 = mul nsw i32 %1, 133
%3 = add nsw i32 %2, 81
%4 = srem i32 %3, 8095
store i32 %4, i32* @Seed, align 4, !tbaa !5
ret i32 %4
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn writeonly "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10, !11}

798
test/compress.ll Normal file
View File

@ -0,0 +1,798 @@
; ModuleID = 'compress.c'
source_filename = "compress.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@maxbits = dso_local local_unnamed_addr global i32 16, align 4
@maxmaxcode = dso_local local_unnamed_addr global i64 65536, align 8
@hsize = dso_local local_unnamed_addr global i64 257, align 8
@free_ent = dso_local local_unnamed_addr global i64 0, align 8
@exit_stat = dso_local local_unnamed_addr global i32 0, align 4
@nomagic = dso_local local_unnamed_addr global i32 1, align 4
@zcat_flg = dso_local local_unnamed_addr global i32 0, align 4
@quiet = dso_local local_unnamed_addr global i32 1, align 4
@block_compress = dso_local local_unnamed_addr global i32 128, align 4
@clear_flg = dso_local local_unnamed_addr global i32 0, align 4
@ratio = dso_local local_unnamed_addr global i64 0, align 8
@checkpoint = dso_local local_unnamed_addr global i64 10000, align 8
@force = dso_local local_unnamed_addr global i32 0, align 4
@InCnt = dso_local local_unnamed_addr global i32 0, align 4
@apsim_InCnt = dso_local local_unnamed_addr global i32 0, align 4
@orig_text_buffer = dso_local global [50 x i8] zeroinitializer, align 16
@InBuff = dso_local local_unnamed_addr global i8* null, align 8
@comp_text_buffer = dso_local global [55 x i8] zeroinitializer, align 16
@OutBuff = dso_local local_unnamed_addr global i8* null, align 8
@in_count = dso_local local_unnamed_addr global i64 1, align 8
@out_count = dso_local local_unnamed_addr global i64 0, align 8
@offset = internal unnamed_addr global i32 0, align 4
@bytes_out = dso_local local_unnamed_addr global i64 0, align 8
@n_bits = dso_local local_unnamed_addr global i32 0, align 4
@maxcode = dso_local local_unnamed_addr global i64 0, align 8
@htab = dso_local local_unnamed_addr global [257 x i64] zeroinitializer, align 16
@codetab = dso_local local_unnamed_addr global [257 x i16] zeroinitializer, align 16
@lmask = dso_local local_unnamed_addr global [9 x i8] c"\FF\FE\FC\F8\F0\E0\C0\80\00", align 1
@rmask = dso_local local_unnamed_addr global [9 x i8] c"\00\01\03\07\0F\1F?\7F\FF", align 1
@buf = dso_local global [16 x i8] zeroinitializer, align 16
@fsize = dso_local local_unnamed_addr global i64 0, align 8
@ofname = dso_local local_unnamed_addr global [100 x i8] zeroinitializer, align 16
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %9, %1 ]
%3 = phi i32 [ 1, %0 ], [ %6, %1 ]
%4 = mul nsw i32 %3, 133
%5 = add nsw i32 %4, 81
%6 = srem i32 %5, 8095
%7 = trunc i32 %6 to i8
%8 = getelementptr inbounds [50 x i8], [50 x i8]* @orig_text_buffer, i64 0, i64 %2
store i8 %7, i8* %8, align 1, !tbaa !5
%9 = add nuw nsw i64 %2, 1
%10 = icmp eq i64 %9, 50
br i1 %10, label %11, label %1, !llvm.loop !8
11: ; preds = %1
store i32 16, i32* @maxbits, align 4, !tbaa !11
store i64 65536, i64* @maxmaxcode, align 8, !tbaa !13
store i32 50, i32* @InCnt, align 4, !tbaa !11
store i32 53, i32* @apsim_InCnt, align 4, !tbaa !11
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @orig_text_buffer, i64 0, i64 0), i8** @InBuff, align 8, !tbaa !15
store i8* getelementptr inbounds ([55 x i8], [55 x i8]* @comp_text_buffer, i64 0, i64 0), i8** @OutBuff, align 8, !tbaa !15
call void @compress()
ret i32 0
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable writeonly
define dso_local void @initbuffer() local_unnamed_addr #1 {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 0, %0 ], [ %9, %1 ]
%3 = phi i32 [ 1, %0 ], [ %6, %1 ]
%4 = mul nsw i32 %3, 133
%5 = add nsw i32 %4, 81
%6 = srem i32 %5, 8095
%7 = trunc i32 %6 to i8
%8 = getelementptr inbounds [50 x i8], [50 x i8]* @orig_text_buffer, i64 0, i64 %2
store i8 %7, i8* %8, align 1, !tbaa !5
%9 = add nuw nsw i64 %2, 1
%10 = icmp eq i64 %9, 50
br i1 %10, label %11, label %1, !llvm.loop !8
11: ; preds = %1
ret void
}
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local void @compress() local_unnamed_addr #0 {
store i32 0, i32* @offset, align 4, !tbaa !11
store i64 3, i64* @bytes_out, align 8, !tbaa !13
store i64 0, i64* @out_count, align 8, !tbaa !13
store i32 0, i32* @clear_flg, align 4, !tbaa !11
store i64 0, i64* @ratio, align 8, !tbaa !13
store i64 1, i64* @in_count, align 8, !tbaa !13
store i64 10000, i64* @checkpoint, align 8, !tbaa !13
store i32 9, i32* @n_bits, align 4, !tbaa !11
store i64 511, i64* @maxcode, align 8, !tbaa !13
%1 = load i32, i32* @block_compress, align 4, !tbaa !11
%2 = icmp eq i32 %1, 0
%3 = select i1 %2, i64 256, i64 257
store i64 %3, i64* @free_ent, align 8, !tbaa !13
%4 = load i32, i32* @InCnt, align 4, !tbaa !11
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %0
%7 = load i32, i32* @apsim_InCnt, align 4, !tbaa !11
%8 = add nsw i32 %7, -1
store i32 %8, i32* @apsim_InCnt, align 4, !tbaa !11
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = add nsw i32 %4, -1
store i32 %11, i32* @InCnt, align 4, !tbaa !11
%12 = load i8*, i8** @InBuff, align 8, !tbaa !15
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %13, i8** @InBuff, align 8, !tbaa !15
%14 = load i8, i8* %12, align 1, !tbaa !5
%15 = zext i8 %14 to i64
br label %16
16: ; preds = %0, %6, %10
%17 = phi i64 [ %15, %10 ], [ 4294967295, %6 ], [ 4294967295, %0 ]
%18 = load i64, i64* @hsize, align 8, !tbaa !13
%19 = icmp slt i64 %18, 65536
br i1 %19, label %20, label %28
20: ; preds = %16, %20
%21 = phi i32 [ %23, %20 ], [ 0, %16 ]
%22 = phi i64 [ %24, %20 ], [ %18, %16 ]
%23 = add nuw nsw i32 %21, 1
%24 = shl nsw i64 %22, 1
%25 = icmp slt i64 %22, 32768
br i1 %25, label %20, label %26, !llvm.loop !17
26: ; preds = %20
%27 = sub nsw i32 7, %21
br label %28
28: ; preds = %26, %16
%29 = phi i32 [ 8, %16 ], [ %27, %26 ]
%30 = add i64 %18, -16
%31 = add i64 %18, 15
%32 = call i64 @llvm.smin.i64(i64 %18, i64 31) #6
%33 = sub i64 %31, %32
%34 = and i64 %33, -16
%35 = sub i64 %30, %34
%36 = getelementptr [257 x i64], [257 x i64]* @htab, i64 0, i64 %35
%37 = bitcast i64* %36 to i8*
%38 = shl nuw i64 %33, 3
%39 = add i64 %38, 128
%40 = and i64 %39, -128
call void @llvm.memset.p0i8.i64(i8* align 8 %37, i8 -1, i64 %40, i1 false) #6
%41 = sub i64 %18, %34
%42 = icmp sgt i64 %41, 16
br i1 %42, label %43, label %52
43: ; preds = %28
%44 = call i64 @llvm.smin.i64(i64 %35, i64 1) #6
%45 = add i64 %44, -1
%46 = getelementptr [257 x i64], [257 x i64]* @htab, i64 0, i64 %45
%47 = bitcast i64* %46 to i8*
%48 = add i64 %18, -15
%49 = add i64 %34, %44
%50 = sub i64 %48, %49
%51 = shl nuw i64 %50, 3
call void @llvm.memset.p0i8.i64(i8* align 8 %47, i8 -1, i64 %51, i1 false) #6
br label %52
52: ; preds = %28, %43
%53 = load i32, i32* @InCnt, align 4, !tbaa !11
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %178
55: ; preds = %52, %174
%56 = phi i32 [ %176, %174 ], [ %53, %52 ]
%57 = phi i64 [ %175, %174 ], [ %17, %52 ]
%58 = load i32, i32* @apsim_InCnt, align 4, !tbaa !11
%59 = add nsw i32 %58, -1
store i32 %59, i32* @apsim_InCnt, align 4, !tbaa !11
%60 = icmp sgt i32 %58, 0
br i1 %60, label %61, label %67
61: ; preds = %55
%62 = add nsw i32 %56, -1
store i32 %62, i32* @InCnt, align 4, !tbaa !11
%63 = load i8*, i8** @InBuff, align 8, !tbaa !15
%64 = getelementptr inbounds i8, i8* %63, i64 1
store i8* %64, i8** @InBuff, align 8, !tbaa !15
%65 = load i8, i8* %63, align 1, !tbaa !5
%66 = zext i8 %65 to i32
br label %67
67: ; preds = %55, %61
%68 = phi i32 [ %66, %61 ], [ -1, %55 ]
%69 = load i64, i64* @in_count, align 8, !tbaa !13
%70 = add nsw i64 %69, 1
store i64 %70, i64* @in_count, align 8, !tbaa !13
%71 = sext i32 %68 to i64
%72 = load i32, i32* @maxbits, align 4, !tbaa !11
%73 = zext i32 %72 to i64
%74 = shl i64 %71, %73
%75 = add nsw i64 %74, %57
%76 = shl i32 %68, %29
%77 = sext i32 %76 to i64
%78 = xor i64 %57, %77
%79 = getelementptr inbounds [257 x i64], [257 x i64]* @htab, i64 0, i64 %78
%80 = load i64, i64* %79, align 8, !tbaa !13
%81 = icmp eq i64 %80, %75
br i1 %81, label %82, label %86
82: ; preds = %67
%83 = getelementptr inbounds [257 x i16], [257 x i16]* @codetab, i64 0, i64 %78
%84 = load i16, i16* %83, align 2, !tbaa !18
%85 = zext i16 %84 to i64
br label %174, !llvm.loop !20
86: ; preds = %67
%87 = icmp slt i64 %80, 0
br i1 %87, label %113, label %88
88: ; preds = %86
%89 = sub nsw i64 %18, %78
%90 = icmp eq i64 %78, 0
%91 = shl i64 %89, 32
%92 = ashr exact i64 %91, 32
%93 = select i1 %90, i64 1, i64 %92
br label %94
94: ; preds = %108, %88
%95 = phi i64 [ 0, %88 ], [ %110, %108 ]
%96 = phi i64 [ %78, %88 ], [ %100, %108 ]
%97 = sub nsw i64 %96, %93
%98 = icmp slt i64 %97, 0
%99 = select i1 %98, i64 %18, i64 0
%100 = add nsw i64 %99, %97
%101 = getelementptr inbounds [257 x i64], [257 x i64]* @htab, i64 0, i64 %100
%102 = load i64, i64* %101, align 8, !tbaa !13
%103 = icmp eq i64 %102, %75
br i1 %103, label %104, label %108
104: ; preds = %94
%105 = getelementptr inbounds [257 x i16], [257 x i16]* @codetab, i64 0, i64 %100
%106 = load i16, i16* %105, align 2, !tbaa !18
%107 = zext i16 %106 to i64
br label %174, !llvm.loop !20
108: ; preds = %94
%109 = icmp slt i64 %102, 1
%110 = add nuw i64 %95, 1
%111 = icmp slt i64 %69, %110
%112 = select i1 %109, i1 true, i1 %111
br i1 %112, label %113, label %94
113: ; preds = %108, %86
%114 = phi i64 [ %78, %86 ], [ %100, %108 ]
%115 = load i64, i64* @out_count, align 8, !tbaa !13
%116 = add nsw i64 %115, 1
store i64 %116, i64* @out_count, align 8, !tbaa !13
%117 = load i64, i64* @free_ent, align 8, !tbaa !13
%118 = load i64, i64* @maxmaxcode, align 8, !tbaa !13
%119 = icmp slt i64 %117, %118
br i1 %119, label %120, label %125
120: ; preds = %113
%121 = add nsw i64 %117, 1
store i64 %121, i64* @free_ent, align 8, !tbaa !13
%122 = trunc i64 %117 to i16
%123 = getelementptr inbounds [257 x i16], [257 x i16]* @codetab, i64 0, i64 %114
store i16 %122, i16* %123, align 2, !tbaa !18
%124 = getelementptr inbounds [257 x i64], [257 x i64]* @htab, i64 0, i64 %114
store i64 %75, i64* %124, align 8, !tbaa !13
br label %174
125: ; preds = %113
%126 = load i64, i64* @checkpoint, align 8, !tbaa !13
%127 = icmp sge i64 %70, %126
%128 = load i32, i32* @block_compress, align 4
%129 = icmp ne i32 %128, 0
%130 = select i1 %127, i1 %129, i1 false
br i1 %130, label %131, label %174
131: ; preds = %125
%132 = add nsw i64 %69, 10001
store i64 %132, i64* @checkpoint, align 8, !tbaa !13
%133 = icmp sgt i64 %69, 8388606
br i1 %133, label %134, label %140
134: ; preds = %131
%135 = load i64, i64* @bytes_out, align 8, !tbaa !13
%136 = icmp ult i64 %135, 256
br i1 %136, label %144, label %137
137: ; preds = %134
%138 = ashr i64 %135, 8
%139 = sdiv i64 %70, %138
br label %144
140: ; preds = %131
%141 = shl i64 %70, 8
%142 = load i64, i64* @bytes_out, align 8, !tbaa !13
%143 = sdiv i64 %141, %142
br label %144
144: ; preds = %140, %137, %134
%145 = phi i64 [ %139, %137 ], [ %143, %140 ], [ 2147483647, %134 ]
%146 = load i64, i64* @ratio, align 8, !tbaa !13
%147 = icmp sgt i64 %145, %146
br i1 %147, label %148, label %149
148: ; preds = %144
store i64 %145, i64* @ratio, align 8, !tbaa !13
br label %174
149: ; preds = %144
store i64 0, i64* @ratio, align 8, !tbaa !13
%150 = load i64, i64* @hsize, align 8, !tbaa !13
%151 = add i64 %150, -16
%152 = add i64 %150, 15
%153 = call i64 @llvm.smin.i64(i64 %150, i64 31) #6
%154 = sub i64 %152, %153
%155 = and i64 %154, -16
%156 = sub i64 %151, %155
%157 = getelementptr [257 x i64], [257 x i64]* @htab, i64 0, i64 %156
%158 = bitcast i64* %157 to i8*
%159 = shl nuw i64 %154, 3
%160 = add i64 %159, 128
%161 = and i64 %160, -128
call void @llvm.memset.p0i8.i64(i8* align 8 %158, i8 -1, i64 %161, i1 false) #6
%162 = sub i64 %150, %155
%163 = icmp sgt i64 %162, 16
br i1 %163, label %164, label %173
164: ; preds = %149
%165 = call i64 @llvm.smin.i64(i64 %156, i64 1) #6
%166 = add i64 %165, -1
%167 = getelementptr [257 x i64], [257 x i64]* @htab, i64 0, i64 %166
%168 = bitcast i64* %167 to i8*
%169 = add i64 %150, -15
%170 = add i64 %155, %165
%171 = sub i64 %169, %170
%172 = shl nuw i64 %171, 3
call void @llvm.memset.p0i8.i64(i8* align 8 %168, i8 -1, i64 %172, i1 false) #6
br label %173
173: ; preds = %164, %149
store i64 257, i64* @free_ent, align 8, !tbaa !13
store i32 1, i32* @clear_flg, align 4, !tbaa !11
call void @output(i64 256) #6
br label %174
174: ; preds = %173, %148, %120, %125, %104, %82
%175 = phi i64 [ %85, %82 ], [ %107, %104 ], [ %71, %125 ], [ %71, %120 ], [ %71, %148 ], [ %71, %173 ]
%176 = load i32, i32* @InCnt, align 4, !tbaa !11
%177 = icmp sgt i32 %176, 0
br i1 %177, label %55, label %178, !llvm.loop !20
178: ; preds = %174, %52
%179 = load i64, i64* @bytes_out, align 8, !tbaa !13
%180 = load i64, i64* @in_count, align 8, !tbaa !13
%181 = icmp sgt i64 %179, %180
br i1 %181, label %182, label %183
182: ; preds = %178
store i32 2, i32* @exit_stat, align 4, !tbaa !11
br label %183
183: ; preds = %182, %178
ret void
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn
define dso_local i32 @getbyte() local_unnamed_addr #2 {
%1 = load i32, i32* @InCnt, align 4, !tbaa !11
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %13
3: ; preds = %0
%4 = load i32, i32* @apsim_InCnt, align 4, !tbaa !11
%5 = add nsw i32 %4, -1
store i32 %5, i32* @apsim_InCnt, align 4, !tbaa !11
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %13
7: ; preds = %3
%8 = add nsw i32 %1, -1
store i32 %8, i32* @InCnt, align 4, !tbaa !11
%9 = load i8*, i8** @InBuff, align 8, !tbaa !15
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %10, i8** @InBuff, align 8, !tbaa !15
%11 = load i8, i8* %9, align 1, !tbaa !5
%12 = zext i8 %11 to i32
br label %13
13: ; preds = %0, %3, %7
%14 = phi i32 [ %12, %7 ], [ -1, %3 ], [ -1, %0 ]
ret i32 %14
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable writeonly
define dso_local void @cl_hash(i64 %0) local_unnamed_addr #1 {
%2 = add i64 %0, -16
%3 = add i64 %0, 15
%4 = call i64 @llvm.smin.i64(i64 %0, i64 31)
%5 = sub i64 %3, %4
%6 = and i64 %5, -16
%7 = sub i64 %2, %6
%8 = getelementptr [257 x i64], [257 x i64]* @htab, i64 0, i64 %7
%9 = bitcast i64* %8 to i8*
%10 = shl nuw i64 %5, 3
%11 = add i64 %10, 128
%12 = and i64 %11, -128
call void @llvm.memset.p0i8.i64(i8* align 8 %9, i8 -1, i64 %12, i1 false)
%13 = add i64 %0, 15
%14 = call i64 @llvm.smin.i64(i64 %0, i64 31)
%15 = sub i64 %13, %14
%16 = and i64 %15, -16
%17 = sub i64 %0, %16
%18 = icmp sgt i64 %17, 16
br i1 %18, label %19, label %30
19: ; preds = %1
%20 = add i64 %0, -16
%21 = sub i64 %20, %16
%22 = call i64 @llvm.smin.i64(i64 %21, i64 1)
%23 = add i64 %22, -1
%24 = getelementptr [257 x i64], [257 x i64]* @htab, i64 0, i64 %23
%25 = bitcast i64* %24 to i8*
%26 = add i64 %0, -15
%27 = add i64 %22, %16
%28 = sub i64 %26, %27
%29 = shl nuw i64 %28, 3
call void @llvm.memset.p0i8.i64(i8* align 8 %25, i8 -1, i64 %29, i1 false)
br label %30
30: ; preds = %19, %1
ret void
}
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local void @cl_block() local_unnamed_addr #0 {
%1 = load i64, i64* @in_count, align 8, !tbaa !13
%2 = add nsw i64 %1, 10000
store i64 %2, i64* @checkpoint, align 8, !tbaa !13
%3 = icmp sgt i64 %1, 8388607
br i1 %3, label %4, label %10
4: ; preds = %0
%5 = load i64, i64* @bytes_out, align 8, !tbaa !13
%6 = icmp ult i64 %5, 256
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = ashr i64 %5, 8
%9 = sdiv i64 %1, %8
br label %14
10: ; preds = %0
%11 = shl i64 %1, 8
%12 = load i64, i64* @bytes_out, align 8, !tbaa !13
%13 = sdiv i64 %11, %12
br label %14
14: ; preds = %4, %7, %10
%15 = phi i64 [ %9, %7 ], [ %13, %10 ], [ 2147483647, %4 ]
%16 = load i64, i64* @ratio, align 8, !tbaa !13
%17 = icmp sgt i64 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
store i64 %15, i64* @ratio, align 8, !tbaa !13
br label %44
19: ; preds = %14
store i64 0, i64* @ratio, align 8, !tbaa !13
%20 = load i64, i64* @hsize, align 8, !tbaa !13
%21 = add i64 %20, -16
%22 = add i64 %20, 15
%23 = call i64 @llvm.smin.i64(i64 %20, i64 31) #6
%24 = sub i64 %22, %23
%25 = and i64 %24, -16
%26 = sub i64 %21, %25
%27 = getelementptr [257 x i64], [257 x i64]* @htab, i64 0, i64 %26
%28 = bitcast i64* %27 to i8*
%29 = shl nuw i64 %24, 3
%30 = add i64 %29, 128
%31 = and i64 %30, -128
call void @llvm.memset.p0i8.i64(i8* align 8 %28, i8 -1, i64 %31, i1 false) #6
%32 = sub i64 %20, %25
%33 = icmp sgt i64 %32, 16
br i1 %33, label %34, label %43
34: ; preds = %19
%35 = call i64 @llvm.smin.i64(i64 %26, i64 1) #6
%36 = add i64 %35, -1
%37 = getelementptr [257 x i64], [257 x i64]* @htab, i64 0, i64 %36
%38 = bitcast i64* %37 to i8*
%39 = add i64 %20, -15
%40 = add i64 %25, %35
%41 = sub i64 %39, %40
%42 = shl nuw i64 %41, 3
call void @llvm.memset.p0i8.i64(i8* align 8 %38, i8 -1, i64 %42, i1 false) #6
br label %43
43: ; preds = %19, %34
store i64 257, i64* @free_ent, align 8, !tbaa !13
store i32 1, i32* @clear_flg, align 4, !tbaa !11
call void @output(i64 256)
br label %44
44: ; preds = %43, %18
ret void
}
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local void @output(i64 %0) local_unnamed_addr #0 {
%2 = load i32, i32* @offset, align 4, !tbaa !11
%3 = icmp sgt i64 %0, -1
br i1 %3, label %4, label %105
4: ; preds = %1
%5 = load i32, i32* @n_bits, align 4, !tbaa !11
%6 = ashr i32 %2, 3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [16 x i8], [16 x i8]* @buf, i64 0, i64 %7
%9 = and i32 %2, 7
%10 = load i8, i8* %8, align 1, !tbaa !5
%11 = zext i32 %9 to i64
%12 = getelementptr inbounds [9 x i8], [9 x i8]* @rmask, i64 0, i64 %11
%13 = load i8, i8* %12, align 1, !tbaa !5
%14 = and i8 %13, %10
%15 = shl i64 %0, %11
%16 = getelementptr inbounds [9 x i8], [9 x i8]* @lmask, i64 0, i64 %11
%17 = load i8, i8* %16, align 1, !tbaa !5
%18 = trunc i64 %15 to i8
%19 = or i8 %14, %18
%20 = and i8 %19, %17
store i8 %20, i8* %8, align 1, !tbaa !5
%21 = getelementptr inbounds i8, i8* %8, i64 1
%22 = sub nuw nsw i32 8, %9
%23 = sub nsw i32 %5, %22
%24 = zext i32 %22 to i64
%25 = ashr i64 %0, %24
%26 = icmp sgt i32 %23, 7
br i1 %26, label %27, label %32
27: ; preds = %4
%28 = trunc i64 %25 to i8
%29 = getelementptr inbounds i8, i8* %8, i64 2
store i8 %28, i8* %21, align 1, !tbaa !5
%30 = ashr i64 %25, 8
%31 = add nsw i32 %23, -8
br label %32
32: ; preds = %27, %4
%33 = phi i64 [ %30, %27 ], [ %25, %4 ]
%34 = phi i32 [ %31, %27 ], [ %23, %4 ]
%35 = phi i8* [ %29, %27 ], [ %21, %4 ]
%36 = icmp eq i32 %34, 0
br i1 %36, label %39, label %37
37: ; preds = %32
%38 = trunc i64 %33 to i8
store i8 %38, i8* %35, align 1, !tbaa !5
br label %39
39: ; preds = %37, %32
%40 = add nsw i32 %5, %2
store i32 %40, i32* @offset, align 4, !tbaa !11
%41 = shl i32 %5, 3
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %59
43: ; preds = %39
%44 = sext i32 %5 to i64
%45 = load i64, i64* @bytes_out, align 8, !tbaa !13
%46 = add nsw i64 %45, %44
store i64 %46, i64* @bytes_out, align 8, !tbaa !13
%47 = add i32 %5, -1
%48 = call i32 @llvm.umin.i32(i32 %47, i32 15)
%49 = zext i32 %48 to i64
%50 = getelementptr [16 x i8], [16 x i8]* @buf, i64 0, i64 %49
br label %51
51: ; preds = %51, %43
%52 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @buf, i64 0, i64 0), %43 ], [ %53, %51 ]
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = load i8, i8* %52, align 1, !tbaa !5
%55 = load i8*, i8** @OutBuff, align 8, !tbaa !15
%56 = getelementptr inbounds i8, i8* %55, i64 1
store i8* %56, i8** @OutBuff, align 8, !tbaa !15
store i8 %54, i8* %55, align 1, !tbaa !5
%57 = icmp eq i8* %52, %50
br i1 %57, label %58, label %51, !llvm.loop !21
58: ; preds = %51
store i32 0, i32* @offset, align 4, !tbaa !11
br label %59
59: ; preds = %58, %39
%60 = load i64, i64* @free_ent, align 8, !tbaa !13
%61 = load i64, i64* @maxcode, align 8, !tbaa !13
%62 = icmp sgt i64 %60, %61
%63 = load i32, i32* @clear_flg, align 4
%64 = icmp sgt i32 %63, 0
%65 = select i1 %62, i1 true, i1 %64
br i1 %65, label %66, label %128
66: ; preds = %59
%67 = load i32, i32* @offset, align 4, !tbaa !11
%68 = icmp sgt i32 %67, 0
br i1 %68, label %69, label %90
69: ; preds = %66
%70 = load i32, i32* @n_bits, align 4, !tbaa !11
%71 = icmp sgt i32 %70, 0
br i1 %71, label %72, label %85
72: ; preds = %69
%73 = add i32 %70, -1
%74 = call i32 @llvm.umin.i32(i32 %73, i32 15) #6
%75 = add nuw nsw i32 %74, 1
%76 = zext i32 %75 to i64
br label %77
77: ; preds = %77, %72
%78 = phi i64 [ 0, %72 ], [ %83, %77 ]
%79 = getelementptr inbounds [16 x i8], [16 x i8]* @buf, i64 0, i64 %78
%80 = load i8, i8* %79, align 1, !tbaa !5
%81 = load i8*, i8** @OutBuff, align 8, !tbaa !15
%82 = getelementptr inbounds i8, i8* %81, i64 1
store i8* %82, i8** @OutBuff, align 8, !tbaa !15
store i8 %80, i8* %81, align 1, !tbaa !5
%83 = add nuw nsw i64 %78, 1
%84 = icmp eq i64 %83, %76
br i1 %84, label %85, label %77, !llvm.loop !22
85: ; preds = %77, %69
%86 = load i32, i32* @n_bits, align 4, !tbaa !11
%87 = sext i32 %86 to i64
%88 = load i64, i64* @bytes_out, align 8, !tbaa !13
%89 = add nsw i64 %88, %87
store i64 %89, i64* @bytes_out, align 8, !tbaa !13
br label %90
90: ; preds = %85, %66
store i32 0, i32* @offset, align 4, !tbaa !11
%91 = load i32, i32* @clear_flg, align 4, !tbaa !11
%92 = icmp eq i32 %91, 0
br i1 %92, label %94, label %93
93: ; preds = %90
store i32 9, i32* @n_bits, align 4, !tbaa !11
store i64 511, i64* @maxcode, align 8, !tbaa !13
store i32 0, i32* @clear_flg, align 4, !tbaa !11
br label %128
94: ; preds = %90
%95 = load i32, i32* @n_bits, align 4, !tbaa !11
%96 = add nsw i32 %95, 1
store i32 %96, i32* @n_bits, align 4, !tbaa !11
%97 = load i32, i32* @maxbits, align 4, !tbaa !11
%98 = icmp eq i32 %96, %97
br i1 %98, label %99, label %101
99: ; preds = %94
%100 = load i64, i64* @maxmaxcode, align 8, !tbaa !13
store i64 %100, i64* @maxcode, align 8, !tbaa !13
br label %128
101: ; preds = %94
%102 = shl nsw i32 -1, %96
%103 = xor i32 %102, -1
%104 = sext i32 %103 to i64
store i64 %104, i64* @maxcode, align 8, !tbaa !13
br label %128
105: ; preds = %1
%106 = icmp sgt i32 %2, 0
br i1 %106, label %107, label %122
107: ; preds = %105
%108 = add nsw i32 %2, 7
%109 = sdiv i32 %108, 8
%110 = add nsw i32 %109, -1
%111 = call i32 @llvm.umin.i32(i32 %110, i32 15) #6
%112 = add nuw nsw i32 %111, 1
%113 = zext i32 %112 to i64
br label %114
114: ; preds = %114, %107
%115 = phi i64 [ 0, %107 ], [ %120, %114 ]
%116 = getelementptr inbounds [16 x i8], [16 x i8]* @buf, i64 0, i64 %115
%117 = load i8, i8* %116, align 1, !tbaa !5
%118 = load i8*, i8** @OutBuff, align 8, !tbaa !15
%119 = getelementptr inbounds i8, i8* %118, i64 1
store i8* %119, i8** @OutBuff, align 8, !tbaa !15
store i8 %117, i8* %118, align 1, !tbaa !5
%120 = add nuw nsw i64 %115, 1
%121 = icmp eq i64 %120, %113
br i1 %121, label %122, label %114, !llvm.loop !22
122: ; preds = %114, %105
%123 = add nsw i32 %2, 7
%124 = sdiv i32 %123, 8
%125 = sext i32 %124 to i64
%126 = load i64, i64* @bytes_out, align 8, !tbaa !13
%127 = add nsw i64 %126, %125
store i64 %127, i64* @bytes_out, align 8, !tbaa !13
store i32 0, i32* @offset, align 4, !tbaa !11
br label %128
128: ; preds = %59, %99, %101, %93, %122
ret void
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn
define dso_local void @putbyte(i8 signext %0) local_unnamed_addr #2 {
%2 = load i8*, i8** @OutBuff, align 8, !tbaa !15
%3 = getelementptr inbounds i8, i8* %2, i64 1
store i8* %3, i8** @OutBuff, align 8, !tbaa !15
store i8 %0, i8* %2, align 1, !tbaa !5
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @writebytes(i8* nocapture readonly %0, i32 %1) local_unnamed_addr #3 {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = add i32 %1, -1
%6 = call i32 @llvm.umin.i32(i32 %5, i32 15)
%7 = add nuw nsw i32 %6, 1
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %4, %9
%10 = phi i64 [ 0, %4 ], [ %15, %9 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11, align 1, !tbaa !5
%13 = load i8*, i8** @OutBuff, align 8, !tbaa !15
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8* %14, i8** @OutBuff, align 8, !tbaa !15
store i8 %12, i8* %13, align 1, !tbaa !5
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %8
br i1 %16, label %17, label %9, !llvm.loop !22
17: ; preds = %9, %2
ret void
}
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare i64 @llvm.smin.i64(i64, i64) #4
; Function Attrs: argmemonly nofree nounwind willreturn writeonly
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #5
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare i32 @llvm.umin.i32(i32, i32) #4
attributes #0 = { nofree nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree norecurse nosync nounwind sspstrong uwtable writeonly "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nosync nounwind readnone speculatable willreturn }
attributes #5 = { argmemonly nofree nounwind willreturn writeonly }
attributes #6 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !6, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !6, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"any pointer", !6, i64 0}
!17 = distinct !{!17, !9, !10}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !6, i64 0}
!20 = distinct !{!20, !9, !10}
!21 = distinct !{!21, !9, !10}
!22 = distinct !{!22, !9, !10}

119
test/cover.ll Normal file
View File

@ -0,0 +1,119 @@
; ModuleID = 'cover.c'
source_filename = "cover.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local i32 @swi120(i32 %0) local_unnamed_addr #0 {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %8, %2 ]
%4 = phi i32 [ %0, %1 ], [ %7, %2 ]
%5 = icmp ult i32 %3, 120
%6 = select i1 %5, i32 1, i32 -1
%7 = add nsw i32 %4, %6
%8 = add nuw nsw i32 %3, 1
%9 = icmp eq i32 %8, 120
br i1 %9, label %10, label %2, !llvm.loop !5
10: ; preds = %2
ret i32 %7
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local i32 @swi50(i32 %0) local_unnamed_addr #0 {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %8, %2 ]
%4 = phi i32 [ %0, %1 ], [ %7, %2 ]
%5 = icmp ult i32 %3, 60
%6 = select i1 %5, i32 1, i32 -1
%7 = add nsw i32 %4, %6
%8 = add nuw nsw i32 %3, 1
%9 = icmp eq i32 %8, 50
br i1 %9, label %10, label %2, !llvm.loop !8
10: ; preds = %2
ret i32 %7
}
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local i32 @swi10(i32 %0) local_unnamed_addr #0 {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %8, %2 ]
%4 = phi i32 [ %0, %1 ], [ %7, %2 ]
%5 = icmp ult i32 %3, 10
%6 = select i1 %5, i32 1, i32 -1
%7 = add nsw i32 %4, %6
%8 = add nuw nsw i32 %3, 1
%9 = icmp eq i32 %8, 10
br i1 %9, label %10, label %2, !llvm.loop !9
10: ; preds = %2
ret i32 %7
}
; Function Attrs: nofree nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
%1 = alloca i32, align 4
%2 = bitcast i32* %1 to i8*
call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %2)
store volatile i32 0, i32* %1, align 4, !tbaa !10
%3 = load volatile i32, i32* %1, align 4, !tbaa !10
br label %4
4: ; preds = %4, %0
%5 = phi i32 [ 0, %0 ], [ %10, %4 ]
%6 = phi i32 [ %3, %0 ], [ %9, %4 ]
%7 = icmp ult i32 %5, 10
%8 = select i1 %7, i32 1, i32 -1
%9 = add nsw i32 %6, %8
%10 = add nuw nsw i32 %5, 1
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %4, !llvm.loop !9
12: ; preds = %4
store volatile i32 %9, i32* %1, align 4, !tbaa !10
%13 = load volatile i32, i32* %1, align 4, !tbaa !10
%14 = call i32 @swi50(i32 %13)
store volatile i32 %14, i32* %1, align 4, !tbaa !10
%15 = load volatile i32, i32* %1, align 4, !tbaa !10
%16 = call i32 @swi120(i32 %15)
store volatile i32 %16, i32* %1, align 4, !tbaa !10
%17 = load volatile i32, i32* %1, align 4, !tbaa !10
%18 = bitcast i32* %1 to i8*
call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %18)
ret i32 %17
}
attributes #0 = { nofree norecurse nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
attributes #2 = { nofree nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.unroll.disable"}
!8 = distinct !{!8, !6, !7}
!9 = distinct !{!9, !6, !7}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C/C++ TBAA"}

313
test/crc.ll Normal file
View File

@ -0,0 +1,313 @@
; ModuleID = 'crc.c'
source_filename = "crc.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@lin = dso_local local_unnamed_addr global [256 x i8] c"asdffeagewaHAFEFaeDsFEawFdsFaefaeerdjgp\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 16
@icrc.icrctb = internal unnamed_addr global [256 x i16] zeroinitializer, align 16
@icrc.init = internal unnamed_addr global i1 false, align 2
@icrc.rchr = internal unnamed_addr global [256 x i8] zeroinitializer, align 16
@icrc.it = internal unnamed_addr constant [16 x i8] c"\00\08\04\0C\02\0A\06\0E\01\09\05\0D\03\0B\07\0F", align 16
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local zeroext i16 @icrc1(i16 zeroext %0, i8 zeroext %1) local_unnamed_addr #0 {
%3 = zext i8 %1 to i16
%4 = shl nuw i16 %3, 8
%5 = xor i16 %4, %0
br label %6
6: ; preds = %2, %6
%7 = phi i16 [ %5, %2 ], [ %12, %6 ]
%8 = phi i32 [ 0, %2 ], [ %13, %6 ]
%9 = icmp sgt i16 %7, -1
%10 = shl i16 %7, 1
%11 = xor i16 %10, 4129
%12 = select i1 %9, i16 %10, i16 %11
%13 = add nuw nsw i32 %8, 1
%14 = icmp eq i32 %13, 8
br i1 %14, label %15, label %6, !llvm.loop !5
15: ; preds = %6
ret i16 %12
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local zeroext i16 @icrc(i16 zeroext %0, i64 %1, i16 signext %2, i32 %3) local_unnamed_addr #1 {
%5 = load i1, i1* @icrc.init, align 2
br i1 %5, label %37, label %6
6: ; preds = %4
store i1 true, i1* @icrc.init, align 2
br label %7
7: ; preds = %6, %21
%8 = phi i64 [ 0, %6 ], [ %34, %21 ]
%9 = phi i32 [ 0, %6 ], [ %35, %21 ]
%10 = trunc i64 %8 to i16
%11 = shl i16 %10, 8
br label %12
12: ; preds = %12, %7
%13 = phi i16 [ %11, %7 ], [ %18, %12 ]
%14 = phi i32 [ 0, %7 ], [ %19, %12 ]
%15 = icmp sgt i16 %13, -1
%16 = shl i16 %13, 1
%17 = xor i16 %16, 4129
%18 = select i1 %15, i16 %16, i16 %17
%19 = add nuw nsw i32 %14, 1
%20 = icmp eq i32 %19, 8
br i1 %20, label %21, label %12, !llvm.loop !5
21: ; preds = %12
%22 = getelementptr inbounds [256 x i16], [256 x i16]* @icrc.icrctb, i64 0, i64 %8
store i16 %18, i16* %22, align 2, !tbaa !8
%23 = and i32 %9, 15
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [16 x i8], [16 x i8]* @icrc.it, i64 0, i64 %24
%26 = load i8, i8* %25, align 1, !tbaa !12
%27 = shl i8 %26, 4
%28 = lshr i32 %9, 4
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [16 x i8], [16 x i8]* @icrc.it, i64 0, i64 %29
%31 = load i8, i8* %30, align 1, !tbaa !12
%32 = or i8 %27, %31
%33 = getelementptr inbounds [256 x i8], [256 x i8]* @icrc.rchr, i64 0, i64 %8
store i8 %32, i8* %33, align 1, !tbaa !12
%34 = add nuw nsw i64 %8, 1
%35 = trunc i64 %34 to i32
%36 = icmp eq i64 %34, 256
br i1 %36, label %37, label %7, !llvm.loop !13
37: ; preds = %21, %4
%38 = icmp sgt i16 %2, -1
br i1 %38, label %39, label %43
39: ; preds = %37
%40 = and i16 %2, 255
%41 = shl i16 %2, 8
%42 = or i16 %41, %40
br label %58
43: ; preds = %37
%44 = icmp slt i32 %3, 0
br i1 %44, label %45, label %58
45: ; preds = %43
%46 = lshr i16 %0, 8
%47 = zext i16 %46 to i64
%48 = getelementptr inbounds [256 x i8], [256 x i8]* @icrc.rchr, i64 0, i64 %47
%49 = load i8, i8* %48, align 1, !tbaa !12
%50 = zext i8 %49 to i16
%51 = and i16 %0, 255
%52 = zext i16 %51 to i64
%53 = getelementptr inbounds [256 x i8], [256 x i8]* @icrc.rchr, i64 0, i64 %52
%54 = load i8, i8* %53, align 1, !tbaa !12
%55 = zext i8 %54 to i16
%56 = shl nuw i16 %55, 8
%57 = or i16 %56, %50
br label %58
58: ; preds = %43, %45, %39
%59 = phi i16 [ %42, %39 ], [ %57, %45 ], [ %0, %43 ]
%60 = icmp slt i32 %3, 0
%61 = icmp eq i64 %1, 0
br i1 %61, label %85, label %62
62: ; preds = %58, %72
%63 = phi i64 [ %83, %72 ], [ 1, %58 ]
%64 = phi i16 [ %81, %72 ], [ %59, %58 ]
%65 = phi i16 [ %82, %72 ], [ 1, %58 ]
%66 = getelementptr inbounds [256 x i8], [256 x i8]* @lin, i64 0, i64 %63
%67 = load i8, i8* %66, align 1, !tbaa !12
br i1 %60, label %68, label %72
68: ; preds = %62
%69 = zext i8 %67 to i64
%70 = getelementptr inbounds [256 x i8], [256 x i8]* @icrc.rchr, i64 0, i64 %69
%71 = load i8, i8* %70, align 1, !tbaa !12
br label %72
72: ; preds = %62, %68
%73 = phi i8 [ %71, %68 ], [ %67, %62 ]
%74 = zext i8 %73 to i16
%75 = lshr i16 %64, 8
%76 = xor i16 %75, %74
%77 = zext i16 %76 to i64
%78 = getelementptr inbounds [256 x i16], [256 x i16]* @icrc.icrctb, i64 0, i64 %77
%79 = load i16, i16* %78, align 2, !tbaa !8
%80 = shl i16 %64, 8
%81 = xor i16 %79, %80
%82 = add i16 %65, 1
%83 = zext i16 %82 to i64
%84 = icmp ugt i64 %83, %1
br i1 %84, label %85, label %62, !llvm.loop !14
85: ; preds = %72, %58
%86 = phi i16 [ %59, %58 ], [ %81, %72 ]
%87 = icmp sgt i32 %3, -1
br i1 %87, label %101, label %88
88: ; preds = %85
%89 = lshr i16 %86, 8
%90 = zext i16 %89 to i64
%91 = getelementptr inbounds [256 x i8], [256 x i8]* @icrc.rchr, i64 0, i64 %90
%92 = load i8, i8* %91, align 1, !tbaa !12
%93 = zext i8 %92 to i16
%94 = and i16 %86, 255
%95 = zext i16 %94 to i64
%96 = getelementptr inbounds [256 x i8], [256 x i8]* @icrc.rchr, i64 0, i64 %95
%97 = load i8, i8* %96, align 1, !tbaa !12
%98 = zext i8 %97 to i16
%99 = shl nuw i16 %98, 8
%100 = or i16 %99, %93
br label %101
101: ; preds = %85, %88
%102 = phi i16 [ %100, %88 ], [ %86, %85 ]
ret i16 %102
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @lin, i64 0, i64 41), align 1, !tbaa !12
%1 = load i1, i1* @icrc.init, align 2
br i1 %1, label %33, label %2
2: ; preds = %0
store i1 true, i1* @icrc.init, align 2
br label %3
3: ; preds = %17, %2
%4 = phi i64 [ 0, %2 ], [ %30, %17 ]
%5 = phi i32 [ 0, %2 ], [ %31, %17 ]
%6 = trunc i64 %4 to i16
%7 = shl i16 %6, 8
br label %8
8: ; preds = %8, %3
%9 = phi i16 [ %7, %3 ], [ %14, %8 ]
%10 = phi i32 [ 0, %3 ], [ %15, %8 ]
%11 = icmp sgt i16 %9, -1
%12 = shl i16 %9, 1
%13 = xor i16 %12, 4129
%14 = select i1 %11, i16 %12, i16 %13
%15 = add nuw nsw i32 %10, 1
%16 = icmp eq i32 %15, 8
br i1 %16, label %17, label %8, !llvm.loop !5
17: ; preds = %8
%18 = getelementptr inbounds [256 x i16], [256 x i16]* @icrc.icrctb, i64 0, i64 %4
store i16 %14, i16* %18, align 2, !tbaa !8
%19 = and i32 %5, 15
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [16 x i8], [16 x i8]* @icrc.it, i64 0, i64 %20
%22 = load i8, i8* %21, align 1, !tbaa !12
%23 = shl i8 %22, 4
%24 = lshr i32 %5, 4
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds [16 x i8], [16 x i8]* @icrc.it, i64 0, i64 %25
%27 = load i8, i8* %26, align 1, !tbaa !12
%28 = or i8 %23, %27
%29 = getelementptr inbounds [256 x i8], [256 x i8]* @icrc.rchr, i64 0, i64 %4
store i8 %28, i8* %29, align 1, !tbaa !12
%30 = add nuw nsw i64 %4, 1
%31 = trunc i64 %30 to i32
%32 = icmp eq i64 %30, 256
br i1 %32, label %33, label %3, !llvm.loop !13
33: ; preds = %17, %0
br label %34
34: ; preds = %33, %34
%35 = phi i64 [ %47, %34 ], [ 1, %33 ]
%36 = phi i16 [ %46, %34 ], [ 0, %33 ]
%37 = getelementptr inbounds [256 x i8], [256 x i8]* @lin, i64 0, i64 %35
%38 = load i8, i8* %37, align 1, !tbaa !12
%39 = zext i8 %38 to i16
%40 = lshr i16 %36, 8
%41 = xor i16 %40, %39
%42 = zext i16 %41 to i64
%43 = getelementptr inbounds [256 x i16], [256 x i16]* @icrc.icrctb, i64 0, i64 %42
%44 = load i16, i16* %43, align 2, !tbaa !8
%45 = shl i16 %36, 8
%46 = xor i16 %44, %45
%47 = add nuw nsw i64 %35, 1
%48 = icmp eq i64 %47, 41
br i1 %48, label %49, label %34, !llvm.loop !14
49: ; preds = %34
%50 = lshr i16 %46, 8
%51 = trunc i16 %50 to i8
store i8 %51, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @lin, i64 0, i64 41), align 1, !tbaa !12
%52 = trunc i16 %44 to i8
store i8 %52, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @lin, i64 0, i64 42), align 2, !tbaa !12
%53 = load i1, i1* @icrc.init, align 2
br i1 %53, label %85, label %54
54: ; preds = %49
store i1 true, i1* @icrc.init, align 2
br label %55
55: ; preds = %69, %54
%56 = phi i64 [ 0, %54 ], [ %82, %69 ]
%57 = phi i32 [ 0, %54 ], [ %83, %69 ]
%58 = trunc i64 %56 to i16
%59 = shl i16 %58, 8
br label %60
60: ; preds = %60, %55
%61 = phi i16 [ %59, %55 ], [ %66, %60 ]
%62 = phi i32 [ 0, %55 ], [ %67, %60 ]
%63 = icmp sgt i16 %61, -1
%64 = shl i16 %61, 1
%65 = xor i16 %64, 4129
%66 = select i1 %63, i16 %64, i16 %65
%67 = add nuw nsw i32 %62, 1
%68 = icmp eq i32 %67, 8
br i1 %68, label %69, label %60, !llvm.loop !5
69: ; preds = %60
%70 = getelementptr inbounds [256 x i16], [256 x i16]* @icrc.icrctb, i64 0, i64 %56
store i16 %66, i16* %70, align 2, !tbaa !8
%71 = and i32 %57, 15
%72 = zext i32 %71 to i64
%73 = getelementptr inbounds [16 x i8], [16 x i8]* @icrc.it, i64 0, i64 %72
%74 = load i8, i8* %73, align 1, !tbaa !12
%75 = shl i8 %74, 4
%76 = lshr i32 %57, 4
%77 = zext i32 %76 to i64
%78 = getelementptr inbounds [16 x i8], [16 x i8]* @icrc.it, i64 0, i64 %77
%79 = load i8, i8* %78, align 1, !tbaa !12
%80 = or i8 %75, %79
%81 = getelementptr inbounds [256 x i8], [256 x i8]* @icrc.rchr, i64 0, i64 %56
store i8 %80, i8* %81, align 1, !tbaa !12
%82 = add nuw nsw i64 %56, 1
%83 = trunc i64 %82 to i32
%84 = icmp eq i64 %82, 256
br i1 %84, label %85, label %55, !llvm.loop !13
85: ; preds = %69, %49
ret i32 0
}
attributes #0 = { nofree norecurse nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.unroll.disable"}
!8 = !{!9, !9, i64 0}
!9 = !{!"short", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !6, !7}
!14 = distinct !{!14, !6, !7}

456
test/dijkstra.ll Normal file

File diff suppressed because one or more lines are too long

219
test/duff.ll Normal file
View File

@ -0,0 +1,219 @@
; ModuleID = 'duff.c'
source_filename = "duff.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@source = dso_local local_unnamed_addr global [100 x i8] zeroinitializer, align 16
@target = dso_local local_unnamed_addr global [100 x i8] zeroinitializer, align 16
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @duffcopy(i8* nocapture %0, i8* nocapture readonly %1, i32 %2) local_unnamed_addr #0 {
%4 = add nsw i32 %2, 7
%5 = sdiv i32 %4, 8
%6 = srem i32 %2, 8
switch i32 %6, label %65 [
i32 0, label %7
i32 7, label %14
i32 6, label %21
i32 5, label %28
i32 4, label %35
i32 3, label %42
i32 2, label %49
i32 1, label %56
]
7: ; preds = %3, %56
%8 = phi i8* [ %60, %56 ], [ %1, %3 ]
%9 = phi i8* [ %62, %56 ], [ %0, %3 ]
%10 = phi i32 [ %63, %56 ], [ %5, %3 ]
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = load i8, i8* %8, align 1, !tbaa !5
%13 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %12, i8* %9, align 1, !tbaa !5
br label %14
14: ; preds = %3, %7
%15 = phi i8* [ %11, %7 ], [ %1, %3 ]
%16 = phi i8* [ %13, %7 ], [ %0, %3 ]
%17 = phi i32 [ %10, %7 ], [ %5, %3 ]
%18 = getelementptr inbounds i8, i8* %15, i64 1
%19 = load i8, i8* %15, align 1, !tbaa !5
%20 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %19, i8* %16, align 1, !tbaa !5
br label %21
21: ; preds = %3, %14
%22 = phi i8* [ %18, %14 ], [ %1, %3 ]
%23 = phi i8* [ %20, %14 ], [ %0, %3 ]
%24 = phi i32 [ %17, %14 ], [ %5, %3 ]
%25 = getelementptr inbounds i8, i8* %22, i64 1
%26 = load i8, i8* %22, align 1, !tbaa !5
%27 = getelementptr inbounds i8, i8* %23, i64 1
store i8 %26, i8* %23, align 1, !tbaa !5
br label %28
28: ; preds = %3, %21
%29 = phi i8* [ %25, %21 ], [ %1, %3 ]
%30 = phi i8* [ %27, %21 ], [ %0, %3 ]
%31 = phi i32 [ %24, %21 ], [ %5, %3 ]
%32 = getelementptr inbounds i8, i8* %29, i64 1
%33 = load i8, i8* %29, align 1, !tbaa !5
%34 = getelementptr inbounds i8, i8* %30, i64 1
store i8 %33, i8* %30, align 1, !tbaa !5
br label %35
35: ; preds = %3, %28
%36 = phi i8* [ %32, %28 ], [ %1, %3 ]
%37 = phi i8* [ %34, %28 ], [ %0, %3 ]
%38 = phi i32 [ %31, %28 ], [ %5, %3 ]
%39 = getelementptr inbounds i8, i8* %36, i64 1
%40 = load i8, i8* %36, align 1, !tbaa !5
%41 = getelementptr inbounds i8, i8* %37, i64 1
store i8 %40, i8* %37, align 1, !tbaa !5
br label %42
42: ; preds = %3, %35
%43 = phi i8* [ %39, %35 ], [ %1, %3 ]
%44 = phi i8* [ %41, %35 ], [ %0, %3 ]
%45 = phi i32 [ %38, %35 ], [ %5, %3 ]
%46 = getelementptr inbounds i8, i8* %43, i64 1
%47 = load i8, i8* %43, align 1, !tbaa !5
%48 = getelementptr inbounds i8, i8* %44, i64 1
store i8 %47, i8* %44, align 1, !tbaa !5
br label %49
49: ; preds = %3, %42
%50 = phi i8* [ %46, %42 ], [ %1, %3 ]
%51 = phi i8* [ %48, %42 ], [ %0, %3 ]
%52 = phi i32 [ %45, %42 ], [ %5, %3 ]
%53 = getelementptr inbounds i8, i8* %50, i64 1
%54 = load i8, i8* %50, align 1, !tbaa !5
%55 = getelementptr inbounds i8, i8* %51, i64 1
store i8 %54, i8* %51, align 1, !tbaa !5
br label %56
56: ; preds = %3, %49
%57 = phi i8* [ %1, %3 ], [ %53, %49 ]
%58 = phi i8* [ %0, %3 ], [ %55, %49 ]
%59 = phi i32 [ %5, %3 ], [ %52, %49 ]
%60 = getelementptr inbounds i8, i8* %57, i64 1
%61 = load i8, i8* %57, align 1, !tbaa !5
%62 = getelementptr inbounds i8, i8* %58, i64 1
store i8 %61, i8* %58, align 1, !tbaa !5
%63 = add nsw i32 %59, -1
%64 = icmp sgt i32 %59, 1
br i1 %64, label %7, label %65, !llvm.loop !8
65: ; preds = %56, %3
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable writeonly
define dso_local void @initialize(i8* nocapture %0, i32 %1) local_unnamed_addr #1 {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %12, %6 ]
%8 = trunc i64 %7 to i32
%9 = sub nsw i32 %1, %8
%10 = trunc i32 %9 to i8
%11 = getelementptr inbounds i8, i8* %0, i64 %7
store i8 %10, i8* %11, align 1, !tbaa !5
%12 = add nuw nsw i64 %7, 1
%13 = icmp eq i64 %12, %5
br i1 %13, label %14, label %6, !llvm.loop !11
14: ; preds = %6, %2
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @main() local_unnamed_addr #0 {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %6, %1 ]
%3 = trunc i64 %2 to i8
%4 = sub i8 100, %3
%5 = getelementptr inbounds [100 x i8], [100 x i8]* @source, i64 0, i64 %2
store i8 %4, i8* %5, align 1, !tbaa !5
%6 = add nuw nsw i64 %2, 1
%7 = icmp eq i64 %6, 100
br i1 %7, label %8, label %1, !llvm.loop !11
8: ; preds = %1
%9 = load i8, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @target, i64 0, i64 0), align 16, !tbaa !5
store i8 %9, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @source, i64 0, i64 0), align 16, !tbaa !5
%10 = load i8, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @target, i64 0, i64 1), align 1, !tbaa !5
store i8 %10, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @source, i64 0, i64 1), align 1, !tbaa !5
%11 = load i8, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @target, i64 0, i64 2), align 2, !tbaa !5
store i8 %11, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @source, i64 0, i64 2), align 2, !tbaa !5
br label %12
12: ; preds = %8, %12
%13 = phi i32 [ 6, %8 ], [ %18, %12 ]
%14 = phi i8* [ getelementptr inbounds ([100 x i8], [100 x i8]* @source, i64 0, i64 0), %8 ], [ %33, %12 ]
%15 = phi i8* [ getelementptr inbounds ([100 x i8], [100 x i8]* @target, i64 0, i64 0), %8 ], [ %31, %12 ]
%16 = getelementptr inbounds i8, i8* %14, i64 3
%17 = getelementptr inbounds i8, i8* %15, i64 3
%18 = add nsw i32 %13, -1
%19 = getelementptr inbounds i8, i8* %15, i64 4
%20 = load i8, i8* %17, align 1, !tbaa !5
%21 = getelementptr inbounds i8, i8* %14, i64 4
store i8 %20, i8* %16, align 1, !tbaa !5
%22 = getelementptr inbounds i8, i8* %15, i64 5
%23 = load i8, i8* %19, align 1, !tbaa !5
%24 = getelementptr inbounds i8, i8* %14, i64 5
store i8 %23, i8* %21, align 1, !tbaa !5
%25 = getelementptr inbounds i8, i8* %15, i64 6
%26 = load i8, i8* %22, align 1, !tbaa !5
%27 = getelementptr inbounds i8, i8* %14, i64 6
store i8 %26, i8* %24, align 1, !tbaa !5
%28 = getelementptr inbounds i8, i8* %15, i64 7
%29 = load i8, i8* %25, align 1, !tbaa !5
%30 = getelementptr inbounds i8, i8* %14, i64 7
store i8 %29, i8* %27, align 1, !tbaa !5
%31 = getelementptr inbounds i8, i8* %15, i64 8
%32 = load i8, i8* %28, align 1, !tbaa !5
%33 = getelementptr inbounds i8, i8* %14, i64 8
store i8 %32, i8* %30, align 1, !tbaa !5
%34 = getelementptr inbounds i8, i8* %15, i64 9
%35 = load i8, i8* %31, align 1, !tbaa !5
%36 = getelementptr inbounds i8, i8* %14, i64 9
store i8 %35, i8* %33, align 1, !tbaa !5
%37 = getelementptr inbounds i8, i8* %15, i64 10
%38 = load i8, i8* %34, align 1, !tbaa !5
%39 = getelementptr inbounds i8, i8* %14, i64 10
store i8 %38, i8* %36, align 1, !tbaa !5
%40 = load i8, i8* %37, align 1, !tbaa !5
store i8 %40, i8* %39, align 1, !tbaa !5
%41 = icmp ugt i32 %13, 2
br i1 %41, label %12, label %42, !llvm.loop !8
42: ; preds = %12
ret void
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree norecurse nosync nounwind sspstrong uwtable writeonly "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !9, !10}

789
test/edn.ll Normal file
View File

@ -0,0 +1,789 @@
; ModuleID = 'edn.c'
source_filename = "edn.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@__const.main.a = private unnamed_addr constant [200 x i16] [i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024, i16 0, i16 2047, i16 3072, i16 2048, i16 512, i16 -2048, i16 -3328, i16 1024], align 16
@__const.main.b = private unnamed_addr constant [200 x i16] [i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096, i16 3168, i16 3136, i16 3104, i16 3072, i16 -2560, i16 -3072, i16 -3584, i16 -4096], align 16
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @vec_mpy1(i16* nocapture %0, i16* nocapture readonly %1, i16 signext %2) local_unnamed_addr #0 {
%4 = sext i16 %2 to i32
br label %5
5: ; preds = %3, %5
%6 = phi i64 [ 0, %3 ], [ %16, %5 ]
%7 = getelementptr inbounds i16, i16* %1, i64 %6
%8 = load i16, i16* %7, align 2, !tbaa !5
%9 = sext i16 %8 to i32
%10 = mul nsw i32 %9, %4
%11 = lshr i32 %10, 15
%12 = getelementptr inbounds i16, i16* %0, i64 %6
%13 = load i16, i16* %12, align 2, !tbaa !5
%14 = trunc i32 %11 to i16
%15 = add i16 %13, %14
store i16 %15, i16* %12, align 2, !tbaa !5
%16 = add nuw nsw i64 %6, 1
%17 = icmp eq i64 %16, 150
br i1 %17, label %18, label %5, !llvm.loop !9
18: ; preds = %5
ret void
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i64 @mac(i16* nocapture readonly %0, i16* nocapture readonly %1, i64 %2, i64* nocapture %3) local_unnamed_addr #0 {
%5 = load i64, i64* %3, align 8, !tbaa !12
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ %5, %4 ], [ %18, %6 ]
%8 = phi i64 [ 0, %4 ], [ %22, %6 ]
%9 = phi i64 [ %2, %4 ], [ %21, %6 ]
%10 = getelementptr inbounds i16, i16* %1, i64 %8
%11 = load i16, i16* %10, align 2, !tbaa !5
%12 = sext i16 %11 to i32
%13 = getelementptr inbounds i16, i16* %0, i64 %8
%14 = load i16, i16* %13, align 2, !tbaa !5
%15 = sext i16 %14 to i32
%16 = mul nsw i32 %15, %12
%17 = sext i32 %16 to i64
%18 = add nsw i64 %7, %17
%19 = mul nsw i32 %12, %12
%20 = zext i32 %19 to i64
%21 = add nsw i64 %9, %20
%22 = add nuw nsw i64 %8, 1
%23 = icmp eq i64 %22, 150
br i1 %23, label %24, label %6, !llvm.loop !14
24: ; preds = %6
store i64 %18, i64* %3, align 8, !tbaa !12
ret i64 %21
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @fir(i16* nocapture readonly %0, i16* nocapture readonly %1, i64* nocapture %2) local_unnamed_addr #0 {
br label %4
4: ; preds = %3, %20
%5 = phi i64 [ 0, %3 ], [ %23, %20 ]
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %17, %6 ]
%8 = phi i64 [ 0, %4 ], [ %18, %6 ]
%9 = add nuw nsw i64 %8, %5
%10 = getelementptr inbounds i16, i16* %0, i64 %9
%11 = load i16, i16* %10, align 2, !tbaa !5
%12 = sext i16 %11 to i64
%13 = getelementptr inbounds i16, i16* %1, i64 %8
%14 = load i16, i16* %13, align 2, !tbaa !5
%15 = sext i16 %14 to i64
%16 = mul nsw i64 %15, %12
%17 = add nsw i64 %16, %7
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, 50
br i1 %19, label %20, label %6, !llvm.loop !15
20: ; preds = %6
%21 = ashr i64 %17, 15
%22 = getelementptr inbounds i64, i64* %2, i64 %5
store i64 %21, i64* %22, align 8, !tbaa !12
%23 = add nuw nsw i64 %5, 1
%24 = icmp eq i64 %23, 50
br i1 %24, label %25, label %4, !llvm.loop !16
25: ; preds = %20
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @fir_no_red_ld(i16* nocapture readonly %0, i16* nocapture readonly %1, i64* nocapture %2) local_unnamed_addr #0 {
br label %4
4: ; preds = %3, %44
%5 = phi i64 [ 0, %3 ], [ %50, %44 ]
%6 = getelementptr inbounds i16, i16* %0, i64 %5
%7 = load i16, i16* %6, align 2, !tbaa !5
br label %8
8: ; preds = %4, %8
%9 = phi i64 [ 0, %4 ], [ %42, %8 ]
%10 = phi i64 [ 0, %4 ], [ %37, %8 ]
%11 = phi i16 [ %7, %4 ], [ %30, %8 ]
%12 = phi i64 [ 0, %4 ], [ %41, %8 ]
%13 = add nuw nsw i64 %9, %5
%14 = or i64 %13, 1
%15 = getelementptr inbounds i16, i16* %0, i64 %14
%16 = load i16, i16* %15, align 2, !tbaa !5
%17 = getelementptr inbounds i16, i16* %1, i64 %9
%18 = load i16, i16* %17, align 2, !tbaa !5
%19 = sext i16 %11 to i32
%20 = sext i16 %18 to i32
%21 = mul nsw i32 %20, %19
%22 = sext i32 %21 to i64
%23 = add nsw i64 %10, %22
%24 = sext i16 %16 to i32
%25 = mul nsw i32 %20, %24
%26 = sext i32 %25 to i64
%27 = add nsw i64 %12, %26
%28 = add nuw nsw i64 %13, 2
%29 = getelementptr inbounds i16, i16* %0, i64 %28
%30 = load i16, i16* %29, align 2, !tbaa !5
%31 = or i64 %9, 1
%32 = getelementptr inbounds i16, i16* %1, i64 %31
%33 = load i16, i16* %32, align 2, !tbaa !5
%34 = sext i16 %33 to i32
%35 = mul nsw i32 %34, %24
%36 = sext i32 %35 to i64
%37 = add nsw i64 %23, %36
%38 = sext i16 %30 to i32
%39 = mul nsw i32 %34, %38
%40 = sext i32 %39 to i64
%41 = add nsw i64 %27, %40
%42 = add nuw nsw i64 %9, 2
%43 = icmp ult i64 %9, 30
br i1 %43, label %8, label %44, !llvm.loop !17
44: ; preds = %8
%45 = ashr i64 %37, 15
%46 = getelementptr inbounds i64, i64* %2, i64 %5
store i64 %45, i64* %46, align 8, !tbaa !12
%47 = ashr i64 %41, 15
%48 = or i64 %5, 1
%49 = getelementptr inbounds i64, i64* %2, i64 %48
store i64 %47, i64* %49, align 8, !tbaa !12
%50 = add nuw nsw i64 %5, 2
%51 = icmp ult i64 %5, 98
br i1 %51, label %4, label %52, !llvm.loop !18
52: ; preds = %44
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i64 @latsynth(i16* nocapture %0, i16* nocapture readonly %1, i64 %2, i64 %3) local_unnamed_addr #0 {
%5 = add nsw i64 %2, -1
%6 = getelementptr inbounds i16, i16* %0, i64 %5
%7 = load i16, i16* %6, align 2, !tbaa !5
%8 = sext i16 %7 to i64
%9 = getelementptr inbounds i16, i16* %1, i64 %5
%10 = load i16, i16* %9, align 2, !tbaa !5
%11 = sext i16 %10 to i64
%12 = mul nsw i64 %11, %8
%13 = sub nsw i64 %3, %12
%14 = icmp sgt i64 %2, 1
br i1 %14, label %15, label %37
15: ; preds = %4
%16 = add nsw i64 %2, -2
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ %35, %17 ], [ %16, %15 ]
%19 = phi i64 [ %27, %17 ], [ %13, %15 ]
%20 = getelementptr inbounds i16, i16* %0, i64 %18
%21 = load i16, i16* %20, align 2, !tbaa !5
%22 = sext i16 %21 to i64
%23 = getelementptr inbounds i16, i16* %1, i64 %18
%24 = load i16, i16* %23, align 2, !tbaa !5
%25 = sext i16 %24 to i64
%26 = mul nsw i64 %25, %22
%27 = sub nsw i64 %19, %26
%28 = ashr i64 %27, 16
%29 = mul nsw i64 %28, %25
%30 = lshr i64 %29, 16
%31 = trunc i64 %30 to i16
%32 = add i16 %21, %31
%33 = add nsw i64 %18, 1
%34 = getelementptr inbounds i16, i16* %0, i64 %33
store i16 %32, i16* %34, align 2, !tbaa !5
%35 = add nsw i64 %18, -1
%36 = icmp sgt i64 %18, 0
br i1 %36, label %17, label %37, !llvm.loop !19
37: ; preds = %17, %4
%38 = phi i64 [ %13, %4 ], [ %27, %17 ]
%39 = lshr i64 %38, 16
%40 = trunc i64 %39 to i16
store i16 %40, i16* %0, align 2, !tbaa !5
ret i64 %38
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @iir1(i16* nocapture readonly %0, i16* nocapture readonly %1, i64* nocapture %2, i64* nocapture %3) local_unnamed_addr #0 {
%5 = load i16, i16* %1, align 2, !tbaa !5
%6 = sext i16 %5 to i64
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %38, %7 ]
%9 = phi i16* [ %0, %4 ], [ %36, %7 ]
%10 = phi i64 [ %6, %4 ], [ %35, %7 ]
%11 = phi i64* [ %3, %4 ], [ %37, %7 ]
%12 = getelementptr inbounds i16, i16* %9, i64 2
%13 = load i16, i16* %12, align 2, !tbaa !5
%14 = sext i16 %13 to i64
%15 = load i64, i64* %11, align 8, !tbaa !12
%16 = mul nsw i64 %15, %14
%17 = getelementptr inbounds i16, i16* %9, i64 3
%18 = load i16, i16* %17, align 2, !tbaa !5
%19 = sext i16 %18 to i64
%20 = getelementptr inbounds i64, i64* %11, i64 1
%21 = load i64, i64* %20, align 8, !tbaa !12
%22 = mul nsw i64 %21, %19
%23 = add nsw i64 %22, %16
%24 = ashr i64 %23, 15
%25 = add nsw i64 %24, %10
%26 = load i16, i16* %9, align 2, !tbaa !5
%27 = sext i16 %26 to i64
%28 = mul nsw i64 %15, %27
%29 = getelementptr inbounds i16, i16* %9, i64 1
%30 = load i16, i16* %29, align 2, !tbaa !5
%31 = sext i16 %30 to i64
%32 = mul nsw i64 %21, %31
%33 = add nsw i64 %32, %28
%34 = ashr i64 %33, 15
%35 = add nsw i64 %34, %25
store i64 %15, i64* %20, align 8, !tbaa !12
store i64 %25, i64* %11, align 8, !tbaa !12
%36 = getelementptr inbounds i16, i16* %9, i64 4
%37 = getelementptr inbounds i64, i64* %11, i64 2
%38 = add nuw nsw i64 %8, 1
%39 = icmp eq i64 %38, 50
br i1 %39, label %40, label %7, !llvm.loop !20
40: ; preds = %7
store i64 %35, i64* %2, align 8, !tbaa !12
ret void
}
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local i64 @codebook(i64 %0, i64 %1, i64 %2, i64 %3, i64 returned %4, i16* nocapture readnone %5, i16 signext %6, i16 signext %7) local_unnamed_addr #2 {
ret i64 %4
}
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local void @jpegdct(i16* nocapture %0, i16* nocapture readonly %1) local_unnamed_addr #3 {
%3 = alloca [12 x i64], align 16
%4 = bitcast [12 x i64]* %3 to i8*
call void @llvm.lifetime.start.p0i8(i64 96, i8* nonnull %4) #5
%5 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 0
%6 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 3
%7 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 8
%8 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 9
%9 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 1
%10 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 2
%11 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 10
%12 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 11
%13 = getelementptr inbounds i16, i16* %1, i64 10
%14 = getelementptr inbounds i16, i16* %1, i64 9
%15 = getelementptr inbounds i16, i16* %1, i64 11
%16 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 4
%17 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 7
%18 = getelementptr inbounds i16, i16* %1, i64 2
%19 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 5
%20 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 6
%21 = getelementptr inbounds i16, i16* %1, i64 8
%22 = getelementptr inbounds i16, i16* %1, i64 1
%23 = getelementptr inbounds i16, i16* %1, i64 3
%24 = getelementptr inbounds i16, i16* %1, i64 4
%25 = getelementptr inbounds i16, i16* %1, i64 6
%26 = getelementptr inbounds i16, i16* %1, i64 5
%27 = getelementptr inbounds i16, i16* %1, i64 7
br label %28
28: ; preds = %2, %204
%29 = phi i64 [ 13, %2 ], [ %207, %204 ]
%30 = phi i64 [ 0, %2 ], [ %206, %204 ]
%31 = phi i64 [ 8, %2 ], [ %208, %204 ]
%32 = phi i32 [ 1, %2 ], [ %210, %204 ]
%33 = phi i16* [ %0, %2 ], [ %209, %204 ]
%34 = shl nuw nsw i32 %32, 2
%35 = zext i32 %34 to i64
%36 = shl nuw nsw i32 %32, 1
%37 = zext i32 %36 to i64
%38 = mul nuw nsw i32 %32, 6
%39 = zext i32 %38 to i64
%40 = mul nuw nsw i32 %32, 7
%41 = zext i32 %40 to i64
%42 = mul nuw nsw i32 %32, 5
%43 = zext i32 %42 to i64
%44 = mul nuw nsw i32 %32, 3
%45 = zext i32 %44 to i64
%46 = zext i32 %32 to i64
%47 = zext i32 %32 to i64
%48 = zext i32 %32 to i64
%49 = trunc i64 %29 to i32
%50 = trunc i64 %29 to i32
%51 = trunc i64 %29 to i32
%52 = trunc i64 %29 to i32
br label %53
53: ; preds = %28, %73
%54 = phi i16 [ 0, %28 ], [ %201, %73 ]
%55 = phi i16* [ %33, %28 ], [ %202, %73 ]
br label %56
56: ; preds = %53, %56
%57 = phi i64 [ 0, %53 ], [ %71, %56 ]
%58 = mul nuw nsw i64 %57, %47
%59 = getelementptr inbounds i16, i16* %55, i64 %58
%60 = load i16, i16* %59, align 2, !tbaa !5
%61 = sext i16 %60 to i64
%62 = sub nuw nsw i64 7, %57
%63 = mul nsw i64 %62, %48
%64 = getelementptr inbounds i16, i16* %55, i64 %63
%65 = load i16, i16* %64, align 2, !tbaa !5
%66 = sext i16 %65 to i64
%67 = add nsw i64 %66, %61
%68 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 %57
store i64 %67, i64* %68, align 8, !tbaa !12
%69 = sub nsw i64 %61, %66
%70 = getelementptr inbounds [12 x i64], [12 x i64]* %3, i64 0, i64 %62
store i64 %69, i64* %70, align 8, !tbaa !12
%71 = add nuw nsw i64 %57, 1
%72 = icmp eq i64 %71, 4
br i1 %72, label %73, label %56, !llvm.loop !21
73: ; preds = %56
%74 = load i64, i64* %5, align 16, !tbaa !12
%75 = load i64, i64* %6, align 8, !tbaa !12
%76 = add nsw i64 %75, %74
store i64 %76, i64* %7, align 16, !tbaa !12
%77 = sub nsw i64 %74, %75
store i64 %77, i64* %8, align 8, !tbaa !12
%78 = load i64, i64* %9, align 8, !tbaa !12
%79 = load i64, i64* %10, align 16, !tbaa !12
%80 = add nsw i64 %79, %78
store i64 %80, i64* %11, align 16, !tbaa !12
%81 = sub nsw i64 %78, %79
store i64 %81, i64* %12, align 8, !tbaa !12
%82 = add nsw i64 %80, %76
%83 = ashr i64 %82, %30
%84 = trunc i64 %83 to i16
store i16 %84, i16* %55, align 2, !tbaa !5
%85 = sub nsw i64 %76, %80
%86 = ashr i64 %85, %30
%87 = trunc i64 %86 to i16
%88 = getelementptr inbounds i16, i16* %55, i64 %35
store i16 %87, i16* %88, align 2, !tbaa !5
%89 = add nsw i64 %81, %77
%90 = trunc i64 %89 to i32
%91 = shl i32 %90, 16
%92 = ashr exact i32 %91, 16
%93 = load i16, i16* %13, align 2, !tbaa !5
%94 = sext i16 %93 to i32
%95 = mul nsw i32 %92, %94
%96 = sext i32 %95 to i64
store i64 %96, i64* %7, align 16, !tbaa !12
%97 = load i16, i16* %14, align 2, !tbaa !5
%98 = sext i16 %97 to i64
%99 = mul nsw i64 %77, %98
%100 = ashr i64 %99, %29
%101 = add i64 %100, %96
%102 = trunc i64 %101 to i16
%103 = getelementptr inbounds i16, i16* %55, i64 %37
store i16 %102, i16* %103, align 2, !tbaa !5
%104 = load i16, i16* %15, align 2, !tbaa !5
%105 = sext i16 %104 to i64
%106 = mul nsw i64 %81, %105
%107 = ashr i64 %106, %29
%108 = add i64 %107, %96
%109 = trunc i64 %108 to i16
%110 = getelementptr inbounds i16, i16* %55, i64 %39
store i16 %109, i16* %110, align 2, !tbaa !5
%111 = load i64, i64* %16, align 16, !tbaa !12
%112 = load i64, i64* %17, align 8, !tbaa !12
%113 = add nsw i64 %112, %111
%114 = trunc i64 %113 to i32
%115 = shl i32 %114, 16
%116 = ashr exact i32 %115, 16
%117 = load i16, i16* %18, align 2, !tbaa !5
%118 = sext i16 %117 to i32
%119 = mul nsw i32 %116, %118
%120 = sext i32 %119 to i64
store i64 %120, i64* %5, align 16, !tbaa !12
%121 = load i64, i64* %19, align 8, !tbaa !12
%122 = load i64, i64* %20, align 16, !tbaa !12
%123 = add nsw i64 %122, %121
%124 = trunc i64 %123 to i32
%125 = shl i32 %124, 16
%126 = ashr exact i32 %125, 16
%127 = load i16, i16* %1, align 2, !tbaa !5
%128 = sext i16 %127 to i32
%129 = mul nsw i32 %126, %128
%130 = sext i32 %129 to i64
store i64 %130, i64* %9, align 8, !tbaa !12
%131 = add nsw i64 %122, %111
store i64 %131, i64* %10, align 16, !tbaa !12
%132 = add nsw i64 %121, %112
store i64 %132, i64* %6, align 8, !tbaa !12
%133 = add nsw i64 %131, %132
%134 = trunc i64 %133 to i32
%135 = shl i32 %134, 16
%136 = ashr exact i32 %135, 16
%137 = load i16, i16* %21, align 2, !tbaa !5
%138 = sext i16 %137 to i32
%139 = mul nsw i32 %136, %138
%140 = sext i32 %139 to i64
store i64 %140, i64* %7, align 16, !tbaa !12
%141 = trunc i64 %131 to i32
%142 = shl i32 %141, 16
%143 = ashr exact i32 %142, 16
%144 = load i16, i16* %22, align 2, !tbaa !5
%145 = sext i16 %144 to i32
%146 = mul nsw i32 %143, %145
%147 = sext i32 %146 to i64
%148 = add nsw i64 %147, %140
store i64 %148, i64* %10, align 16, !tbaa !12
%149 = trunc i64 %132 to i32
%150 = shl i32 %149, 16
%151 = ashr exact i32 %150, 16
%152 = load i16, i16* %23, align 2, !tbaa !5
%153 = sext i16 %152 to i32
%154 = mul nsw i32 %151, %153
%155 = sext i32 %154 to i64
%156 = add nsw i64 %155, %140
store i64 %156, i64* %6, align 8, !tbaa !12
%157 = load i16, i16* %24, align 2, !tbaa !5
%158 = zext i16 %157 to i64
%159 = mul i64 %111, %158
%160 = add nsw i64 %148, %120
%161 = add i64 %160, %159
%162 = trunc i64 %161 to i32
%163 = shl i32 %162, 16
%164 = ashr exact i32 %163, 16
%165 = ashr i32 %164, %49
%166 = trunc i32 %165 to i16
%167 = getelementptr inbounds i16, i16* %55, i64 %41
store i16 %166, i16* %167, align 2, !tbaa !5
%168 = load i16, i16* %25, align 2, !tbaa !5
%169 = zext i16 %168 to i64
%170 = mul i64 %121, %169
%171 = add nsw i64 %156, %130
%172 = add i64 %171, %170
%173 = trunc i64 %172 to i32
%174 = shl i32 %173, 16
%175 = ashr exact i32 %174, 16
%176 = ashr i32 %175, %50
%177 = trunc i32 %176 to i16
%178 = getelementptr inbounds i16, i16* %55, i64 %43
store i16 %177, i16* %178, align 2, !tbaa !5
%179 = load i16, i16* %26, align 2, !tbaa !5
%180 = zext i16 %179 to i64
%181 = mul i64 %122, %180
%182 = add nsw i64 %148, %130
%183 = add i64 %182, %181
%184 = trunc i64 %183 to i32
%185 = shl i32 %184, 16
%186 = ashr exact i32 %185, 16
%187 = ashr i32 %186, %51
%188 = trunc i32 %187 to i16
%189 = getelementptr inbounds i16, i16* %55, i64 %45
store i16 %188, i16* %189, align 2, !tbaa !5
%190 = load i16, i16* %27, align 2, !tbaa !5
%191 = zext i16 %190 to i64
%192 = mul i64 %112, %191
%193 = add nsw i64 %156, %120
%194 = add i64 %193, %192
%195 = trunc i64 %194 to i32
%196 = shl i32 %195, 16
%197 = ashr exact i32 %196, 16
%198 = ashr i32 %197, %52
%199 = trunc i32 %198 to i16
%200 = getelementptr inbounds i16, i16* %55, i64 %46
store i16 %199, i16* %200, align 2, !tbaa !5
%201 = add nuw nsw i16 %54, 1
%202 = getelementptr inbounds i16, i16* %55, i64 %31
%203 = icmp eq i16 %201, 8
br i1 %203, label %204, label %53, !llvm.loop !22
204: ; preds = %73
%205 = add nuw nsw i32 %32, 7
%206 = add nuw nsw i64 %30, 3
%207 = add nuw nsw i64 %29, 3
%208 = add nsw i64 %31, -7
%209 = getelementptr inbounds i16, i16* %202, i64 -64
%210 = and i32 %205, 65535
%211 = icmp ult i32 %210, 9
br i1 %211, label %28, label %212, !llvm.loop !23
212: ; preds = %204
call void @llvm.lifetime.end.p0i8(i64 96, i8* nonnull %4) #5
ret void
}
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
%1 = alloca [200 x i16], align 16
%2 = alloca [200 x i16], align 16
%3 = alloca [200 x i64], align 16
%4 = bitcast [200 x i16]* %1 to i8*
call void @llvm.lifetime.start.p0i8(i64 400, i8* nonnull %4) #5
call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 16 dereferenceable(400) %4, i8* noundef nonnull align 16 dereferenceable(400) bitcast ([200 x i16]* @__const.main.a to i8*), i64 400, i1 false)
%5 = bitcast [200 x i16]* %2 to i8*
call void @llvm.lifetime.start.p0i8(i64 400, i8* nonnull %5) #5
call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 16 dereferenceable(400) %5, i8* noundef nonnull align 16 dereferenceable(400) bitcast ([200 x i16]* @__const.main.b to i8*), i64 400, i1 false)
%6 = bitcast [200 x i64]* %3 to i8*
call void @llvm.lifetime.start.p0i8(i64 1600, i8* nonnull %6) #5
%7 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 0
br label %8
8: ; preds = %8, %0
%9 = phi i64 [ 0, %0 ], [ %19, %8 ]
%10 = getelementptr inbounds [200 x i16], [200 x i16]* %2, i64 0, i64 %9
%11 = load i16, i16* %10, align 2, !tbaa !5
%12 = sext i16 %11 to i32
%13 = mul nsw i32 %12, 3
%14 = lshr i32 %13, 15
%15 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 %9
%16 = load i16, i16* %15, align 2, !tbaa !5
%17 = trunc i32 %14 to i16
%18 = add i16 %16, %17
store i16 %18, i16* %15, align 2, !tbaa !5
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, 150
br i1 %20, label %21, label %8, !llvm.loop !9
21: ; preds = %8
%22 = getelementptr inbounds [200 x i64], [200 x i64]* %3, i64 0, i64 0
%23 = load i64, i64* %22, align 16, !tbaa !12
br label %24
24: ; preds = %24, %21
%25 = phi i64 [ %23, %21 ], [ %34, %24 ]
%26 = phi i64 [ 0, %21 ], [ %35, %24 ]
%27 = getelementptr inbounds [200 x i16], [200 x i16]* %2, i64 0, i64 %26
%28 = load i16, i16* %27, align 2, !tbaa !5
%29 = sext i16 %28 to i64
%30 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 %26
%31 = load i16, i16* %30, align 2, !tbaa !5
%32 = sext i16 %31 to i64
%33 = mul nsw i64 %32, %29
%34 = add nsw i64 %33, %25
%35 = add nuw nsw i64 %26, 1
%36 = icmp eq i64 %35, 150
br i1 %36, label %37, label %24, !llvm.loop !14
37: ; preds = %24
store i64 %34, i64* %22, align 16, !tbaa !12
br label %38
38: ; preds = %54, %37
%39 = phi i64 [ 0, %37 ], [ %57, %54 ]
br label %40
40: ; preds = %40, %38
%41 = phi i64 [ 0, %38 ], [ %51, %40 ]
%42 = phi i64 [ 0, %38 ], [ %52, %40 ]
%43 = add nuw nsw i64 %42, %39
%44 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 %43
%45 = load i16, i16* %44, align 2, !tbaa !5
%46 = sext i16 %45 to i64
%47 = getelementptr inbounds [200 x i16], [200 x i16]* %2, i64 0, i64 %42
%48 = load i16, i16* %47, align 2, !tbaa !5
%49 = sext i16 %48 to i64
%50 = mul nsw i64 %49, %46
%51 = add nsw i64 %50, %41
%52 = add nuw nsw i64 %42, 1
%53 = icmp eq i64 %52, 50
br i1 %53, label %54, label %40, !llvm.loop !15
54: ; preds = %40
%55 = ashr i64 %51, 15
%56 = getelementptr inbounds [200 x i64], [200 x i64]* %3, i64 0, i64 %39
store i64 %55, i64* %56, align 8, !tbaa !12
%57 = add nuw nsw i64 %39, 1
%58 = icmp eq i64 %57, 50
br i1 %58, label %59, label %38, !llvm.loop !16
59: ; preds = %54, %99
%60 = phi i64 [ %105, %99 ], [ 0, %54 ]
%61 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 %60
%62 = load i16, i16* %61, align 4, !tbaa !5
br label %63
63: ; preds = %63, %59
%64 = phi i64 [ 0, %59 ], [ %97, %63 ]
%65 = phi i64 [ 0, %59 ], [ %92, %63 ]
%66 = phi i16 [ %62, %59 ], [ %85, %63 ]
%67 = phi i64 [ 0, %59 ], [ %96, %63 ]
%68 = add nuw nsw i64 %64, %60
%69 = or i64 %68, 1
%70 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 %69
%71 = load i16, i16* %70, align 2, !tbaa !5
%72 = getelementptr inbounds [200 x i16], [200 x i16]* %2, i64 0, i64 %64
%73 = load i16, i16* %72, align 4, !tbaa !5
%74 = sext i16 %66 to i32
%75 = sext i16 %73 to i32
%76 = mul nsw i32 %75, %74
%77 = sext i32 %76 to i64
%78 = add nsw i64 %65, %77
%79 = sext i16 %71 to i32
%80 = mul nsw i32 %75, %79
%81 = sext i32 %80 to i64
%82 = add nsw i64 %67, %81
%83 = add nuw nsw i64 %68, 2
%84 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 %83
%85 = load i16, i16* %84, align 4, !tbaa !5
%86 = or i64 %64, 1
%87 = getelementptr inbounds [200 x i16], [200 x i16]* %2, i64 0, i64 %86
%88 = load i16, i16* %87, align 2, !tbaa !5
%89 = sext i16 %88 to i32
%90 = mul nsw i32 %89, %79
%91 = sext i32 %90 to i64
%92 = add nsw i64 %78, %91
%93 = sext i16 %85 to i32
%94 = mul nsw i32 %89, %93
%95 = sext i32 %94 to i64
%96 = add nsw i64 %82, %95
%97 = add nuw nsw i64 %64, 2
%98 = icmp ult i64 %64, 30
br i1 %98, label %63, label %99, !llvm.loop !17
99: ; preds = %63
%100 = ashr i64 %92, 15
%101 = getelementptr inbounds [200 x i64], [200 x i64]* %3, i64 0, i64 %60
store i64 %100, i64* %101, align 16, !tbaa !12
%102 = ashr i64 %96, 15
%103 = or i64 %60, 1
%104 = getelementptr inbounds [200 x i64], [200 x i64]* %3, i64 0, i64 %103
store i64 %102, i64* %104, align 8, !tbaa !12
%105 = add nuw nsw i64 %60, 2
%106 = icmp ult i64 %60, 98
br i1 %106, label %59, label %107, !llvm.loop !18
107: ; preds = %99
%108 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 99
%109 = load i16, i16* %108, align 2, !tbaa !5
%110 = sext i16 %109 to i64
%111 = getelementptr inbounds [200 x i16], [200 x i16]* %2, i64 0, i64 99
%112 = load i16, i16* %111, align 2, !tbaa !5
%113 = sext i16 %112 to i64
%114 = mul nsw i64 %113, %110
%115 = sub nsw i64 43690, %114
br label %116
116: ; preds = %116, %107
%117 = phi i64 [ %134, %116 ], [ 98, %107 ]
%118 = phi i64 [ %126, %116 ], [ %115, %107 ]
%119 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 %117
%120 = load i16, i16* %119, align 2, !tbaa !5
%121 = sext i16 %120 to i64
%122 = getelementptr inbounds [200 x i16], [200 x i16]* %2, i64 0, i64 %117
%123 = load i16, i16* %122, align 2, !tbaa !5
%124 = sext i16 %123 to i64
%125 = mul nsw i64 %124, %121
%126 = sub nsw i64 %118, %125
%127 = ashr i64 %126, 16
%128 = mul nsw i64 %127, %124
%129 = lshr i64 %128, 16
%130 = trunc i64 %129 to i16
%131 = add i16 %120, %130
%132 = add nuw nsw i64 %117, 1
%133 = getelementptr inbounds [200 x i16], [200 x i16]* %1, i64 0, i64 %132
store i16 %131, i16* %133, align 2, !tbaa !5
%134 = add nsw i64 %117, -1
%135 = icmp eq i64 %117, 0
br i1 %135, label %136, label %116, !llvm.loop !19
136: ; preds = %116
%137 = getelementptr inbounds [200 x i16], [200 x i16]* %2, i64 0, i64 0
%138 = lshr i64 %126, 16
%139 = trunc i64 %138 to i16
store i16 %139, i16* %7, align 16, !tbaa !5
%140 = load i16, i16* %137, align 16, !tbaa !5
%141 = sext i16 %140 to i64
br label %142
142: ; preds = %142, %136
%143 = phi i64 [ 0, %136 ], [ %173, %142 ]
%144 = phi i16* [ %7, %136 ], [ %171, %142 ]
%145 = phi i64 [ %141, %136 ], [ %170, %142 ]
%146 = phi i64* [ %22, %136 ], [ %172, %142 ]
%147 = getelementptr inbounds i16, i16* %144, i64 2
%148 = load i16, i16* %147, align 2, !tbaa !5
%149 = sext i16 %148 to i64
%150 = load i64, i64* %146, align 8, !tbaa !12
%151 = mul nsw i64 %150, %149
%152 = getelementptr inbounds i16, i16* %144, i64 3
%153 = load i16, i16* %152, align 2, !tbaa !5
%154 = sext i16 %153 to i64
%155 = getelementptr inbounds i64, i64* %146, i64 1
%156 = load i64, i64* %155, align 8, !tbaa !12
%157 = mul nsw i64 %156, %154
%158 = add nsw i64 %157, %151
%159 = ashr i64 %158, 15
%160 = add nsw i64 %159, %145
%161 = load i16, i16* %144, align 2, !tbaa !5
%162 = sext i16 %161 to i64
%163 = mul nsw i64 %150, %162
%164 = getelementptr inbounds i16, i16* %144, i64 1
%165 = load i16, i16* %164, align 2, !tbaa !5
%166 = sext i16 %165 to i64
%167 = mul nsw i64 %156, %166
%168 = add nsw i64 %167, %163
%169 = ashr i64 %168, 15
%170 = add nsw i64 %169, %160
store i64 %150, i64* %155, align 8, !tbaa !12
store i64 %160, i64* %146, align 8, !tbaa !12
%171 = getelementptr inbounds i16, i16* %144, i64 4
%172 = getelementptr inbounds i64, i64* %146, i64 2
%173 = add nuw nsw i64 %143, 1
%174 = icmp eq i64 %173, 50
br i1 %174, label %175, label %142, !llvm.loop !20
175: ; preds = %142
%176 = getelementptr inbounds [200 x i64], [200 x i64]* %3, i64 0, i64 100
store i64 %170, i64* %176, align 16, !tbaa !12
call void @jpegdct(i16* nonnull %7, i16* nonnull %137)
call void @llvm.lifetime.end.p0i8(i64 1600, i8* nonnull %6) #5
call void @llvm.lifetime.end.p0i8(i64 400, i8* nonnull %5) #5
call void @llvm.lifetime.end.p0i8(i64 400, i8* nonnull %4) #5
ret i32 0
}
; Function Attrs: argmemonly mustprogress nofree nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #4
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
attributes #2 = { nofree norecurse nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { argmemonly mustprogress nofree nounwind willreturn }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = distinct !{!14, !10, !11}
!15 = distinct !{!15, !10, !11}
!16 = distinct !{!16, !10, !11}
!17 = distinct !{!17, !10, !11}
!18 = distinct !{!18, !10, !11}
!19 = distinct !{!19, !10, !11}
!20 = distinct !{!20, !10, !11}
!21 = distinct !{!21, !10, !11}
!22 = distinct !{!22, !10, !11}
!23 = distinct !{!23, !10, !11}

140
test/expint.ll Normal file
View File

@ -0,0 +1,140 @@
; ModuleID = 'expint.c'
source_filename = "expint.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local void @main() local_unnamed_addr #0 {
ret void
}
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local i64 @expint(i32 %0, i64 %1) local_unnamed_addr #0 {
%3 = add nsw i32 %0, -1
%4 = icmp sgt i64 %1, 1
br i1 %4, label %5, label %36
5: ; preds = %2
%6 = sext i32 %0 to i64
%7 = add nsw i64 %6, %1
br label %12
8: ; preds = %12
%9 = add nuw nsw i64 %13, 1
%10 = add nuw nsw i32 %18, 1
%11 = icmp eq i64 %9, 101
br i1 %11, label %82, label %12, !llvm.loop !5
12: ; preds = %5, %8
%13 = phi i64 [ 1, %5 ], [ %9, %8 ]
%14 = phi i64 [ 30000000, %5 ], [ %31, %8 ]
%15 = phi i64 [ 30000000, %5 ], [ %27, %8 ]
%16 = phi i64 [ 2000000, %5 ], [ %29, %8 ]
%17 = phi i64 [ %7, %5 ], [ %24, %8 ]
%18 = phi i32 [ 1, %5 ], [ %10, %8 ]
%19 = add nsw i32 %18, %3
%20 = trunc i64 %13 to i32
%21 = mul i32 %19, %20
%22 = sub i32 0, %21
%23 = sext i32 %22 to i64
%24 = add nsw i64 %17, 2
%25 = mul nsw i64 %15, %23
%26 = add nsw i64 %25, %24
%27 = mul nsw i64 %26, 10
%28 = sdiv i64 %23, %16
%29 = add nsw i64 %28, %24
%30 = mul nsw i64 %29, %27
%31 = mul nsw i64 %30, %14
%32 = icmp slt i64 %30, 10000
br i1 %32, label %33, label %8
33: ; preds = %12
%34 = mul i64 %31, %1
%35 = sub i64 0, %34
br label %82
36: ; preds = %2
%37 = icmp eq i32 %3, 0
%38 = select i1 %37, i64 1000, i64 2
%39 = icmp sgt i32 %0, 1
%40 = add i64 %1, 8
%41 = mul i64 %40, %1
%42 = sub nsw i64 4, %1
%43 = shl i64 %41, %42
%44 = sext i32 %3 to i64
%45 = add nsw i64 %44, 2
%46 = add i32 %0, -2
%47 = zext i32 %46 to i64
%48 = mul i64 %45, %47
%49 = add i64 %48, %44
%50 = zext i32 %46 to i64
%51 = add i32 %0, -3
%52 = zext i32 %51 to i64
%53 = mul nuw i64 %50, %52
%54 = lshr i64 %53, 1
%55 = add i64 %49, %54
%56 = add i64 %55, 256
%57 = zext i32 %3 to i64
%58 = select i1 %39, i64 %56, i64 255
br label %59
59: ; preds = %36, %77
%60 = phi i64 [ 1, %36 ], [ %80, %77 ]
%61 = phi i64 [ %38, %36 ], [ %79, %77 ]
%62 = phi i64 [ 1, %36 ], [ %65, %77 ]
%63 = phi i64 [ -1, %36 ], [ %66, %77 ]
%64 = sdiv i64 %1, %60
%65 = mul i64 %64, %63
%66 = mul i64 %64, %62
%67 = icmp eq i64 %60, %57
br i1 %67, label %68, label %71
68: ; preds = %59
%69 = mul nsw i64 %65, %43
%70 = add nsw i64 %58, %69
br label %77
71: ; preds = %59
%72 = trunc i64 %60 to i32
%73 = sub nsw i32 %72, %3
%74 = sext i32 %73 to i64
%75 = sdiv i64 %65, %74
%76 = sub nsw i64 0, %75
br label %77
77: ; preds = %68, %71
%78 = phi i64 [ %76, %71 ], [ %70, %68 ]
%79 = add nsw i64 %78, %61
%80 = add nuw nsw i64 %60, 1
%81 = icmp eq i64 %80, 101
br i1 %81, label %82, label %59, !llvm.loop !8
82: ; preds = %77, %8, %33
%83 = phi i64 [ %35, %33 ], [ undef, %8 ], [ %79, %77 ]
ret i64 %83
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn
define dso_local i64 @foo(i64 %0) local_unnamed_addr #1 {
%2 = add i64 %0, 8
%3 = mul i64 %2, %0
%4 = sub nsw i64 4, %0
%5 = shl i64 %3, %4
ret i64 %5
}
attributes #0 = { nofree norecurse nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.unroll.disable"}
!8 = distinct !{!8, !6, !7}

257
test/fdct.ll Normal file
View File

@ -0,0 +1,257 @@
; ModuleID = 'fdct.c'
source_filename = "fdct.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@block = dso_local global [64 x i16] [i16 99, i16 104, i16 109, i16 113, i16 115, i16 115, i16 55, i16 55, i16 104, i16 111, i16 113, i16 116, i16 119, i16 56, i16 56, i16 56, i16 110, i16 115, i16 120, i16 119, i16 118, i16 56, i16 56, i16 56, i16 119, i16 121, i16 122, i16 120, i16 120, i16 59, i16 59, i16 59, i16 119, i16 120, i16 121, i16 122, i16 122, i16 55, i16 55, i16 55, i16 121, i16 121, i16 121, i16 121, i16 60, i16 57, i16 57, i16 57, i16 122, i16 122, i16 61, i16 63, i16 62, i16 57, i16 57, i16 57, i16 62, i16 62, i16 61, i16 61, i16 63, i16 58, i16 58, i16 58], align 16
@out = dso_local local_unnamed_addr global i32 0, align 4
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @fdct(i16* nocapture %0, i32 %1) local_unnamed_addr #0 {
%3 = sext i32 %1 to i64
br label %18
4: ; preds = %18
%5 = mul nsw i32 %1, 7
%6 = sext i32 %5 to i64
%7 = sext i32 %1 to i64
%8 = mul nsw i32 %1, 6
%9 = sext i32 %8 to i64
%10 = shl nsw i32 %1, 1
%11 = sext i32 %10 to i64
%12 = mul nsw i32 %1, 5
%13 = sext i32 %12 to i64
%14 = mul nsw i32 %1, 3
%15 = sext i32 %14 to i64
%16 = shl nsw i32 %1, 2
%17 = sext i32 %16 to i64
br label %107
18: ; preds = %2, %18
%19 = phi i16* [ %0, %2 ], [ %104, %18 ]
%20 = phi i32 [ 0, %2 ], [ %105, %18 ]
%21 = load i16, i16* %19, align 2, !tbaa !5
%22 = sext i16 %21 to i32
%23 = getelementptr inbounds i16, i16* %19, i64 7
%24 = load i16, i16* %23, align 2, !tbaa !5
%25 = sext i16 %24 to i32
%26 = add nsw i32 %25, %22
%27 = sub nsw i32 %22, %25
%28 = getelementptr inbounds i16, i16* %19, i64 1
%29 = load i16, i16* %28, align 2, !tbaa !5
%30 = sext i16 %29 to i32
%31 = getelementptr inbounds i16, i16* %19, i64 6
%32 = load i16, i16* %31, align 2, !tbaa !5
%33 = sext i16 %32 to i32
%34 = add nsw i32 %33, %30
%35 = sub nsw i32 %30, %33
%36 = getelementptr inbounds i16, i16* %19, i64 2
%37 = load i16, i16* %36, align 2, !tbaa !5
%38 = sext i16 %37 to i32
%39 = getelementptr inbounds i16, i16* %19, i64 5
%40 = load i16, i16* %39, align 2, !tbaa !5
%41 = sext i16 %40 to i32
%42 = add nsw i32 %41, %38
%43 = sub nsw i32 %38, %41
%44 = getelementptr inbounds i16, i16* %19, i64 3
%45 = load i16, i16* %44, align 2, !tbaa !5
%46 = sext i16 %45 to i32
%47 = getelementptr inbounds i16, i16* %19, i64 4
%48 = load i16, i16* %47, align 2, !tbaa !5
%49 = sext i16 %48 to i32
%50 = add nsw i32 %49, %46
%51 = sub nsw i32 %46, %49
%52 = add nsw i32 %50, %26
%53 = sub nsw i32 %26, %50
%54 = add nsw i32 %42, %34
%55 = sub nsw i32 %34, %42
%56 = add nsw i32 %52, %54
%57 = trunc i32 %56 to i16
%58 = shl i16 %57, 2
store i16 %58, i16* %19, align 2, !tbaa !5
%59 = sub nsw i32 %52, %54
%60 = trunc i32 %59 to i16
%61 = shl i16 %60, 2
store i16 %61, i16* %47, align 2, !tbaa !5
%62 = add nsw i32 %53, %55
%63 = mul nsw i32 %62, 4433
%64 = mul nsw i32 %53, 6270
%65 = add nsw i32 %63, %64
%66 = lshr i32 %65, 11
%67 = trunc i32 %66 to i16
store i16 %67, i16* %36, align 2, !tbaa !5
%68 = mul nsw i32 %55, -15137
%69 = add nsw i32 %63, %68
%70 = lshr i32 %69, 11
%71 = trunc i32 %70 to i16
store i16 %71, i16* %31, align 2, !tbaa !5
%72 = add nsw i32 %51, %27
%73 = add nsw i32 %43, %35
%74 = add nsw i32 %51, %35
%75 = add nsw i32 %43, %27
%76 = add nsw i32 %74, %75
%77 = mul nsw i32 %76, 9633
%78 = mul nsw i32 %51, 2446
%79 = mul nsw i32 %43, 16819
%80 = mul nsw i32 %35, 25172
%81 = mul nsw i32 %27, 12299
%82 = mul nsw i32 %72, -7373
%83 = mul nsw i32 %73, -20995
%84 = mul nsw i32 %74, -16069
%85 = mul nsw i32 %75, -3196
%86 = add nsw i32 %77, %84
%87 = add nsw i32 %77, %85
%88 = add nsw i32 %82, %78
%89 = add nsw i32 %88, %86
%90 = lshr i32 %89, 11
%91 = trunc i32 %90 to i16
store i16 %91, i16* %23, align 2, !tbaa !5
%92 = add nsw i32 %83, %79
%93 = add nsw i32 %92, %87
%94 = lshr i32 %93, 11
%95 = trunc i32 %94 to i16
store i16 %95, i16* %39, align 2, !tbaa !5
%96 = add nsw i32 %83, %80
%97 = add nsw i32 %96, %86
%98 = lshr i32 %97, 11
%99 = trunc i32 %98 to i16
store i16 %99, i16* %44, align 2, !tbaa !5
%100 = add nsw i32 %82, %81
%101 = add nsw i32 %100, %87
%102 = lshr i32 %101, 11
%103 = trunc i32 %102 to i16
store i16 %103, i16* %28, align 2, !tbaa !5
%104 = getelementptr inbounds i16, i16* %19, i64 %3
%105 = add nuw nsw i32 %20, 1
%106 = icmp eq i32 %105, 8
br i1 %106, label %4, label %18, !llvm.loop !9
107: ; preds = %4, %107
%108 = phi i16* [ %0, %4 ], [ %193, %107 ]
%109 = phi i32 [ 0, %4 ], [ %194, %107 ]
%110 = load i16, i16* %108, align 2, !tbaa !5
%111 = sext i16 %110 to i32
%112 = getelementptr inbounds i16, i16* %108, i64 %6
%113 = load i16, i16* %112, align 2, !tbaa !5
%114 = sext i16 %113 to i32
%115 = add nsw i32 %114, %111
%116 = sub nsw i32 %111, %114
%117 = getelementptr inbounds i16, i16* %108, i64 %7
%118 = load i16, i16* %117, align 2, !tbaa !5
%119 = sext i16 %118 to i32
%120 = getelementptr inbounds i16, i16* %108, i64 %9
%121 = load i16, i16* %120, align 2, !tbaa !5
%122 = sext i16 %121 to i32
%123 = add nsw i32 %122, %119
%124 = sub nsw i32 %119, %122
%125 = getelementptr inbounds i16, i16* %108, i64 %11
%126 = load i16, i16* %125, align 2, !tbaa !5
%127 = sext i16 %126 to i32
%128 = getelementptr inbounds i16, i16* %108, i64 %13
%129 = load i16, i16* %128, align 2, !tbaa !5
%130 = sext i16 %129 to i32
%131 = add nsw i32 %130, %127
%132 = sub nsw i32 %127, %130
%133 = getelementptr inbounds i16, i16* %108, i64 %15
%134 = load i16, i16* %133, align 2, !tbaa !5
%135 = sext i16 %134 to i32
%136 = getelementptr inbounds i16, i16* %108, i64 %17
%137 = load i16, i16* %136, align 2, !tbaa !5
%138 = sext i16 %137 to i32
%139 = add nsw i32 %138, %135
%140 = sub nsw i32 %135, %138
%141 = add nsw i32 %139, %115
%142 = sub nsw i32 %115, %139
%143 = add nsw i32 %131, %123
%144 = sub nsw i32 %123, %131
%145 = add nsw i32 %141, %143
%146 = ashr i32 %145, 5
%147 = trunc i32 %146 to i16
store i16 %147, i16* %108, align 2, !tbaa !5
%148 = sub nsw i32 %141, %143
%149 = ashr i32 %148, 5
%150 = trunc i32 %149 to i16
store i16 %150, i16* %136, align 2, !tbaa !5
%151 = add nsw i32 %142, %144
%152 = mul nsw i32 %151, 4433
%153 = mul nsw i32 %142, 6270
%154 = add nsw i32 %152, %153
%155 = ashr i32 %154, 18
%156 = trunc i32 %155 to i16
store i16 %156, i16* %125, align 2, !tbaa !5
%157 = mul nsw i32 %144, -15137
%158 = add nsw i32 %152, %157
%159 = ashr i32 %158, 18
%160 = trunc i32 %159 to i16
store i16 %160, i16* %120, align 2, !tbaa !5
%161 = add nsw i32 %140, %116
%162 = add nsw i32 %132, %124
%163 = add nsw i32 %140, %124
%164 = add nsw i32 %132, %116
%165 = add nsw i32 %163, %164
%166 = mul nsw i32 %165, 9633
%167 = mul nsw i32 %140, 2446
%168 = mul nsw i32 %132, 16819
%169 = mul nsw i32 %124, 25172
%170 = mul nsw i32 %116, 12299
%171 = mul nsw i32 %161, -7373
%172 = mul nsw i32 %162, -20995
%173 = mul nsw i32 %163, -16069
%174 = mul nsw i32 %164, -3196
%175 = add nsw i32 %166, %173
%176 = add nsw i32 %166, %174
%177 = add nsw i32 %171, %167
%178 = add nsw i32 %177, %175
%179 = ashr i32 %178, 18
%180 = trunc i32 %179 to i16
store i16 %180, i16* %112, align 2, !tbaa !5
%181 = add nsw i32 %172, %168
%182 = add nsw i32 %181, %176
%183 = ashr i32 %182, 18
%184 = trunc i32 %183 to i16
store i16 %184, i16* %128, align 2, !tbaa !5
%185 = add nsw i32 %172, %169
%186 = add nsw i32 %185, %175
%187 = ashr i32 %186, 18
%188 = trunc i32 %187 to i16
store i16 %188, i16* %133, align 2, !tbaa !5
%189 = add nsw i32 %171, %170
%190 = add nsw i32 %189, %176
%191 = ashr i32 %190, 18
%192 = trunc i32 %191 to i16
store i16 %192, i16* %117, align 2, !tbaa !5
%193 = getelementptr inbounds i16, i16* %108, i64 1
%194 = add nuw nsw i32 %109, 1
%195 = icmp eq i32 %194, 8
br i1 %195, label %196, label %107, !llvm.loop !12
196: ; preds = %107
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
call void @fdct(i16* getelementptr inbounds ([64 x i16], [64 x i16]* @block, i64 0, i64 0), i32 8)
%1 = load i16, i16* getelementptr inbounds ([64 x i16], [64 x i16]* @block, i64 0, i64 0), align 16, !tbaa !5
%2 = sext i16 %1 to i32
ret i32 %2
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}

383
test/fft1.ll Normal file
View File

@ -0,0 +1,383 @@
; ModuleID = 'fft1.c'
source_filename = "fft1.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@ai = dso_local local_unnamed_addr global [8 x double] zeroinitializer, align 16
@ar = dso_local local_unnamed_addr global [8 x double] zeroinitializer, align 16
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @main() local_unnamed_addr #0 {
br label %1
1: ; preds = %0, %47
%2 = phi i64 [ 0, %0 ], [ %50, %47 ]
%3 = trunc i64 %2 to i32
%4 = sitofp i32 %3 to double
%5 = fmul double %4, 6.283180e+00
%6 = fmul double %5, 1.250000e-01
%7 = fsub double 0x3FF921F9F01B866E, %6
%8 = fcmp ogt double %7, 6.283180e+00
br i1 %8, label %12, label %9
9: ; preds = %12, %1
%10 = phi double [ %7, %1 ], [ %14, %12 ]
%11 = fcmp olt double %10, -6.283180e+00
br i1 %11, label %16, label %20
12: ; preds = %1, %12
%13 = phi double [ %14, %12 ], [ %7, %1 ]
%14 = fadd double %13, -6.283180e+00
%15 = fcmp ogt double %14, 6.283180e+00
br i1 %15, label %12, label %9, !llvm.loop !5
16: ; preds = %9, %16
%17 = phi double [ %18, %16 ], [ %10, %9 ]
%18 = fadd double %17, 6.283180e+00
%19 = fcmp olt double %18, -6.283180e+00
br i1 %19, label %16, label %20, !llvm.loop !8
20: ; preds = %16, %9
%21 = phi double [ %10, %9 ], [ %18, %16 ]
%22 = fneg double %21
%23 = fmul double %21, %22
%24 = fmul double %21, %23
%25 = fdiv double %24, 6.000000e+00
%26 = fadd double %21, %25
%27 = fcmp ult double %25, 0.000000e+00
%28 = fneg double %25
%29 = select i1 %27, double %28, double %25
%30 = fcmp ult double %29, 1.000000e-05
br i1 %30, label %47, label %31
31: ; preds = %20, %31
%32 = phi i32 [ %42, %31 ], [ 2, %20 ]
%33 = phi double [ %40, %31 ], [ %25, %20 ]
%34 = phi double [ %41, %31 ], [ %26, %20 ]
%35 = fmul double %23, %33
%36 = sitofp i32 %32 to double
%37 = fmul double %36, 2.000000e+00
%38 = fadd double %37, 1.000000e+00
%39 = fmul double %37, %38
%40 = fdiv double %35, %39
%41 = fadd double %34, %40
%42 = add nuw nsw i32 %32, 1
%43 = fcmp ult double %40, 0.000000e+00
%44 = fneg double %40
%45 = select i1 %43, double %44, double %40
%46 = fcmp ult double %45, 1.000000e-05
br i1 %46, label %47, label %31, !llvm.loop !9
47: ; preds = %31, %20
%48 = phi double [ %26, %20 ], [ %41, %31 ]
%49 = getelementptr inbounds [8 x double], [8 x double]* @ar, i64 0, i64 %2
store double %48, double* %49, align 8, !tbaa !10
%50 = add nuw nsw i64 %2, 1
%51 = icmp eq i64 %50, 8
br i1 %51, label %52, label %1, !llvm.loop !14
52: ; preds = %47
%53 = call i32 @fft1(i32 8, i32 0)
%54 = call i32 @fft1(i32 8, i32 1)
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @fft1(i32 %0, i32 %1) local_unnamed_addr #0 {
%3 = icmp slt i32 %0, 2
br i1 %3, label %197, label %4
4: ; preds = %2
%5 = sitofp i32 %0 to double
%6 = add nsw i32 %0, -64
%7 = sitofp i32 %6 to double
%8 = icmp slt i32 %0, 64
%9 = fneg double %7
%10 = select i1 %8, double %9, double %7
%11 = fcmp ogt double %10, 0x3EB0C6F7A0B5ED8D
br i1 %11, label %197, label %12
12: ; preds = %4
%13 = icmp eq i32 %1, 1
%14 = sext i32 %0 to i64
br label %19
15: ; preds = %150
%16 = icmp sgt i32 %0, 1
br i1 %16, label %17, label %181
17: ; preds = %15
%18 = zext i32 %0 to i64
br label %153
19: ; preds = %12, %150
%20 = phi i32 [ 0, %12 ], [ %151, %150 ]
%21 = phi i32 [ %0, %12 ], [ %22, %150 ]
%22 = sdiv i32 %21, 2
%23 = sitofp i32 %22 to double
%24 = fdiv double 3.141590e+00, %23
%25 = icmp sgt i32 %21, %0
%26 = icmp sgt i32 %21, 1
br i1 %26, label %27, label %150
27: ; preds = %19
%28 = sext i32 %21 to i64
br label %29
29: ; preds = %27, %147
%30 = phi i32 [ %148, %147 ], [ 0, %27 ]
%31 = sitofp i32 %30 to double
%32 = fmul double %24, %31
%33 = fsub double 0x3FF921F9F01B866E, %32
%34 = fcmp ogt double %33, 6.283180e+00
br i1 %34, label %38, label %35
35: ; preds = %38, %29
%36 = phi double [ %33, %29 ], [ %40, %38 ]
%37 = fcmp olt double %36, -6.283180e+00
br i1 %37, label %42, label %46
38: ; preds = %29, %38
%39 = phi double [ %40, %38 ], [ %33, %29 ]
%40 = fadd double %39, -6.283180e+00
%41 = fcmp ogt double %40, 6.283180e+00
br i1 %41, label %38, label %35, !llvm.loop !5
42: ; preds = %35, %42
%43 = phi double [ %44, %42 ], [ %36, %35 ]
%44 = fadd double %43, 6.283180e+00
%45 = fcmp olt double %44, -6.283180e+00
br i1 %45, label %42, label %46, !llvm.loop !8
46: ; preds = %42, %35
%47 = phi double [ %36, %35 ], [ %44, %42 ]
%48 = fneg double %47
%49 = fmul double %47, %48
%50 = fmul double %47, %49
%51 = fdiv double %50, 6.000000e+00
%52 = fadd double %47, %51
%53 = fcmp ult double %51, 0.000000e+00
%54 = fneg double %51
%55 = select i1 %53, double %54, double %51
%56 = fcmp ult double %55, 1.000000e-05
br i1 %56, label %73, label %57
57: ; preds = %46, %57
%58 = phi i32 [ %68, %57 ], [ 2, %46 ]
%59 = phi double [ %66, %57 ], [ %51, %46 ]
%60 = phi double [ %67, %57 ], [ %52, %46 ]
%61 = fmul double %49, %59
%62 = sitofp i32 %58 to double
%63 = fmul double %62, 2.000000e+00
%64 = fadd double %63, 1.000000e+00
%65 = fmul double %63, %64
%66 = fdiv double %61, %65
%67 = fadd double %60, %66
%68 = add nuw nsw i32 %58, 1
%69 = fcmp ult double %66, 0.000000e+00
%70 = fneg double %66
%71 = select i1 %69, double %70, double %66
%72 = fcmp ult double %71, 1.000000e-05
br i1 %72, label %73, label %57, !llvm.loop !9
73: ; preds = %57, %46
%74 = phi double [ %52, %46 ], [ %67, %57 ]
%75 = fcmp ogt double %32, 6.283180e+00
br i1 %75, label %79, label %76
76: ; preds = %79, %73
%77 = phi double [ %32, %73 ], [ %81, %79 ]
%78 = fcmp olt double %77, -6.283180e+00
br i1 %78, label %83, label %87
79: ; preds = %73, %79
%80 = phi double [ %81, %79 ], [ %32, %73 ]
%81 = fadd double %80, -6.283180e+00
%82 = fcmp ogt double %81, 6.283180e+00
br i1 %82, label %79, label %76, !llvm.loop !5
83: ; preds = %76, %83
%84 = phi double [ %85, %83 ], [ %77, %76 ]
%85 = fadd double %84, 6.283180e+00
%86 = fcmp olt double %85, -6.283180e+00
br i1 %86, label %83, label %87, !llvm.loop !8
87: ; preds = %83, %76
%88 = phi double [ %77, %76 ], [ %85, %83 ]
%89 = fneg double %88
%90 = fmul double %88, %89
%91 = fmul double %88, %90
%92 = fdiv double %91, 6.000000e+00
%93 = fadd double %88, %92
%94 = fcmp ult double %92, 0.000000e+00
%95 = fneg double %92
%96 = select i1 %94, double %95, double %92
%97 = fcmp ult double %96, 1.000000e-05
br i1 %97, label %114, label %98
98: ; preds = %87, %98
%99 = phi i32 [ %109, %98 ], [ 2, %87 ]
%100 = phi double [ %107, %98 ], [ %92, %87 ]
%101 = phi double [ %108, %98 ], [ %93, %87 ]
%102 = fmul double %90, %100
%103 = sitofp i32 %99 to double
%104 = fmul double %103, 2.000000e+00
%105 = fadd double %104, 1.000000e+00
%106 = fmul double %104, %105
%107 = fdiv double %102, %106
%108 = fadd double %101, %107
%109 = add nuw nsw i32 %99, 1
%110 = fcmp ult double %107, 0.000000e+00
%111 = fneg double %107
%112 = select i1 %110, double %111, double %107
%113 = fcmp ult double %112, 1.000000e-05
br i1 %113, label %114, label %98, !llvm.loop !9
114: ; preds = %98, %87
%115 = phi double [ %93, %87 ], [ %108, %98 ]
%116 = fneg double %115
%117 = select i1 %13, double %115, double %116
%118 = sub nsw i32 %30, %21
br i1 %25, label %147, label %119
119: ; preds = %114, %119
%120 = phi i64 [ %144, %119 ], [ %28, %114 ]
%121 = phi i32 [ %145, %119 ], [ %21, %114 ]
%122 = add nsw i32 %121, %118
%123 = add nsw i32 %122, %22
%124 = sext i32 %122 to i64
%125 = getelementptr inbounds [8 x double], [8 x double]* @ar, i64 0, i64 %124
%126 = load double, double* %125, align 8, !tbaa !10
%127 = sext i32 %123 to i64
%128 = getelementptr inbounds [8 x double], [8 x double]* @ar, i64 0, i64 %127
%129 = load double, double* %128, align 8, !tbaa !10
%130 = getelementptr inbounds [8 x double], [8 x double]* @ai, i64 0, i64 %124
%131 = load double, double* %130, align 8, !tbaa !10
%132 = getelementptr inbounds [8 x double], [8 x double]* @ai, i64 0, i64 %127
%133 = load double, double* %132, align 8, !tbaa !10
%134 = fsub double %126, %129
%135 = fsub double %131, %133
%136 = fadd double %126, %129
store double %136, double* %125, align 8, !tbaa !10
%137 = fadd double %131, %133
store double %137, double* %130, align 8, !tbaa !10
%138 = fmul double %74, %134
%139 = fmul double %117, %135
%140 = fsub double %138, %139
store double %140, double* %128, align 8, !tbaa !10
%141 = fmul double %74, %135
%142 = fmul double %117, %134
%143 = fadd double %142, %141
store double %143, double* %132, align 8, !tbaa !10
%144 = add i64 %120, %28
%145 = add nsw i32 %121, %21
%146 = icmp sgt i64 %144, %14
br i1 %146, label %147, label %119, !llvm.loop !15
147: ; preds = %119, %114
%148 = add nuw nsw i32 %30, 1
%149 = icmp eq i32 %148, %22
br i1 %149, label %150, label %29, !llvm.loop !16
150: ; preds = %147, %19
%151 = add nuw nsw i32 %20, 1
%152 = icmp eq i32 %151, 6
br i1 %152, label %15, label %19, !llvm.loop !17
153: ; preds = %17, %177
%154 = phi i64 [ 1, %17 ], [ %179, %177 ]
%155 = phi i32 [ 1, %17 ], [ %178, %177 ]
%156 = sext i32 %155 to i64
%157 = icmp slt i64 %154, %156
br i1 %157, label %158, label %170
158: ; preds = %153
%159 = add nsw i32 %155, -1
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds [8 x double], [8 x double]* @ar, i64 0, i64 %160
%162 = load double, double* %161, align 8, !tbaa !10
%163 = getelementptr inbounds [8 x double], [8 x double]* @ai, i64 0, i64 %160
%164 = load double, double* %163, align 8, !tbaa !10
%165 = add nsw i64 %154, -1
%166 = getelementptr inbounds [8 x double], [8 x double]* @ar, i64 0, i64 %165
%167 = load double, double* %166, align 8, !tbaa !10
store double %167, double* %161, align 8, !tbaa !10
%168 = getelementptr inbounds [8 x double], [8 x double]* @ai, i64 0, i64 %165
%169 = load double, double* %168, align 8, !tbaa !10
store double %169, double* %163, align 8, !tbaa !10
store double %162, double* %166, align 8, !tbaa !10
store double %164, double* %168, align 8, !tbaa !10
br label %170
170: ; preds = %158, %153
br label %171
171: ; preds = %170, %171
%172 = phi i32 [ %174, %171 ], [ %0, %170 ]
%173 = phi i32 [ %176, %171 ], [ %155, %170 ]
%174 = sdiv i32 %172, 2
%175 = icmp sgt i32 %173, %174
%176 = sub nsw i32 %173, %174
br i1 %175, label %171, label %177, !llvm.loop !18
177: ; preds = %171
%178 = add nsw i32 %173, %174
%179 = add nuw nsw i64 %154, 1
%180 = icmp eq i64 %179, %18
br i1 %180, label %181, label %153, !llvm.loop !19
181: ; preds = %177, %15
%182 = icmp ne i32 %1, 0
%183 = icmp sgt i32 %0, 0
%184 = select i1 %182, i1 %183, i1 false
br i1 %184, label %185, label %197
185: ; preds = %181
%186 = zext i32 %0 to i64
br label %187
187: ; preds = %185, %187
%188 = phi i64 [ 0, %185 ], [ %195, %187 ]
%189 = getelementptr inbounds [8 x double], [8 x double]* @ar, i64 0, i64 %188
%190 = load double, double* %189, align 8, !tbaa !10
%191 = fdiv double %190, %5
store double %191, double* %189, align 8, !tbaa !10
%192 = getelementptr inbounds [8 x double], [8 x double]* @ai, i64 0, i64 %188
%193 = load double, double* %192, align 8, !tbaa !10
%194 = fdiv double %193, %5
store double %194, double* %192, align 8, !tbaa !10
%195 = add nuw nsw i64 %188, 1
%196 = icmp eq i64 %195, %186
br i1 %196, label %197, label %187, !llvm.loop !20
197: ; preds = %187, %181, %4, %2
%198 = phi i32 [ 999, %2 ], [ 1, %4 ], [ 0, %181 ], [ 0, %187 ]
ret i32 %198
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.unroll.disable"}
!8 = distinct !{!8, !6, !7}
!9 = distinct !{!9, !6, !7}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C/C++ TBAA"}
!14 = distinct !{!14, !6, !7}
!15 = distinct !{!15, !6, !7}
!16 = distinct !{!16, !6, !7}
!17 = distinct !{!17, !6, !7}
!18 = distinct !{!18, !6, !7}
!19 = distinct !{!19, !6, !7}
!20 = distinct !{!20, !6, !7}

52
test/fibcall.ll Normal file
View File

@ -0,0 +1,52 @@
; ModuleID = 'fibcall.c'
source_filename = "fibcall.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local i32 @fib(i32 %0) local_unnamed_addr #0 {
%2 = icmp sgt i32 %0, 1
br i1 %2, label %3, label %14
3: ; preds = %1
%4 = add i32 %0, -2
%5 = call i32 @llvm.umin.i32(i32 %4, i32 28)
%6 = add nuw nsw i32 %5, 2
br label %7
7: ; preds = %3, %7
%8 = phi i32 [ %12, %7 ], [ 2, %3 ]
%9 = phi i32 [ %11, %7 ], [ 1, %3 ]
%10 = phi i32 [ %9, %7 ], [ 0, %3 ]
%11 = add nsw i32 %9, %10
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %8, %6
br i1 %13, label %14, label %7, !llvm.loop !5
14: ; preds = %7, %1
%15 = phi i32 [ 1, %1 ], [ %11, %7 ]
ret i32 %15
}
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
ret i32 30
}
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare i32 @llvm.umin.i32(i32, i32) #1
attributes #0 = { nofree norecurse nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.unroll.disable"}

163
test/fir.ll Normal file

File diff suppressed because one or more lines are too long

77
test/insertsort.ll Normal file
View File

@ -0,0 +1,77 @@
; ModuleID = 'insertsort.c'
source_filename = "insertsort.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@a = dso_local local_unnamed_addr global [11 x i32] zeroinitializer, align 16
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
store i32 0, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 0), align 16, !tbaa !5
store i32 11, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 1), align 4, !tbaa !5
store i32 10, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 2), align 8, !tbaa !5
store i32 9, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 3), align 4, !tbaa !5
store i32 8, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 4), align 16, !tbaa !5
store i32 7, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 5), align 4, !tbaa !5
store i32 6, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 6), align 8, !tbaa !5
store i32 5, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 7), align 4, !tbaa !5
store i32 4, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 8), align 16, !tbaa !5
store i32 3, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 9), align 4, !tbaa !5
store i32 2, i32* getelementptr inbounds ([11 x i32], [11 x i32]* @a, i64 0, i64 10), align 8, !tbaa !5
br label %1
1: ; preds = %0, %22
%2 = phi i64 [ 2, %0 ], [ %23, %22 ]
%3 = phi i64 [ 1, %0 ], [ %24, %22 ]
%4 = getelementptr inbounds [11 x i32], [11 x i32]* @a, i64 0, i64 %2
%5 = load i32, i32* %4, align 4, !tbaa !5
%6 = add nsw i64 %2, -1
%7 = getelementptr inbounds [11 x i32], [11 x i32]* @a, i64 0, i64 %6
%8 = load i32, i32* %7, align 4, !tbaa !5
%9 = icmp ult i32 %5, %8
br i1 %9, label %10, label %22
10: ; preds = %1, %10
%11 = phi i64 [ %18, %10 ], [ %3, %1 ]
%12 = phi i32 [ %20, %10 ], [ %8, %1 ]
%13 = phi i32* [ %19, %10 ], [ %7, %1 ]
%14 = phi i32 [ %17, %10 ], [ %5, %1 ]
%15 = phi i32* [ %16, %10 ], [ %4, %1 ]
store i32 %12, i32* %15, align 4, !tbaa !5
store i32 %14, i32* %13, align 4, !tbaa !5
%16 = getelementptr inbounds [11 x i32], [11 x i32]* @a, i64 0, i64 %11
%17 = load i32, i32* %16, align 4, !tbaa !5
%18 = add nsw i64 %11, -1
%19 = getelementptr inbounds [11 x i32], [11 x i32]* @a, i64 0, i64 %18
%20 = load i32, i32* %19, align 4, !tbaa !5
%21 = icmp ult i32 %17, %20
br i1 %21, label %10, label %22, !llvm.loop !9
22: ; preds = %10, %1
%23 = add nuw nsw i64 %2, 1
%24 = add nuw nsw i64 %3, 1
%25 = icmp eq i64 %23, 11
br i1 %25, label %26, label %1, !llvm.loop !12
26: ; preds = %22
ret i32 1
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}

26
test/janne_complex.ll Normal file
View File

@ -0,0 +1,26 @@
; ModuleID = 'janne_complex.c'
source_filename = "janne_complex.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local i32 @complex(i32 %0, i32 %1) local_unnamed_addr #0 {
ret i32 1
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn
define dso_local i32 @main() local_unnamed_addr #1 {
ret i32 1
}
attributes #0 = { nofree norecurse nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}

235
test/jfdctint.ll Normal file
View File

@ -0,0 +1,235 @@
; ModuleID = 'jfdctint.c'
source_filename = "jfdctint.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@data = dso_local local_unnamed_addr global [64 x i32] zeroinitializer, align 16
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @jpeg_fdct_islow() local_unnamed_addr #0 {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 7, %0 ], [ %78, %1 ]
%3 = phi i32* [ getelementptr inbounds ([64 x i32], [64 x i32]* @data, i64 0, i64 0), %0 ], [ %77, %1 ]
%4 = load i32, i32* %3, align 4, !tbaa !5
%5 = getelementptr inbounds i32, i32* %3, i64 7
%6 = load i32, i32* %5, align 4, !tbaa !5
%7 = add nsw i32 %6, %4
%8 = sub nsw i32 %4, %6
%9 = getelementptr inbounds i32, i32* %3, i64 1
%10 = load i32, i32* %9, align 4, !tbaa !5
%11 = getelementptr inbounds i32, i32* %3, i64 6
%12 = load i32, i32* %11, align 4, !tbaa !5
%13 = add nsw i32 %12, %10
%14 = sub nsw i32 %10, %12
%15 = getelementptr inbounds i32, i32* %3, i64 2
%16 = load i32, i32* %15, align 4, !tbaa !5
%17 = getelementptr inbounds i32, i32* %3, i64 5
%18 = load i32, i32* %17, align 4, !tbaa !5
%19 = add nsw i32 %18, %16
%20 = sub nsw i32 %16, %18
%21 = getelementptr inbounds i32, i32* %3, i64 3
%22 = load i32, i32* %21, align 4, !tbaa !5
%23 = getelementptr inbounds i32, i32* %3, i64 4
%24 = load i32, i32* %23, align 4, !tbaa !5
%25 = add nsw i32 %24, %22
%26 = sub nsw i32 %22, %24
%27 = add nsw i32 %25, %7
%28 = sub nsw i32 %7, %25
%29 = add nsw i32 %19, %13
%30 = sub nsw i32 %13, %19
%31 = add nsw i32 %27, %29
%32 = shl i32 %31, 2
store i32 %32, i32* %3, align 4, !tbaa !5
%33 = sub nsw i32 %27, %29
%34 = shl i32 %33, 2
store i32 %34, i32* %23, align 4, !tbaa !5
%35 = add nsw i32 %28, %30
%36 = mul nsw i32 %35, 4433
%37 = mul nsw i32 %28, 6270
%38 = add i32 %36, 1024
%39 = add i32 %38, %37
%40 = ashr i32 %39, 11
store i32 %40, i32* %15, align 4, !tbaa !5
%41 = mul nsw i32 %30, -15137
%42 = add i32 %36, 1024
%43 = add i32 %42, %41
%44 = ashr i32 %43, 11
store i32 %44, i32* %11, align 4, !tbaa !5
%45 = add nsw i32 %26, %8
%46 = add nsw i32 %20, %14
%47 = add nsw i32 %26, %14
%48 = add nsw i32 %20, %8
%49 = add nsw i32 %47, %48
%50 = mul nsw i32 %49, 9633
%51 = mul nsw i32 %26, 2446
%52 = mul nsw i32 %20, 16819
%53 = mul nsw i32 %14, 25172
%54 = mul nsw i32 %8, 12299
%55 = mul nsw i32 %45, -7373
%56 = mul nsw i32 %46, -20995
%57 = mul nsw i32 %47, -16069
%58 = mul nsw i32 %48, -3196
%59 = add nsw i32 %50, %57
%60 = add nsw i32 %50, %58
%61 = add i32 %55, 1024
%62 = add i32 %61, %51
%63 = add i32 %62, %59
%64 = ashr i32 %63, 11
store i32 %64, i32* %5, align 4, !tbaa !5
%65 = add i32 %56, 1024
%66 = add i32 %65, %52
%67 = add i32 %66, %60
%68 = ashr i32 %67, 11
store i32 %68, i32* %17, align 4, !tbaa !5
%69 = add i32 %56, 1024
%70 = add i32 %69, %53
%71 = add i32 %70, %59
%72 = ashr i32 %71, 11
store i32 %72, i32* %21, align 4, !tbaa !5
%73 = add i32 %55, 1024
%74 = add i32 %73, %54
%75 = add i32 %74, %60
%76 = ashr i32 %75, 11
store i32 %76, i32* %9, align 4, !tbaa !5
%77 = getelementptr inbounds i32, i32* %3, i64 8
%78 = add nsw i32 %2, -1
%79 = icmp eq i32 %2, 0
br i1 %79, label %80, label %1, !llvm.loop !9
80: ; preds = %1, %80
%81 = phi i32 [ %159, %80 ], [ 7, %1 ]
%82 = phi i32* [ %158, %80 ], [ getelementptr inbounds ([64 x i32], [64 x i32]* @data, i64 0, i64 0), %1 ]
%83 = load i32, i32* %82, align 4, !tbaa !5
%84 = getelementptr inbounds i32, i32* %82, i64 56
%85 = load i32, i32* %84, align 4, !tbaa !5
%86 = add nsw i32 %85, %83
%87 = sub nsw i32 %83, %85
%88 = getelementptr inbounds i32, i32* %82, i64 8
%89 = load i32, i32* %88, align 4, !tbaa !5
%90 = getelementptr inbounds i32, i32* %82, i64 48
%91 = load i32, i32* %90, align 4, !tbaa !5
%92 = add nsw i32 %91, %89
%93 = sub nsw i32 %89, %91
%94 = getelementptr inbounds i32, i32* %82, i64 16
%95 = load i32, i32* %94, align 4, !tbaa !5
%96 = getelementptr inbounds i32, i32* %82, i64 40
%97 = load i32, i32* %96, align 4, !tbaa !5
%98 = add nsw i32 %97, %95
%99 = sub nsw i32 %95, %97
%100 = getelementptr inbounds i32, i32* %82, i64 24
%101 = load i32, i32* %100, align 4, !tbaa !5
%102 = getelementptr inbounds i32, i32* %82, i64 32
%103 = load i32, i32* %102, align 4, !tbaa !5
%104 = add nsw i32 %103, %101
%105 = sub nsw i32 %101, %103
%106 = add nsw i32 %104, %86
%107 = sub nsw i32 %86, %104
%108 = add nsw i32 %98, %92
%109 = sub nsw i32 %92, %98
%110 = add i32 %108, 2
%111 = add i32 %110, %106
%112 = ashr i32 %111, 2
store i32 %112, i32* %82, align 4, !tbaa !5
%113 = sub i32 2, %108
%114 = add i32 %113, %106
%115 = ashr i32 %114, 2
store i32 %115, i32* %102, align 4, !tbaa !5
%116 = add nsw i32 %107, %109
%117 = mul nsw i32 %116, 4433
%118 = mul nsw i32 %107, 6270
%119 = add i32 %117, 16384
%120 = add i32 %119, %118
%121 = ashr i32 %120, 15
store i32 %121, i32* %94, align 4, !tbaa !5
%122 = mul nsw i32 %109, -15137
%123 = add i32 %117, 16384
%124 = add i32 %123, %122
%125 = ashr i32 %124, 15
store i32 %125, i32* %90, align 4, !tbaa !5
%126 = add nsw i32 %105, %87
%127 = add nsw i32 %99, %93
%128 = add nsw i32 %105, %93
%129 = add nsw i32 %99, %87
%130 = add nsw i32 %128, %129
%131 = mul nsw i32 %130, 9633
%132 = mul nsw i32 %105, 2446
%133 = mul nsw i32 %99, 16819
%134 = mul nsw i32 %93, 25172
%135 = mul nsw i32 %87, 12299
%136 = mul nsw i32 %126, -7373
%137 = mul nsw i32 %127, -20995
%138 = mul nsw i32 %128, -16069
%139 = mul nsw i32 %129, -3196
%140 = add nsw i32 %131, %138
%141 = add nsw i32 %131, %139
%142 = add i32 %136, 16384
%143 = add i32 %142, %132
%144 = add i32 %143, %140
%145 = ashr i32 %144, 15
store i32 %145, i32* %84, align 4, !tbaa !5
%146 = add i32 %137, 16384
%147 = add i32 %146, %133
%148 = add i32 %147, %141
%149 = ashr i32 %148, 15
store i32 %149, i32* %96, align 4, !tbaa !5
%150 = add i32 %137, 16384
%151 = add i32 %150, %134
%152 = add i32 %151, %140
%153 = ashr i32 %152, 15
store i32 %153, i32* %100, align 4, !tbaa !5
%154 = add i32 %136, 16384
%155 = add i32 %154, %135
%156 = add i32 %155, %141
%157 = ashr i32 %156, 15
store i32 %157, i32* %88, align 4, !tbaa !5
%158 = getelementptr inbounds i32, i32* %82, i64 1
%159 = add nsw i32 %81, -1
%160 = icmp eq i32 %81, 0
br i1 %160, label %161, label %80, !llvm.loop !12
161: ; preds = %80
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @main() local_unnamed_addr #0 {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 0, %0 ], [ %8, %1 ]
%3 = phi i32 [ 1, %0 ], [ %6, %1 ]
%4 = mul nsw i32 %3, 133
%5 = add nsw i32 %4, 81
%6 = srem i32 %5, 65535
%7 = getelementptr inbounds [64 x i32], [64 x i32]* @data, i64 0, i64 %2
store i32 %6, i32* %7, align 4, !tbaa !5
%8 = add nuw nsw i64 %2, 1
%9 = icmp eq i64 %8, 64
br i1 %9, label %10, label %1, !llvm.loop !13
10: ; preds = %1
call void @jpeg_fdct_islow()
ret void
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}
!13 = distinct !{!13, !10, !11}

79
test/lcdnum.ll Normal file
View File

@ -0,0 +1,79 @@
; ModuleID = 'lcdnum.c'
source_filename = "lcdnum.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@IN = dso_local global i8 0, align 1
@OUT = dso_local global i8 0, align 1
@switch.table.main = private unnamed_addr constant [15 x i8] c"$]m.]{%\7Fo?zS|[\1B", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn
define dso_local zeroext i8 @num_to_lcd(i8 zeroext %0) local_unnamed_addr #0 {
%2 = add i8 %0, -1
%3 = icmp ult i8 %2, 15
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i8 %2 to i64
%6 = getelementptr inbounds [15 x i8], [15 x i8]* @switch.table.main, i64 0, i64 %5
%7 = load i8, i8* %6, align 1
br label %8
8: ; preds = %4, %1
%9 = phi i8 [ 0, %1 ], [ %7, %4 ]
ret i8 %9
}
; Function Attrs: nofree norecurse nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
br label %1
1: ; preds = %0, %15
%2 = phi i32 [ 0, %0 ], [ %16, %15 ]
%3 = load volatile i8, i8* @IN, align 1, !tbaa !5
%4 = icmp ult i32 %2, 5
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = and i8 %3, 15
%7 = add nsw i8 %6, -1
%8 = icmp ult i8 %7, 15
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = sext i8 %7 to i64
%11 = getelementptr inbounds [15 x i8], [15 x i8]* @switch.table.main, i64 0, i64 %10
%12 = load i8, i8* %11, align 1
br label %13
13: ; preds = %9, %5
%14 = phi i8 [ 0, %5 ], [ %12, %9 ]
store volatile i8 %14, i8* @OUT, align 1, !tbaa !5
br label %15
15: ; preds = %1, %13
%16 = add nuw nsw i32 %2, 1
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %1, !llvm.loop !8
18: ; preds = %15
ret i32 0
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree norecurse nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.unroll.disable"}

486
test/lms.ll Normal file
View File

@ -0,0 +1,486 @@
; ModuleID = 'lms.c'
source_filename = "lms.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@mu = dso_local local_unnamed_addr global float 0x3F847AE140000000, align 4
@lms_rand.next = internal unnamed_addr global i64 1, align 8
@main.d = internal unnamed_addr global [201 x float] zeroinitializer, align 16
@main.b = internal unnamed_addr global [21 x float] zeroinitializer, align 16
@lms.px = internal unnamed_addr global [51 x float] zeroinitializer, align 16
@lms.sigma = internal unnamed_addr global float 2.000000e+00, align 4
@gaussian.ready = internal unnamed_addr global i1 false, align 4
@gaussian.gstore = internal unnamed_addr global float 0.000000e+00, align 4
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn
define dso_local i32 @lms_rand() local_unnamed_addr #0 {
%1 = load i64, i64* @lms_rand.next, align 8, !tbaa !5
%2 = mul i64 %1, 1103515245
%3 = add i64 %2, 12345
store i64 %3, i64* @lms_rand.next, align 8, !tbaa !5
%4 = lshr i64 %3, 16
%5 = trunc i64 %4 to i32
%6 = and i32 %5, 32767
ret i32 %6
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
br label %1
1: ; preds = %23, %0
%2 = phi i32 [ 0, %0 ], [ %25, %23 ]
%3 = phi i32 [ 1, %0 ], [ %26, %23 ]
%4 = phi float [ 0x3FC99999A0000000, %0 ], [ %24, %23 ]
%5 = icmp eq i32 %2, 0
br i1 %5, label %6, label %23
6: ; preds = %1
%7 = fmul float %4, %4
%8 = fsub float 2.000000e+00, %7
%9 = fpext float %8 to double
%10 = fpext float %4 to double
%11 = fmul double %10, 2.000000e+00
%12 = fdiv double %9, %11
%13 = fptrunc double %12 to float
%14 = fadd float %4, %13
%15 = fmul float %14, %14
%16 = fsub float 2.000000e+00, %15
%17 = fcmp ult float %16, 0.000000e+00
%18 = fneg float %16
%19 = select i1 %17, float %18, float %16
%20 = fpext float %19 to double
%21 = fcmp ugt double %20, 1.000000e-05
br i1 %21, label %23, label %22
22: ; preds = %6
br label %23
23: ; preds = %22, %6, %1
%24 = phi float [ %4, %1 ], [ %14, %22 ], [ %14, %6 ]
%25 = phi i32 [ 1, %1 ], [ 1, %22 ], [ 0, %6 ]
%26 = add nuw nsw i32 %3, 1
%27 = icmp eq i32 %26, 20
br i1 %27, label %28, label %1, !llvm.loop !9
28: ; preds = %23, %50
%29 = phi i32 [ %52, %50 ], [ 0, %23 ]
%30 = phi i32 [ %53, %50 ], [ 1, %23 ]
%31 = phi float [ %51, %50 ], [ 0x3FF3333340000000, %23 ]
%32 = icmp eq i32 %29, 0
br i1 %32, label %33, label %50
33: ; preds = %28
%34 = fmul float %31, %31
%35 = fsub float 1.200000e+01, %34
%36 = fpext float %35 to double
%37 = fpext float %31 to double
%38 = fmul double %37, 2.000000e+00
%39 = fdiv double %36, %38
%40 = fptrunc double %39 to float
%41 = fadd float %31, %40
%42 = fmul float %41, %41
%43 = fsub float 1.200000e+01, %42
%44 = fcmp ult float %43, 0.000000e+00
%45 = fneg float %43
%46 = select i1 %44, float %45, float %43
%47 = fpext float %46 to double
%48 = fcmp ugt double %47, 1.000000e-05
br i1 %48, label %50, label %49
49: ; preds = %33
br label %50
50: ; preds = %49, %33, %28
%51 = phi float [ %31, %28 ], [ %41, %49 ], [ %41, %33 ]
%52 = phi i32 [ 1, %28 ], [ 1, %49 ], [ 0, %33 ]
%53 = add nuw nsw i32 %30, 1
%54 = icmp eq i32 %53, 20
br i1 %54, label %55, label %28, !llvm.loop !9
55: ; preds = %50
%56 = fpext float %51 to double
%57 = fmul double %56, 2.000000e-01
%58 = fptrunc double %57 to float
br label %59
59: ; preds = %55, %203
%60 = phi i64 [ 0, %55 ], [ %208, %203 ]
%61 = trunc i64 %60 to i32
%62 = sitofp i32 %61 to float
%63 = fmul float %62, 0x3FD41B2F80000000
%64 = fpext float %63 to double
%65 = fcmp ogt double %64, 0x401921FB54442D18
br i1 %65, label %70, label %66
66: ; preds = %70, %59
%67 = phi float [ %63, %59 ], [ %73, %70 ]
%68 = fpext float %67 to double
%69 = fcmp olt double %68, 0xC01921FB54442D18
br i1 %69, label %76, label %82
70: ; preds = %59, %70
%71 = phi double [ %74, %70 ], [ %64, %59 ]
%72 = fadd double %71, 0xC01921FB54442D18
%73 = fptrunc double %72 to float
%74 = fpext float %73 to double
%75 = fcmp ogt double %74, 0x401921FB54442D18
br i1 %75, label %70, label %66, !llvm.loop !12
76: ; preds = %66, %76
%77 = phi double [ %80, %76 ], [ %68, %66 ]
%78 = fadd double %77, 0x401921FB54442D18
%79 = fptrunc double %78 to float
%80 = fpext float %79 to double
%81 = fcmp olt double %80, 0xC01921FB54442D18
br i1 %81, label %76, label %82, !llvm.loop !13
82: ; preds = %76, %66
%83 = phi float [ %67, %66 ], [ %79, %76 ]
%84 = fneg float %83
%85 = fmul float %83, %84
%86 = fmul float %83, %85
%87 = fdiv float %86, 6.000000e+00
%88 = fadd float %83, %87
%89 = fcmp ult float %87, 0.000000e+00
%90 = fneg float %87
%91 = select i1 %89, float %90, float %87
%92 = fpext float %91 to double
%93 = fcmp ult double %92, 1.000000e-05
br i1 %93, label %113, label %94
94: ; preds = %82, %94
%95 = phi i32 [ %107, %94 ], [ 2, %82 ]
%96 = phi float [ %105, %94 ], [ %87, %82 ]
%97 = phi float [ %106, %94 ], [ %88, %82 ]
%98 = fmul float %85, %96
%99 = fpext float %98 to double
%100 = sitofp i32 %95 to double
%101 = fmul double %100, 2.000000e+00
%102 = fadd double %101, 1.000000e+00
%103 = fmul double %101, %102
%104 = fdiv double %99, %103
%105 = fptrunc double %104 to float
%106 = fadd float %97, %105
%107 = add nuw nsw i32 %95, 1
%108 = fcmp ult float %105, 0.000000e+00
%109 = fneg float %105
%110 = select i1 %108, float %109, float %105
%111 = fpext float %110 to double
%112 = fcmp ult double %111, 1.000000e-05
br i1 %112, label %113, label %94, !llvm.loop !14
113: ; preds = %94, %82
%114 = phi float [ %88, %82 ], [ %106, %94 ]
%115 = fmul float %24, %114
%116 = load i1, i1* @gaussian.ready, align 4
br i1 %116, label %201, label %117
117: ; preds = %113
%118 = load i64, i64* @lms_rand.next, align 8, !tbaa !5
%119 = mul i64 %118, 1103515245
%120 = add i64 %119, 12345
%121 = lshr i64 %120, 16
%122 = trunc i64 %121 to i32
%123 = and i32 %122, 32767
%124 = sitofp i32 %123 to float
%125 = fadd float %124, -1.638400e+04
%126 = mul i64 %120, 1103515245
%127 = add i64 %126, 12345
store i64 %127, i64* @lms_rand.next, align 8, !tbaa !5
%128 = lshr i64 %127, 16
%129 = trunc i64 %128 to i32
%130 = and i32 %129, 32767
%131 = sitofp i32 %130 to float
%132 = fadd float %131, -1.638400e+04
%133 = fmul float %125, 0x3F10000000000000
%134 = fmul float %132, 0x3F10000000000000
%135 = fmul float %133, %133
%136 = fmul float %134, %134
%137 = fadd float %135, %136
%138 = fcmp ogt float %137, 1.000000e+00
br i1 %138, label %139, label %162
139: ; preds = %117, %139
%140 = phi i64 [ %149, %139 ], [ %127, %117 ]
%141 = mul i64 %140, 1103515245
%142 = add i64 %141, 12345
%143 = lshr i64 %142, 16
%144 = trunc i64 %143 to i32
%145 = and i32 %144, 32767
%146 = sitofp i32 %145 to float
%147 = fadd float %146, -1.638400e+04
%148 = mul i64 %142, 1103515245
%149 = add i64 %148, 12345
%150 = lshr i64 %149, 16
%151 = trunc i64 %150 to i32
%152 = and i32 %151, 32767
%153 = sitofp i32 %152 to float
%154 = fadd float %153, -1.638400e+04
%155 = fmul float %147, 0x3F10000000000000
%156 = fmul float %154, 0x3F10000000000000
%157 = fmul float %155, %155
%158 = fmul float %156, %156
%159 = fadd float %157, %158
%160 = fcmp ogt float %159, 1.000000e+00
br i1 %160, label %139, label %161, !llvm.loop !15
161: ; preds = %139
store i64 %149, i64* @lms_rand.next, align 8, !tbaa !5
br label %162
162: ; preds = %161, %117
%163 = phi float [ %156, %161 ], [ %134, %117 ]
%164 = phi float [ %159, %161 ], [ %137, %117 ]
%165 = phi float [ %155, %161 ], [ %133, %117 ]
%166 = fdiv float -9.000000e+00, %164
%167 = fcmp oeq float %166, 0.000000e+00
br i1 %167, label %197, label %168
168: ; preds = %162
%169 = fdiv float %166, 1.000000e+01
br label %170
170: ; preds = %192, %168
%171 = phi i32 [ 0, %168 ], [ %194, %192 ]
%172 = phi i32 [ 1, %168 ], [ %195, %192 ]
%173 = phi float [ %169, %168 ], [ %193, %192 ]
%174 = icmp eq i32 %171, 0
br i1 %174, label %175, label %192
175: ; preds = %170
%176 = fmul float %173, %173
%177 = fsub float %166, %176
%178 = fpext float %177 to double
%179 = fpext float %173 to double
%180 = fmul double %179, 2.000000e+00
%181 = fdiv double %178, %180
%182 = fptrunc double %181 to float
%183 = fadd float %173, %182
%184 = fmul float %183, %183
%185 = fsub float %166, %184
%186 = fcmp ult float %185, 0.000000e+00
%187 = fneg float %185
%188 = select i1 %186, float %187, float %185
%189 = fpext float %188 to double
%190 = fcmp ugt double %189, 1.000000e-05
br i1 %190, label %192, label %191
191: ; preds = %175
br label %192
192: ; preds = %191, %175, %170
%193 = phi float [ %173, %170 ], [ %183, %191 ], [ %183, %175 ]
%194 = phi i32 [ 1, %170 ], [ 1, %191 ], [ 0, %175 ]
%195 = add nuw nsw i32 %172, 1
%196 = icmp eq i32 %195, 20
br i1 %196, label %197, label %170, !llvm.loop !9
197: ; preds = %192, %162
%198 = phi float [ 0.000000e+00, %162 ], [ %193, %192 ]
%199 = fmul float %165, %198
store float %199, float* @gaussian.gstore, align 4, !tbaa !16
%200 = fmul float %163, %198
store i1 true, i1* @gaussian.ready, align 4
br label %203
201: ; preds = %113
store i1 false, i1* @gaussian.ready, align 4
%202 = load float, float* @gaussian.gstore, align 4, !tbaa !16
br label %203
203: ; preds = %197, %201
%204 = phi float [ %200, %197 ], [ %202, %201 ]
%205 = fmul float %204, %58
%206 = fadd float %115, %205
%207 = getelementptr inbounds [201 x float], [201 x float]* @main.d, i64 0, i64 %60
store float %206, float* %207, align 4, !tbaa !16
%208 = add nuw nsw i64 %60, 1
%209 = icmp eq i64 %208, 201
br i1 %209, label %210, label %59, !llvm.loop !18
210: ; preds = %203
%211 = load float, float* @mu, align 4, !tbaa !16
%212 = fpext float %211 to double
%213 = fmul double %212, 2.000000e+00
%214 = fdiv double %213, 2.100000e+01
%215 = fptrunc double %214 to float
store float %215, float* @mu, align 4, !tbaa !16
%216 = load float, float* @lms.sigma, align 4, !tbaa !16
br label %217
217: ; preds = %210, %254
%218 = phi i64 [ 0, %210 ], [ %255, %254 ]
%219 = phi float [ 0.000000e+00, %210 ], [ %222, %254 ]
%220 = phi float [ %216, %210 ], [ %241, %254 ]
%221 = getelementptr inbounds [201 x float], [201 x float]* @main.d, i64 0, i64 %218
%222 = load float, float* %221, align 4, !tbaa !16
store float %219, float* getelementptr inbounds ([51 x float], [51 x float]* @lms.px, i64 0, i64 0), align 16, !tbaa !16
%223 = load float, float* getelementptr inbounds ([21 x float], [21 x float]* @main.b, i64 0, i64 0), align 16, !tbaa !16
%224 = fmul float %219, %223
br label %225
225: ; preds = %225, %217
%226 = phi i64 [ 1, %217 ], [ %234, %225 ]
%227 = phi float [ %224, %217 ], [ %233, %225 ]
%228 = getelementptr inbounds [21 x float], [21 x float]* @main.b, i64 0, i64 %226
%229 = load float, float* %228, align 4, !tbaa !16
%230 = getelementptr inbounds [51 x float], [51 x float]* @lms.px, i64 0, i64 %226
%231 = load float, float* %230, align 4, !tbaa !16
%232 = fmul float %229, %231
%233 = fadd float %227, %232
%234 = add nuw nsw i64 %226, 1
%235 = icmp eq i64 %234, 21
br i1 %235, label %236, label %225, !llvm.loop !19
236: ; preds = %225
%237 = fsub float %222, %233
%238 = fmul float %219, %219
%239 = fmul float %238, 0x3F847AE140000000
%240 = fmul float %220, 0x3FEFAE1480000000
%241 = fadd float %239, %240
%242 = fmul float %237, %215
%243 = fdiv float %242, %241
br label %244
244: ; preds = %244, %236
%245 = phi i64 [ 0, %236 ], [ %252, %244 ]
%246 = getelementptr inbounds [21 x float], [21 x float]* @main.b, i64 0, i64 %245
%247 = load float, float* %246, align 4, !tbaa !16
%248 = getelementptr inbounds [51 x float], [51 x float]* @lms.px, i64 0, i64 %245
%249 = load float, float* %248, align 4, !tbaa !16
%250 = fmul float %243, %249
%251 = fadd float %247, %250
store float %251, float* %246, align 4, !tbaa !16
%252 = add nuw nsw i64 %245, 1
%253 = icmp eq i64 %252, 21
br i1 %253, label %254, label %244, !llvm.loop !20
254: ; preds = %244
call void @llvm.memmove.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(80) bitcast (float* getelementptr inbounds ([51 x float], [51 x float]* @lms.px, i64 0, i64 1) to i8*), i8* noundef nonnull align 16 dereferenceable(80) bitcast ([51 x float]* @lms.px to i8*), i64 80, i1 false)
%255 = add nuw nsw i64 %218, 1
%256 = icmp eq i64 %255, 201
br i1 %256, label %257, label %217, !llvm.loop !21
257: ; preds = %254
store float %241, float* @lms.sigma, align 4, !tbaa !16
ret i32 0
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local float @lms(float %0, float %1, float* nocapture %2, i32 %3, float %4, float %5) local_unnamed_addr #1 {
store float %0, float* getelementptr inbounds ([51 x float], [51 x float]* @lms.px, i64 0, i64 0), align 16, !tbaa !16
%7 = load float, float* %2, align 4, !tbaa !16
%8 = fmul float %7, %0
%9 = icmp slt i32 %3, 1
br i1 %9, label %24, label %10
10: ; preds = %6
%11 = add i32 %3, 1
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 1, %10 ], [ %22, %13 ]
%15 = phi float [ %8, %10 ], [ %21, %13 ]
%16 = getelementptr inbounds float, float* %2, i64 %14
%17 = load float, float* %16, align 4, !tbaa !16
%18 = getelementptr inbounds [51 x float], [51 x float]* @lms.px, i64 0, i64 %14
%19 = load float, float* %18, align 4, !tbaa !16
%20 = fmul float %17, %19
%21 = fadd float %15, %20
%22 = add nuw nsw i64 %14, 1
%23 = icmp eq i64 %22, %12
br i1 %23, label %24, label %13, !llvm.loop !19
24: ; preds = %13, %6
%25 = phi float [ %8, %6 ], [ %21, %13 ]
%26 = fsub float %1, %25
%27 = fmul float %0, %0
%28 = fmul float %27, %5
%29 = fsub float 1.000000e+00, %5
%30 = load float, float* @lms.sigma, align 4, !tbaa !16
%31 = fmul float %29, %30
%32 = fadd float %28, %31
store float %32, float* @lms.sigma, align 4, !tbaa !16
%33 = fmul float %26, %4
%34 = fdiv float %33, %32
%35 = icmp slt i32 %3, 0
br i1 %35, label %39, label %36
36: ; preds = %24
%37 = add i32 %3, 1
%38 = zext i32 %37 to i64
br label %43
39: ; preds = %43, %24
%40 = icmp sgt i32 %3, 0
br i1 %40, label %41, label %63
41: ; preds = %39
%42 = zext i32 %3 to i64
br label %53
43: ; preds = %36, %43
%44 = phi i64 [ 0, %36 ], [ %51, %43 ]
%45 = getelementptr inbounds float, float* %2, i64 %44
%46 = load float, float* %45, align 4, !tbaa !16
%47 = getelementptr inbounds [51 x float], [51 x float]* @lms.px, i64 0, i64 %44
%48 = load float, float* %47, align 4, !tbaa !16
%49 = fmul float %34, %48
%50 = fadd float %46, %49
store float %50, float* %45, align 4, !tbaa !16
%51 = add nuw nsw i64 %44, 1
%52 = icmp eq i64 %51, %38
br i1 %52, label %39, label %43, !llvm.loop !20
53: ; preds = %41, %53
%54 = phi i64 [ %42, %41 ], [ %62, %53 ]
%55 = phi i32 [ %3, %41 ], [ %56, %53 ]
%56 = add nsw i32 %55, -1
%57 = zext i32 %56 to i64
%58 = getelementptr inbounds [51 x float], [51 x float]* @lms.px, i64 0, i64 %57
%59 = load float, float* %58, align 4, !tbaa !16
%60 = getelementptr inbounds [51 x float], [51 x float]* @lms.px, i64 0, i64 %54
store float %59, float* %60, align 4, !tbaa !16
%61 = icmp sgt i64 %54, 1
%62 = add nsw i64 %54, -1
br i1 %61, label %53, label %63, !llvm.loop !22
63: ; preds = %53, %39
ret float %25
}
; Function Attrs: argmemonly nofree nounwind willreturn
declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1 immarg) #2
attributes #0 = { mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { argmemonly nofree nounwind willreturn }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10, !11}
!15 = distinct !{!15, !10, !11}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = distinct !{!18, !10, !11}
!19 = distinct !{!19, !10, !11}
!20 = distinct !{!20, !10, !11}
!21 = distinct !{!21, !10, !11}
!22 = distinct !{!22, !10, !11}

269
test/ludcmp.ll Normal file
View File

@ -0,0 +1,269 @@
; ModuleID = 'ludcmp.c'
source_filename = "ludcmp.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@a = dso_local local_unnamed_addr global [50 x [50 x double]] zeroinitializer, align 16
@b = dso_local local_unnamed_addr global [50 x double] zeroinitializer, align 16
@x = dso_local local_unnamed_addr global [50 x double] zeroinitializer, align 16
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
br label %1
1: ; preds = %0, %17
%2 = phi i64 [ 0, %0 ], [ %3, %17 ]
%3 = add nuw nsw i64 %2, 1
br label %4
4: ; preds = %1, %4
%5 = phi i64 [ 0, %1 ], [ %7, %4 ]
%6 = phi double [ 0.000000e+00, %1 ], [ %15, %4 ]
%7 = add nuw nsw i64 %5, 1
%8 = add nuw nsw i64 %3, %7
%9 = trunc i64 %8 to i32
%10 = sitofp i32 %9 to double
%11 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %2, i64 %5
%12 = icmp eq i64 %2, %5
%13 = fmul double %10, 1.000000e+01
%14 = select i1 %12, double %13, double %10
store double %14, double* %11, align 8, !tbaa !5
%15 = fadd double %6, %14
%16 = icmp eq i64 %7, 6
br i1 %16, label %17, label %4, !llvm.loop !9
17: ; preds = %4
%18 = getelementptr inbounds [50 x double], [50 x double]* @b, i64 0, i64 %2
store double %15, double* %18, align 8, !tbaa !5
%19 = icmp eq i64 %3, 6
br i1 %19, label %20, label %1, !llvm.loop !12
20: ; preds = %17
%21 = call i32 @ludcmp(i32 5, double 0x3EB0C6F7A0B5ED8D)
ret i32 0
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local i32 @ludcmp(i32 %0, double %1) local_unnamed_addr #0 {
%3 = alloca [100 x double], align 16
%4 = bitcast [100 x double]* %3 to i8*
call void @llvm.lifetime.start.p0i8(i64 800, i8* nonnull %4) #2
%5 = icmp sgt i32 %0, 99
%6 = fcmp ole double %1, 0.000000e+00
%7 = select i1 %5, i1 true, i1 %6
br i1 %7, label %133, label %8
8: ; preds = %2
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %69
10: ; preds = %8
%11 = add i32 %0, 1
%12 = zext i32 %0 to i64
%13 = zext i32 %11 to i64
%14 = zext i32 %11 to i64
br label %18
15: ; preds = %66
%16 = add nuw nsw i64 %20, 1
%17 = icmp eq i64 %28, %12
br i1 %17, label %69, label %18, !llvm.loop !13
18: ; preds = %10, %15
%19 = phi i64 [ 0, %10 ], [ %28, %15 ]
%20 = phi i64 [ 1, %10 ], [ %16, %15 ]
%21 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %19, i64 %19
%22 = load double, double* %21, align 8, !tbaa !5
%23 = fcmp ult double %22, 0.000000e+00
%24 = fneg double %22
%25 = select i1 %23, double %24, double %22
%26 = fcmp ugt double %25, %1
br i1 %26, label %27, label %133
27: ; preds = %18
%28 = add nuw nsw i64 %19, 1
%29 = icmp eq i64 %19, 0
br label %30
30: ; preds = %27, %45
%31 = phi i64 [ %20, %27 ], [ %49, %45 ]
%32 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %31, i64 %19
%33 = load double, double* %32, align 8, !tbaa !5
br i1 %29, label %45, label %34
34: ; preds = %30, %34
%35 = phi i64 [ %43, %34 ], [ 0, %30 ]
%36 = phi double [ %42, %34 ], [ %33, %30 ]
%37 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %31, i64 %35
%38 = load double, double* %37, align 8, !tbaa !5
%39 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %35, i64 %19
%40 = load double, double* %39, align 8, !tbaa !5
%41 = fmul double %38, %40
%42 = fsub double %36, %41
%43 = add nuw nsw i64 %35, 1
%44 = icmp eq i64 %43, %19
br i1 %44, label %45, label %34, !llvm.loop !14
45: ; preds = %34, %30
%46 = phi double [ %33, %30 ], [ %42, %34 ]
%47 = load double, double* %21, align 8, !tbaa !5
%48 = fdiv double %46, %47
store double %48, double* %32, align 8, !tbaa !5
%49 = add nuw nsw i64 %31, 1
%50 = icmp eq i64 %49, %13
br i1 %50, label %51, label %30, !llvm.loop !15
51: ; preds = %45, %66
%52 = phi i64 [ %67, %66 ], [ %20, %45 ]
%53 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %28, i64 %52
%54 = load double, double* %53, align 8, !tbaa !5
br label %55
55: ; preds = %51, %55
%56 = phi i64 [ 0, %51 ], [ %64, %55 ]
%57 = phi double [ %54, %51 ], [ %63, %55 ]
%58 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %28, i64 %56
%59 = load double, double* %58, align 8, !tbaa !5
%60 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %56, i64 %52
%61 = load double, double* %60, align 8, !tbaa !5
%62 = fmul double %59, %61
%63 = fsub double %57, %62
%64 = add nuw nsw i64 %56, 1
%65 = icmp eq i64 %64, %20
br i1 %65, label %66, label %55, !llvm.loop !16
66: ; preds = %55
store double %63, double* %53, align 8, !tbaa !5
%67 = add nuw nsw i64 %52, 1
%68 = icmp eq i64 %67, %14
br i1 %68, label %15, label %51, !llvm.loop !17
69: ; preds = %15, %8
%70 = load double, double* getelementptr inbounds ([50 x double], [50 x double]* @b, i64 0, i64 0), align 16, !tbaa !5
%71 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 0
store double %70, double* %71, align 16, !tbaa !5
%72 = icmp slt i32 %0, 1
br i1 %72, label %95, label %73
73: ; preds = %69
%74 = add i32 %0, 1
%75 = zext i32 %74 to i64
br label %76
76: ; preds = %73, %91
%77 = phi i64 [ 1, %73 ], [ %93, %91 ]
%78 = getelementptr inbounds [50 x double], [50 x double]* @b, i64 0, i64 %77
%79 = load double, double* %78, align 8, !tbaa !5
br label %80
80: ; preds = %76, %80
%81 = phi i64 [ 0, %76 ], [ %89, %80 ]
%82 = phi double [ %79, %76 ], [ %88, %80 ]
%83 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %77, i64 %81
%84 = load double, double* %83, align 8, !tbaa !5
%85 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %81
%86 = load double, double* %85, align 8, !tbaa !5
%87 = fmul double %84, %86
%88 = fsub double %82, %87
%89 = add nuw nsw i64 %81, 1
%90 = icmp eq i64 %89, %77
br i1 %90, label %91, label %80, !llvm.loop !18
91: ; preds = %80
%92 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %77
store double %88, double* %92, align 8, !tbaa !5
%93 = add nuw nsw i64 %77, 1
%94 = icmp eq i64 %93, %75
br i1 %94, label %95, label %76, !llvm.loop !19
95: ; preds = %91, %69
%96 = sext i32 %0 to i64
%97 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %96
%98 = load double, double* %97, align 8, !tbaa !5
%99 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %96, i64 %96
%100 = load double, double* %99, align 8, !tbaa !5
%101 = fdiv double %98, %100
%102 = getelementptr inbounds [50 x double], [50 x double]* @x, i64 0, i64 %96
store double %101, double* %102, align 8, !tbaa !5
%103 = icmp sgt i32 %0, 0
br i1 %103, label %104, label %133
104: ; preds = %95
%105 = sext i32 %0 to i64
%106 = add i32 %0, 1
%107 = sext i32 %0 to i64
br label %108
108: ; preds = %104, %126
%109 = phi i64 [ %105, %104 ], [ %110, %126 ]
%110 = add nsw i64 %109, -1
%111 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %110
%112 = load double, double* %111, align 8, !tbaa !5
%113 = icmp sgt i64 %109, %107
br i1 %113, label %126, label %114
114: ; preds = %108, %114
%115 = phi i64 [ %123, %114 ], [ %109, %108 ]
%116 = phi double [ %122, %114 ], [ %112, %108 ]
%117 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %110, i64 %115
%118 = load double, double* %117, align 8, !tbaa !5
%119 = getelementptr inbounds [50 x double], [50 x double]* @x, i64 0, i64 %115
%120 = load double, double* %119, align 8, !tbaa !5
%121 = fmul double %118, %120
%122 = fsub double %116, %121
%123 = add nsw i64 %115, 1
%124 = trunc i64 %123 to i32
%125 = icmp eq i32 %106, %124
br i1 %125, label %126, label %114, !llvm.loop !20
126: ; preds = %114, %108
%127 = phi double [ %112, %108 ], [ %122, %114 ]
%128 = getelementptr inbounds [50 x [50 x double]], [50 x [50 x double]]* @a, i64 0, i64 %110, i64 %110
%129 = load double, double* %128, align 8, !tbaa !5
%130 = fdiv double %127, %129
%131 = getelementptr inbounds [50 x double], [50 x double]* @x, i64 0, i64 %110
store double %130, double* %131, align 8, !tbaa !5
%132 = icmp sgt i64 %109, 1
br i1 %132, label %108, label %133, !llvm.loop !21
133: ; preds = %18, %126, %95, %2
%134 = phi i32 [ 999, %2 ], [ 0, %95 ], [ 0, %126 ], [ 1, %18 ]
call void @llvm.lifetime.end.p0i8(i64 800, i8* nonnull %4) #2
ret i32 %134
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
attributes #0 = { nofree nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
attributes #2 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10, !11}
!15 = distinct !{!15, !10, !11}
!16 = distinct !{!16, !10, !11}
!17 = distinct !{!17, !10, !11}
!18 = distinct !{!18, !10, !11}
!19 = distinct !{!19, !10, !11}
!20 = distinct !{!20, !10, !11}
!21 = distinct !{!21, !10, !11}

302
test/matmult.ll Normal file
View File

@ -0,0 +1,302 @@
; ModuleID = 'matmult.c'
source_filename = "matmult.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@ArrayA = dso_local local_unnamed_addr global [20 x [20 x i32]] zeroinitializer, align 16
@ArrayB = dso_local local_unnamed_addr global [20 x [20 x i32]] zeroinitializer, align 16
@ResultArray = dso_local local_unnamed_addr global [20 x [20 x i32]] zeroinitializer, align 16
@Seed = dso_local local_unnamed_addr global i32 0, align 4
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @main() local_unnamed_addr #0 {
store i32 0, i32* @Seed, align 4, !tbaa !5
br label %1
1: ; preds = %13, %0
%2 = phi i32 [ 0, %0 ], [ %9, %13 ]
%3 = phi i64 [ 0, %0 ], [ %14, %13 ]
br label %4
4: ; preds = %4, %1
%5 = phi i32 [ %2, %1 ], [ %9, %4 ]
%6 = phi i64 [ 0, %1 ], [ %11, %4 ]
%7 = mul nsw i32 %5, 133
%8 = add nsw i32 %7, 81
%9 = srem i32 %8, 8095
%10 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* @ArrayA, i64 0, i64 %3, i64 %6
store i32 %9, i32* %10, align 4, !tbaa !5
%11 = add nuw nsw i64 %6, 1
%12 = icmp eq i64 %11, 20
br i1 %12, label %13, label %4, !llvm.loop !9
13: ; preds = %4
%14 = add nuw nsw i64 %3, 1
%15 = icmp eq i64 %14, 20
br i1 %15, label %16, label %1, !llvm.loop !12
16: ; preds = %13
store i32 %9, i32* @Seed, align 4, !tbaa !5
br label %17
17: ; preds = %16, %29
%18 = phi i32 [ %25, %29 ], [ %9, %16 ]
%19 = phi i64 [ %30, %29 ], [ 0, %16 ]
br label %20
20: ; preds = %20, %17
%21 = phi i32 [ %18, %17 ], [ %25, %20 ]
%22 = phi i64 [ 0, %17 ], [ %27, %20 ]
%23 = mul nsw i32 %21, 133
%24 = add nsw i32 %23, 81
%25 = srem i32 %24, 8095
%26 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* @ArrayB, i64 0, i64 %19, i64 %22
store i32 %25, i32* %26, align 4, !tbaa !5
%27 = add nuw nsw i64 %22, 1
%28 = icmp eq i64 %27, 20
br i1 %28, label %29, label %20, !llvm.loop !9
29: ; preds = %20
%30 = add nuw nsw i64 %19, 1
%31 = icmp eq i64 %30, 20
br i1 %31, label %32, label %17, !llvm.loop !12
32: ; preds = %29
store i32 %25, i32* @Seed, align 4, !tbaa !5
br label %33
33: ; preds = %32, %52
%34 = phi i64 [ %53, %52 ], [ 0, %32 ]
br label %35
35: ; preds = %49, %33
%36 = phi i64 [ 0, %33 ], [ %50, %49 ]
%37 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* @ResultArray, i64 0, i64 %34, i64 %36
store i32 0, i32* %37, align 4, !tbaa !5
br label %38
38: ; preds = %38, %35
%39 = phi i32 [ 0, %35 ], [ %46, %38 ]
%40 = phi i64 [ 0, %35 ], [ %47, %38 ]
%41 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* @ArrayA, i64 0, i64 %34, i64 %40
%42 = load i32, i32* %41, align 4, !tbaa !5
%43 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* @ArrayB, i64 0, i64 %40, i64 %36
%44 = load i32, i32* %43, align 4, !tbaa !5
%45 = mul nsw i32 %44, %42
%46 = add nsw i32 %39, %45
%47 = add nuw nsw i64 %40, 1
%48 = icmp eq i64 %47, 20
br i1 %48, label %49, label %38, !llvm.loop !13
49: ; preds = %38
store i32 %46, i32* %37, align 4, !tbaa !5
%50 = add nuw nsw i64 %36, 1
%51 = icmp eq i64 %50, 20
br i1 %51, label %52, label %35, !llvm.loop !14
52: ; preds = %49
%53 = add nuw nsw i64 %34, 1
%54 = icmp eq i64 %53, 20
br i1 %54, label %55, label %33, !llvm.loop !15
55: ; preds = %52
ret void
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn writeonly
define dso_local void @InitSeed() local_unnamed_addr #1 {
store i32 0, i32* @Seed, align 4, !tbaa !5
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @Test([20 x i32]* nocapture %0, [20 x i32]* nocapture %1, [20 x i32]* nocapture %2) local_unnamed_addr #0 {
br label %4
4: ; preds = %15, %3
%5 = phi i64 [ 0, %3 ], [ %16, %15 ]
br label %6
6: ; preds = %6, %4
%7 = phi i64 [ 0, %4 ], [ %13, %6 ]
%8 = load i32, i32* @Seed, align 4, !tbaa !5
%9 = mul nsw i32 %8, 133
%10 = add nsw i32 %9, 81
%11 = srem i32 %10, 8095
store i32 %11, i32* @Seed, align 4, !tbaa !5
%12 = getelementptr inbounds [20 x i32], [20 x i32]* %0, i64 %5, i64 %7
store i32 %11, i32* %12, align 4, !tbaa !5
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, 20
br i1 %14, label %15, label %6, !llvm.loop !9
15: ; preds = %6
%16 = add nuw nsw i64 %5, 1
%17 = icmp eq i64 %16, 20
br i1 %17, label %18, label %4, !llvm.loop !12
18: ; preds = %15, %29
%19 = phi i64 [ %30, %29 ], [ 0, %15 ]
br label %20
20: ; preds = %20, %18
%21 = phi i64 [ 0, %18 ], [ %27, %20 ]
%22 = load i32, i32* @Seed, align 4, !tbaa !5
%23 = mul nsw i32 %22, 133
%24 = add nsw i32 %23, 81
%25 = srem i32 %24, 8095
store i32 %25, i32* @Seed, align 4, !tbaa !5
%26 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 %19, i64 %21
store i32 %25, i32* %26, align 4, !tbaa !5
%27 = add nuw nsw i64 %21, 1
%28 = icmp eq i64 %27, 20
br i1 %28, label %29, label %20, !llvm.loop !9
29: ; preds = %20
%30 = add nuw nsw i64 %19, 1
%31 = icmp eq i64 %30, 20
br i1 %31, label %32, label %18, !llvm.loop !12
32: ; preds = %29, %51
%33 = phi i64 [ %52, %51 ], [ 0, %29 ]
br label %34
34: ; preds = %48, %32
%35 = phi i64 [ 0, %32 ], [ %49, %48 ]
%36 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 %33, i64 %35
store i32 0, i32* %36, align 4, !tbaa !5
br label %37
37: ; preds = %37, %34
%38 = phi i64 [ 0, %34 ], [ %46, %37 ]
%39 = getelementptr inbounds [20 x i32], [20 x i32]* %0, i64 %33, i64 %38
%40 = load i32, i32* %39, align 4, !tbaa !5
%41 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 %38, i64 %35
%42 = load i32, i32* %41, align 4, !tbaa !5
%43 = mul nsw i32 %42, %40
%44 = load i32, i32* %36, align 4, !tbaa !5
%45 = add nsw i32 %44, %43
store i32 %45, i32* %36, align 4, !tbaa !5
%46 = add nuw nsw i64 %38, 1
%47 = icmp eq i64 %46, 20
br i1 %47, label %48, label %37, !llvm.loop !13
48: ; preds = %37
%49 = add nuw nsw i64 %35, 1
%50 = icmp eq i64 %49, 20
br i1 %50, label %51, label %34, !llvm.loop !14
51: ; preds = %48
%52 = add nuw nsw i64 %33, 1
%53 = icmp eq i64 %52, 20
br i1 %53, label %54, label %32, !llvm.loop !15
54: ; preds = %51
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @Initialize([20 x i32]* nocapture %0) local_unnamed_addr #0 {
br label %2
2: ; preds = %1, %13
%3 = phi i64 [ 0, %1 ], [ %14, %13 ]
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 0, %2 ], [ %11, %4 ]
%6 = load i32, i32* @Seed, align 4, !tbaa !5
%7 = mul nsw i32 %6, 133
%8 = add nsw i32 %7, 81
%9 = srem i32 %8, 8095
store i32 %9, i32* @Seed, align 4, !tbaa !5
%10 = getelementptr inbounds [20 x i32], [20 x i32]* %0, i64 %3, i64 %5
store i32 %9, i32* %10, align 4, !tbaa !5
%11 = add nuw nsw i64 %5, 1
%12 = icmp eq i64 %11, 20
br i1 %12, label %13, label %4, !llvm.loop !9
13: ; preds = %4
%14 = add nuw nsw i64 %3, 1
%15 = icmp eq i64 %14, 20
br i1 %15, label %16, label %2, !llvm.loop !12
16: ; preds = %13
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @Multiply([20 x i32]* nocapture readonly %0, [20 x i32]* nocapture readonly %1, [20 x i32]* nocapture %2) local_unnamed_addr #0 {
br label %4
4: ; preds = %3, %23
%5 = phi i64 [ 0, %3 ], [ %24, %23 ]
br label %6
6: ; preds = %4, %20
%7 = phi i64 [ 0, %4 ], [ %21, %20 ]
%8 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 %5, i64 %7
store i32 0, i32* %8, align 4, !tbaa !5
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %18, %9 ]
%11 = getelementptr inbounds [20 x i32], [20 x i32]* %0, i64 %5, i64 %10
%12 = load i32, i32* %11, align 4, !tbaa !5
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 %10, i64 %7
%14 = load i32, i32* %13, align 4, !tbaa !5
%15 = mul nsw i32 %14, %12
%16 = load i32, i32* %8, align 4, !tbaa !5
%17 = add nsw i32 %16, %15
store i32 %17, i32* %8, align 4, !tbaa !5
%18 = add nuw nsw i64 %10, 1
%19 = icmp eq i64 %18, 20
br i1 %19, label %20, label %9, !llvm.loop !13
20: ; preds = %9
%21 = add nuw nsw i64 %7, 1
%22 = icmp eq i64 %21, 20
br i1 %22, label %23, label %6, !llvm.loop !14
23: ; preds = %20
%24 = add nuw nsw i64 %5, 1
%25 = icmp eq i64 %24, 20
br i1 %25, label %26, label %4, !llvm.loop !15
26: ; preds = %23
ret void
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn
define dso_local i32 @RandomInteger() local_unnamed_addr #2 {
%1 = load i32, i32* @Seed, align 4, !tbaa !5
%2 = mul nsw i32 %1, 133
%3 = add nsw i32 %2, 81
%4 = srem i32 %3, 8095
store i32 %4, i32* @Seed, align 4, !tbaa !5
ret i32 %4
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn writeonly "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10, !11}
!15 = distinct !{!15, !10, !11}

403
test/minver.ll Normal file
View File

@ -0,0 +1,403 @@
; ModuleID = 'minver.c'
source_filename = "minver.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@a = internal unnamed_addr global [3 x [3 x double]] [[3 x double] [double 3.000000e+00, double -6.000000e+00, double 7.000000e+00], [3 x double] [double 9.000000e+00, double 0.000000e+00, double -5.000000e+00], [3 x double] [double 5.000000e+00, double -8.000000e+00, double 6.000000e+00]], align 16
@aa = dso_local local_unnamed_addr global [3 x [3 x double]] zeroinitializer, align 16
@a_i = dso_local local_unnamed_addr global [3 x [3 x double]] zeroinitializer, align 16
@b = dso_local local_unnamed_addr global [3 x [3 x double]] zeroinitializer, align 16
@c = dso_local local_unnamed_addr global [3 x [3 x double]] zeroinitializer, align 16
@det = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@e = dso_local local_unnamed_addr global [3 x [3 x double]] zeroinitializer, align 16
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn
define dso_local double @minver_fabs(double %0) local_unnamed_addr #0 {
%2 = fcmp ult double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
ret double %4
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 16 dereferenceable(72) bitcast ([3 x [3 x double]]* @aa to i8*), i8* noundef nonnull align 16 dereferenceable(72) bitcast ([3 x [3 x double]]* @a to i8*), i64 72, i1 false)
%1 = call i32 @minver(i32 3, i32 3, double 0x3EB0C6F7A0B5ED8D)
call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 16 dereferenceable(72) bitcast ([3 x [3 x double]]* @a_i to i8*), i8* noundef nonnull align 16 dereferenceable(72) bitcast ([3 x [3 x double]]* @a to i8*), i64 72, i1 false)
br label %2
2: ; preds = %0, %21
%3 = phi i64 [ %22, %21 ], [ 0, %0 ]
br label %4
4: ; preds = %17, %2
%5 = phi i64 [ 0, %2 ], [ %19, %17 ]
br label %6
6: ; preds = %6, %4
%7 = phi i64 [ 0, %4 ], [ %15, %6 ]
%8 = phi double [ 0.000000e+00, %4 ], [ %14, %6 ]
%9 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %3, i64 %7
%10 = load double, double* %9, align 8, !tbaa !5
%11 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @b, i64 0, i64 %7, i64 %5
%12 = load double, double* %11, align 8, !tbaa !5
%13 = fmul double %10, %12
%14 = fadd double %8, %13
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, 3
br i1 %16, label %17, label %6, !llvm.loop !9
17: ; preds = %6
%18 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @c, i64 0, i64 %3, i64 %5
store double %14, double* %18, align 8, !tbaa !5
%19 = add nuw nsw i64 %5, 1
%20 = icmp eq i64 %19, 3
br i1 %20, label %21, label %4, !llvm.loop !12
21: ; preds = %17
%22 = add nuw nsw i64 %3, 1
%23 = icmp eq i64 %22, 3
br i1 %23, label %24, label %2, !llvm.loop !13
24: ; preds = %21
ret i32 0
}
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local i32 @minver(i32 %0, i32 %1, double %2) local_unnamed_addr #2 {
%4 = alloca [500 x i32], align 16
%5 = bitcast [500 x i32]* %4 to i8*
call void @llvm.lifetime.start.p0i8(i64 2000, i8* nonnull %5) #5
%6 = add i32 %0, -2
%7 = icmp ugt i32 %6, 498
%8 = fcmp ole double %2, 0.000000e+00
%9 = select i1 %7, i1 true, i1 %8
br i1 %9, label %155, label %10
10: ; preds = %3
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = zext i32 %0 to i64
br label %27
14: ; preds = %27, %10
%15 = icmp sgt i32 %0, 0
%16 = icmp sgt i32 %0, 0
%17 = icmp sgt i32 %0, 0
%18 = icmp sgt i32 %0, 0
%19 = icmp sgt i32 %0, 0
br i1 %19, label %20, label %37
20: ; preds = %14
%21 = zext i32 %0 to i64
%22 = zext i32 %0 to i64
%23 = zext i32 %0 to i64
%24 = zext i32 %0 to i64
%25 = zext i32 %0 to i64
%26 = zext i32 %0 to i64
br label %33
27: ; preds = %12, %27
%28 = phi i64 [ 0, %12 ], [ %31, %27 ]
%29 = getelementptr inbounds [500 x i32], [500 x i32]* %4, i64 0, i64 %28
%30 = trunc i64 %28 to i32
store i32 %30, i32* %29, align 4, !tbaa !14
%31 = add nuw nsw i64 %28, 1
%32 = icmp eq i64 %31, %13
br i1 %32, label %14, label %27, !llvm.loop !16
33: ; preds = %20, %121
%34 = phi i64 [ 0, %20 ], [ %124, %121 ]
%35 = phi double [ 1.000000e+00, %20 ], [ %85, %121 ]
%36 = phi i32 [ undef, %20 ], [ %54, %121 ]
br label %43
37: ; preds = %121, %14
%38 = phi double [ 1.000000e+00, %14 ], [ %85, %121 ]
%39 = icmp sgt i32 %0, 0
%40 = icmp sgt i32 %0, 0
br i1 %40, label %41, label %152
41: ; preds = %37
%42 = zext i32 %0 to i64
br label %126
43: ; preds = %33, %43
%44 = phi i64 [ %34, %33 ], [ %56, %43 ]
%45 = phi double [ 0.000000e+00, %33 ], [ %55, %43 ]
%46 = phi i32 [ %36, %33 ], [ %54, %43 ]
%47 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %44, i64 %34
%48 = load double, double* %47, align 8, !tbaa !5
%49 = fcmp ult double %48, 0.000000e+00
%50 = fneg double %48
%51 = select i1 %49, double %50, double %48
%52 = fcmp ogt double %51, %45
%53 = trunc i64 %44 to i32
%54 = select i1 %52, i32 %53, i32 %46
%55 = select i1 %52, double %51, double %45
%56 = add nuw nsw i64 %44, 1
%57 = icmp eq i64 %56, %22
br i1 %57, label %58, label %43, !llvm.loop !17
58: ; preds = %43
%59 = sext i32 %54 to i64
%60 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %59, i64 %34
%61 = load double, double* %60, align 8, !tbaa !5
%62 = fcmp ult double %61, 0.000000e+00
%63 = fneg double %61
%64 = select i1 %62, double %63, double %61
%65 = fcmp ugt double %64, %2
br i1 %65, label %66, label %152
66: ; preds = %58
%67 = fmul double %35, %61
%68 = zext i32 %54 to i64
%69 = icmp eq i64 %34, %68
br i1 %69, label %84, label %70
70: ; preds = %66
%71 = fneg double %51
%72 = getelementptr inbounds [500 x i32], [500 x i32]* %4, i64 0, i64 %34
%73 = load i32, i32* %72, align 4, !tbaa !14
%74 = getelementptr inbounds [500 x i32], [500 x i32]* %4, i64 0, i64 %59
%75 = load i32, i32* %74, align 4, !tbaa !14
store i32 %75, i32* %72, align 4, !tbaa !14
store i32 %73, i32* %74, align 4, !tbaa !14
br i1 %15, label %76, label %84
76: ; preds = %70, %76
%77 = phi i64 [ %82, %76 ], [ 0, %70 ]
%78 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %34, i64 %77
%79 = load double, double* %78, align 8, !tbaa !5
%80 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %59, i64 %77
%81 = load double, double* %80, align 8, !tbaa !5
store double %81, double* %78, align 8, !tbaa !5
store double %79, double* %80, align 8, !tbaa !5
%82 = add nuw nsw i64 %77, 1
%83 = icmp eq i64 %82, %23
br i1 %83, label %84, label %76, !llvm.loop !18
84: ; preds = %76, %70, %66
%85 = phi double [ %67, %66 ], [ %71, %70 ], [ %71, %76 ]
br i1 %16, label %87, label %86
86: ; preds = %87, %84
br i1 %18, label %94, label %121
87: ; preds = %84, %87
%88 = phi i64 [ %92, %87 ], [ 0, %84 ]
%89 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %34, i64 %88
%90 = load double, double* %89, align 8, !tbaa !5
%91 = fdiv double %90, %61
store double %91, double* %89, align 8, !tbaa !5
%92 = add nuw nsw i64 %88, 1
%93 = icmp eq i64 %92, %24
br i1 %93, label %86, label %87, !llvm.loop !19
94: ; preds = %86, %118
%95 = phi i64 [ %119, %118 ], [ 0, %86 ]
%96 = icmp eq i64 %95, %34
br i1 %96, label %118, label %97
97: ; preds = %94
%98 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %95, i64 %34
%99 = load double, double* %98, align 8, !tbaa !5
%100 = fcmp une double %99, 0.000000e+00
br i1 %100, label %101, label %118
101: ; preds = %97
br i1 %17, label %102, label %115
102: ; preds = %101, %112
%103 = phi i64 [ %113, %112 ], [ 0, %101 ]
%104 = icmp eq i64 %103, %34
br i1 %104, label %112, label %105
105: ; preds = %102
%106 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %34, i64 %103
%107 = load double, double* %106, align 8, !tbaa !5
%108 = fmul double %99, %107
%109 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %95, i64 %103
%110 = load double, double* %109, align 8, !tbaa !5
%111 = fsub double %110, %108
store double %111, double* %109, align 8, !tbaa !5
br label %112
112: ; preds = %102, %105
%113 = add nuw nsw i64 %103, 1
%114 = icmp eq i64 %113, %26
br i1 %114, label %115, label %102, !llvm.loop !20
115: ; preds = %112, %101
%116 = fneg double %99
%117 = fdiv double %116, %61
store double %117, double* %98, align 8, !tbaa !5
br label %118
118: ; preds = %94, %115, %97
%119 = add nuw nsw i64 %95, 1
%120 = icmp eq i64 %119, %25
br i1 %120, label %121, label %94, !llvm.loop !21
121: ; preds = %118, %86
%122 = fdiv double 1.000000e+00, %61
%123 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %34, i64 %34
store double %122, double* %123, align 8, !tbaa !5
%124 = add nuw nsw i64 %34, 1
%125 = icmp eq i64 %124, %21
br i1 %125, label %37, label %33, !llvm.loop !22
126: ; preds = %41, %149
%127 = phi i64 [ 0, %41 ], [ %150, %149 ]
%128 = getelementptr inbounds [500 x i32], [500 x i32]* %4, i64 0, i64 %127
%129 = load i32, i32* %128, align 4, !tbaa !14
%130 = zext i32 %129 to i64
%131 = icmp eq i64 %127, %130
br i1 %131, label %149, label %136
132: ; preds = %143, %136
%133 = load i32, i32* %128, align 4, !tbaa !14
%134 = zext i32 %133 to i64
%135 = icmp eq i64 %127, %134
br i1 %135, label %149, label %136, !llvm.loop !23
136: ; preds = %126, %132
%137 = phi i32 [ %133, %132 ], [ %129, %126 ]
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds [500 x i32], [500 x i32]* %4, i64 0, i64 %138
%140 = load i32, i32* %139, align 4, !tbaa !14
store i32 %137, i32* %139, align 4, !tbaa !14
store i32 %140, i32* %128, align 4, !tbaa !14
%141 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %138, i64 %127
%142 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %138, i64 %138
br i1 %39, label %143, label %132
143: ; preds = %136, %143
%144 = phi i32 [ %147, %143 ], [ 0, %136 ]
%145 = load double, double* %141, align 8, !tbaa !5
%146 = load double, double* %142, align 8, !tbaa !5
store double %146, double* %141, align 8, !tbaa !5
store double %145, double* %142, align 8, !tbaa !5
%147 = add nuw nsw i32 %144, 1
%148 = icmp eq i32 %147, %0
br i1 %148, label %132, label %143, !llvm.loop !24
149: ; preds = %132, %126
%150 = add nuw nsw i64 %127, 1
%151 = icmp eq i64 %150, %42
br i1 %151, label %152, label %126, !llvm.loop !25
152: ; preds = %58, %149, %37
%153 = phi double [ %38, %37 ], [ %38, %149 ], [ %35, %58 ]
%154 = phi i32 [ 0, %37 ], [ 0, %149 ], [ 1, %58 ]
store double %153, double* @det, align 8, !tbaa !5
br label %155
155: ; preds = %152, %3
%156 = phi i32 [ 999, %3 ], [ %154, %152 ]
call void @llvm.lifetime.end.p0i8(i64 2000, i8* nonnull %5) #5
ret i32 %156
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @mmul(i32 %0, i32 %1, i32 %2, i32 %3) local_unnamed_addr #3 {
%5 = icmp sgt i32 %0, 0
%6 = icmp sgt i32 %2, 0
%7 = select i1 %5, i1 %6, i1 false
%8 = icmp sgt i32 %3, 0
%9 = select i1 %7, i1 %8, i1 false
%10 = icmp eq i32 %1, %2
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %12, label %38
12: ; preds = %4
%13 = zext i32 %0 to i64
%14 = zext i32 %3 to i64
%15 = zext i32 %2 to i64
br label %16
16: ; preds = %12, %35
%17 = phi i64 [ 0, %12 ], [ %36, %35 ]
br label %18
18: ; preds = %16, %31
%19 = phi i64 [ 0, %16 ], [ %33, %31 ]
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %29, %20 ]
%22 = phi double [ 0.000000e+00, %18 ], [ %28, %20 ]
%23 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @a, i64 0, i64 %17, i64 %21
%24 = load double, double* %23, align 8, !tbaa !5
%25 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @b, i64 0, i64 %21, i64 %19
%26 = load double, double* %25, align 8, !tbaa !5
%27 = fmul double %24, %26
%28 = fadd double %22, %27
%29 = add nuw nsw i64 %21, 1
%30 = icmp eq i64 %29, %15
br i1 %30, label %31, label %20, !llvm.loop !9
31: ; preds = %20
%32 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* @c, i64 0, i64 %17, i64 %19
store double %28, double* %32, align 8, !tbaa !5
%33 = add nuw nsw i64 %19, 1
%34 = icmp eq i64 %33, %14
br i1 %34, label %35, label %18, !llvm.loop !12
35: ; preds = %31
%36 = add nuw nsw i64 %17, 1
%37 = icmp eq i64 %36, %13
br i1 %37, label %38, label %16, !llvm.loop !13
38: ; preds = %35, %4
%39 = phi i32 [ 999, %4 ], [ 0, %35 ]
ret i32 %39
}
; Function Attrs: argmemonly nofree nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #4
attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
attributes #2 = { nofree nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { argmemonly nofree nounwind willreturn }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}
!13 = distinct !{!13, !10, !11}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = distinct !{!16, !10, !11}
!17 = distinct !{!17, !10, !11}
!18 = distinct !{!18, !10, !11}
!19 = distinct !{!19, !10, !11}
!20 = distinct !{!20, !10, !11}
!21 = distinct !{!21, !10, !11}
!22 = distinct !{!22, !10, !11}
!23 = distinct !{!23, !11}
!24 = distinct !{!24, !10, !11}
!25 = distinct !{!25, !10, !11}

590
test/ndes.ll Normal file
View File

@ -0,0 +1,590 @@
; ModuleID = 'ndes.c'
source_filename = "ndes.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.GREAT = type { i64, i64, i64 }
%struct.IMMENSE = type { i64, i64 }
@des.ip = internal unnamed_addr constant [65 x i8] c"\00:2*\22\1A\12\0A\02<4,$\1C\14\0C\04>6.&\1E\16\0E\06@80( \18\10\0891)!\19\11\09\01;3+#\1B\13\0B\03=5-%\1D\15\0D\05?7/'\1F\17\0F\07", align 16
@des.ipm = internal unnamed_addr constant [65 x i8] c"\00(\080\108\18@ '\07/\0F7\17?\1F&\06.\0E6\16>\1E%\05-\0D5\15=\1D$\04,\0C4\14<\1C#\03+\0B3\13;\1B\22\02*\0A2\12:\1A!\01)\091\119\19", align 16
@des.kns = internal global [17 x %struct.GREAT] zeroinitializer, align 16
@des.initflag = internal unnamed_addr global i1 false, align 4
@bit = dso_local local_unnamed_addr global [33 x i64] zeroinitializer, align 16
@icd = internal unnamed_addr global %struct.IMMENSE zeroinitializer, align 8
@ipc1 = internal unnamed_addr constant [57 x i8] c"\0091)!\19\11\09\01:2*\22\1A\12\0A\02;3+#\1B\13\0B\03<4,$?7/'\1F\17\0F\07>6.&\1E\16\0E\06=5-%\1D\15\0D\05\1C\14\0C\04", align 16
@ipc2 = internal unnamed_addr constant [49 x i8] c"\00\0E\11\0B\18\01\05\03\1C\0F\06\15\0A\17\13\0C\04\1A\08\10\07\1B\14\0D\02)4\1F%/7\1E(3-!0,1'8\225.*2$\1D ", align 16
@cyfun.iet = internal unnamed_addr constant [49 x i32] [i32 0, i32 32, i32 1, i32 2, i32 3, i32 4, i32 5, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 28, i32 29, i32 30, i32 31, i32 32, i32 1], align 16
@cyfun.ipp = internal unnamed_addr constant [33 x i32] [i32 0, i32 16, i32 7, i32 20, i32 21, i32 29, i32 12, i32 28, i32 17, i32 1, i32 15, i32 23, i32 26, i32 5, i32 18, i32 31, i32 10, i32 2, i32 8, i32 24, i32 14, i32 32, i32 27, i32 3, i32 9, i32 19, i32 13, i32 30, i32 6, i32 22, i32 11, i32 4, i32 25], align 16
@cyfun.is = internal unnamed_addr constant [16 x [4 x [9 x i8]]] [[4 x [9 x i8]] [[9 x i8] c"\00\0E\0F\0A\07\02\0C\04\0D", [9 x i8] c"\00\00\03\0D\0D\0E\0A\0D\01", [9 x i8] c"\00\04\00\0D\0A\04\09\01\07", [9 x i8] c"\00\0F\0D\01\03\0B\04\06\02"], [4 x [9 x i8]] [[9 x i8] c"\00\04\01\00\0D\0C\01\0B\02", [9 x i8] c"\00\0F\0D\07\08\0B\0F\00\0F", [9 x i8] c"\00\01\0E\06\06\02\0E\04\0B", [9 x i8] c"\00\0C\08\0A\0F\08\03\0B\01"], [4 x [9 x i8]] [[9 x i8] c"\00\0D\08\09\0E\04\0A\02\08", [9 x i8] c"\00\07\04\00\0B\02\04\0B\0D", [9 x i8] c"\00\0E\07\04\09\01\0F\0B\04", [9 x i8] c"\00\08\0A\0D\00\0C\02\0D\0E"], [4 x [9 x i8]] [[9 x i8] c"\00\01\0E\0E\03\01\0F\0E\04", [9 x i8] c"\00\04\07\09\05\0C\02\07\08", [9 x i8] c"\00\08\0B\09\00\0B\05\0D\01", [9 x i8] c"\00\02\01\00\06\07\0C\08\07"], [4 x [9 x i8]] [[9 x i8] c"\00\02\06\06\00\07\09\0F\06", [9 x i8] c"\00\0E\0F\03\06\04\07\04\0A", [9 x i8] c"\00\0D\0A\08\0C\0A\02\0C\09", [9 x i8] c"\00\04\03\06\0A\01\09\01\04"], [4 x [9 x i8]] [[9 x i8] c"\00\0F\0B\03\06\0A\02\00\0F", [9 x i8] c"\00\02\02\04\0F\07\0C\09\03", [9 x i8] c"\00\06\04\0F\0B\0D\08\03\0C", [9 x i8] c"\00\09\0F\09\01\0E\05\04\0A"], [4 x [9 x i8]] [[9 x i8] c"\00\0B\03\0F\09\0B\06\08\0B", [9 x i8] c"\00\0D\08\06\00\0D\09\01\07", [9 x i8] c"\00\02\0D\03\07\07\0C\07\0E", [9 x i8] c"\00\01\04\08\0D\02\0F\0A\08"], [4 x [9 x i8]] [[9 x i8] c"\00\08\04\05\0A\06\08\0D\01", [9 x i8] c"\00\01\0E\0A\03\01\05\0A\04", [9 x i8] c"\00\0B\01\00\0D\08\03\0E\02", [9 x i8] c"\00\07\02\07\08\0D\0A\07\0D"], [4 x [9 x i8]] [[9 x i8] c"\00\03\09\01\01\08\00\03\0A", [9 x i8] c"\00\0A\0C\02\04\05\06\0E\0C", [9 x i8] c"\00\0F\05\0B\0F\0F\07\0A\00", [9 x i8] c"\00\05\0B\04\09\06\0B\09\0F"], [4 x [9 x i8]] [[9 x i8] c"\00\0A\07\0D\02\05\0D\0C\09", [9 x i8] c"\00\06\00\08\07\00\01\03\05", [9 x i8] c"\00\0C\08\01\01\09\00\0F\06", [9 x i8] c"\00\0B\06\0F\04\0F\0E\05\0C"], [4 x [9 x i8]] [[9 x i8] c"\00\06\02\0C\08\03\03\09\03", [9 x i8] c"\00\0C\01\05\02\0F\0D\05\06", [9 x i8] c"\00\09\0C\02\03\0C\04\06\0A", [9 x i8] c"\00\03\07\0E\05\00\01\00\09"], [4 x [9 x i8]] [[9 x i8] c"\00\0C\0D\07\05\0F\04\07\0E", [9 x i8] c"\00\0B\0A\0E\0C\0A\0E\0C\0B", [9 x i8] c"\00\07\06\0C\0E\05\0A\08\0D", [9 x i8] c"\00\0E\0C\03\0B\09\07\0F\00"], [4 x [9 x i8]] [[9 x i8] c"\00\05\0C\0B\0B\0D\0E\05\05", [9 x i8] c"\00\09\06\0C\01\03\00\02\00", [9 x i8] c"\00\03\09\05\05\06\01\00\0F", [9 x i8] c"\00\0A\00\0B\0C\0A\06\0E\03"], [4 x [9 x i8]] [[9 x i8] c"\00\09\00\04\0C\00\07\0A\00", [9 x i8] c"\00\05\09\0B\0A\09\0B\0F\0E", [9 x i8] c"\00\0A\03\0A\02\03\0D\05\03", [9 x i8] c"\00\00\05\05\07\04\00\02\05"], [4 x [9 x i8]] [[9 x i8] c"\00\00\05\02\04\0E\05\06\0C", [9 x i8] c"\00\03\0B\0F\0E\08\03\08\09", [9 x i8] c"\00\05\02\0E\08\00\0B\09\05", [9 x i8] c"\00\06\0E\02\02\05\08\03\06"], [4 x [9 x i8]] [[9 x i8] c"\00\07\0A\08\0F\09\0B\01\07", [9 x i8] c"\00\08\05\01\09\06\08\06\02", [9 x i8] c"\00\00\0F\07\04\0E\06\02\08", [9 x i8] c"\00\0D\09\0C\0E\03\0D\0C\0B"]], align 16
@cyfun.ibin = internal unnamed_addr constant [16 x i8] c"\00\08\04\0C\02\0A\06\0E\01\09\05\0D\03\0B\07\0F", align 16
@value = dso_local local_unnamed_addr global i32 1, align 4
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local void @des(i64 %0, i64 %1, i64 %2, i64 %3, i32* nocapture %4, i32 %5, %struct.IMMENSE* nocapture %6) local_unnamed_addr #0 {
%8 = alloca i64, align 8
%9 = alloca %struct.GREAT, align 8
%10 = bitcast i64* %8 to i8*
call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %10) #6
%11 = bitcast %struct.GREAT* %9 to i8*
call void @llvm.lifetime.start.p0i8(i64 24, i8* nonnull %11) #6
%12 = load i1, i1* @des.initflag, align 4
br i1 %12, label %21, label %13
13: ; preds = %7
store i1 true, i1* @des.initflag, align 4
store i64 1, i64* getelementptr inbounds ([33 x i64], [33 x i64]* @bit, i64 0, i64 1), align 8, !tbaa !5
br label %14
14: ; preds = %13, %14
%15 = phi i64 [ 2, %13 ], [ %19, %14 ]
%16 = phi i64 [ 1, %13 ], [ %17, %14 ]
%17 = shl i64 %16, 1
%18 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %15
store i64 %17, i64* %18, align 8, !tbaa !5
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, 33
br i1 %20, label %21, label %14, !llvm.loop !9
21: ; preds = %14, %7
%22 = load i32, i32* %4, align 4, !tbaa !12
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %67, %21
br label %76
25: ; preds = %21
store i32 0, i32* %4, align 4, !tbaa !12
call void @llvm.memset.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(16) bitcast (%struct.IMMENSE* @icd to i8*), i8 0, i64 16, i1 false)
br label %27
26: ; preds = %27
store i64 %47, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 1), align 8, !tbaa !14
store i64 %63, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 0), align 8, !tbaa !16
br label %67
27: ; preds = %25, %27
%28 = phi i64 [ 28, %25 ], [ %64, %27 ]
%29 = phi i64 [ 56, %25 ], [ %65, %27 ]
%30 = phi i64 [ 0, %25 ], [ %47, %27 ]
%31 = phi i64 [ 0, %25 ], [ %63, %27 ]
%32 = shl i64 %30, 1
%33 = getelementptr inbounds [57 x i8], [57 x i8]* @ipc1, i64 0, i64 %28
%34 = load i8, i8* %33, align 1, !tbaa !17
%35 = lshr i64 529835723988510, %28
%36 = and i64 %35, 1
%37 = icmp eq i64 %36, 0
%38 = sext i8 %34 to i64
%39 = add nsw i64 %38, -32
%40 = select i1 %37, i64 %38, i64 %39
%41 = select i1 %37, i64 %3, i64 %2
%42 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %40
%43 = load i64, i64* %42, align 8, !tbaa !5
%44 = and i64 %43, %41
%45 = icmp ne i64 %44, 0
%46 = zext i1 %45 to i64
%47 = or i64 %32, %46
%48 = shl i64 %31, 1
%49 = getelementptr inbounds [57 x i8], [57 x i8]* @ipc1, i64 0, i64 %29
%50 = load i8, i8* %49, align 1, !tbaa !17
%51 = lshr i64 529835723988510, %29
%52 = and i64 %51, 1
%53 = icmp eq i64 %52, 0
%54 = sext i8 %50 to i64
%55 = add nsw i64 %54, -32
%56 = select i1 %53, i64 %54, i64 %55
%57 = select i1 %53, i64 %3, i64 %2
%58 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %56
%59 = load i64, i64* %58, align 8, !tbaa !5
%60 = and i64 %59, %57
%61 = icmp ne i64 %60, 0
%62 = zext i1 %61 to i64
%63 = or i64 %48, %62
%64 = add nsw i64 %28, -1
%65 = add nsw i64 %29, -1
%66 = icmp ugt i64 %28, 1
br i1 %66, label %27, label %26, !llvm.loop !18
67: ; preds = %26, %67
%68 = phi i64 [ 1, %26 ], [ %72, %67 ]
%69 = getelementptr inbounds [17 x %struct.GREAT], [17 x %struct.GREAT]* @des.kns, i64 0, i64 %68
%70 = bitcast %struct.GREAT* %69 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(24) %11, i8* noundef nonnull align 8 dereferenceable(24) %70, i64 24, i1 false), !tbaa.struct !19
%71 = trunc i64 %68 to i32
call void @ks(i32 %71, %struct.GREAT* nonnull %9)
call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(24) %70, i8* noundef nonnull align 8 dereferenceable(24) %11, i64 24, i1 false), !tbaa.struct !19
%72 = add nuw nsw i64 %68, 1
%73 = icmp eq i64 %72, 17
br i1 %73, label %24, label %67, !llvm.loop !20
74: ; preds = %76
%75 = icmp eq i32 %5, 1
br label %112
76: ; preds = %24, %76
%77 = phi i64 [ %109, %76 ], [ 32, %24 ]
%78 = phi i64 [ %110, %76 ], [ 64, %24 ]
%79 = phi i64 [ %108, %76 ], [ 0, %24 ]
%80 = phi i64 [ %94, %76 ], [ 0, %24 ]
%81 = shl i64 %80, 1
%82 = getelementptr inbounds [65 x i8], [65 x i8]* @des.ip, i64 0, i64 %77
%83 = load i8, i8* %82, align 1, !tbaa !17
%84 = icmp sgt i8 %83, 32
%85 = sext i8 %83 to i64
%86 = add nsw i64 %85, -32
%87 = select i1 %84, i64 %86, i64 %85
%88 = select i1 %84, i64 %0, i64 %1
%89 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %87
%90 = load i64, i64* %89, align 8, !tbaa !5
%91 = and i64 %90, %88
%92 = icmp ne i64 %91, 0
%93 = zext i1 %92 to i64
%94 = or i64 %81, %93
%95 = shl i64 %79, 1
%96 = getelementptr inbounds [65 x i8], [65 x i8]* @des.ip, i64 0, i64 %78
%97 = load i8, i8* %96, align 1, !tbaa !17
%98 = icmp sgt i8 %97, 32
%99 = sext i8 %97 to i64
%100 = add nsw i64 %99, -32
%101 = select i1 %98, i64 %100, i64 %99
%102 = select i1 %98, i64 %0, i64 %1
%103 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %101
%104 = load i64, i64* %103, align 8, !tbaa !5
%105 = and i64 %104, %102
%106 = icmp ne i64 %105, 0
%107 = zext i1 %106 to i64
%108 = or i64 %95, %107
%109 = add nsw i64 %77, -1
%110 = add nsw i64 %78, -1
%111 = icmp ugt i64 %77, 1
br i1 %111, label %76, label %74, !llvm.loop !21
112: ; preds = %74, %112
%113 = phi i64 [ %108, %74 ], [ %121, %112 ]
%114 = phi i64 [ %94, %74 ], [ %113, %112 ]
%115 = phi i32 [ 1, %74 ], [ %122, %112 ]
%116 = sub nuw nsw i32 17, %115
%117 = select i1 %75, i32 %116, i32 %115
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [17 x %struct.GREAT], [17 x %struct.GREAT]* @des.kns, i64 0, i64 %118
call void @cyfun(i64 %113, %struct.GREAT* nonnull byval(%struct.GREAT) align 8 %119, i64* nonnull %8)
%120 = load i64, i64* %8, align 8, !tbaa !5
%121 = xor i64 %120, %114
store i64 %121, i64* %8, align 8, !tbaa !5
%122 = add nuw nsw i32 %115, 1
%123 = icmp eq i32 %122, 17
br i1 %123, label %124, label %112, !llvm.loop !22
124: ; preds = %112
store i64 %113, i64* %8, align 8, !tbaa !5
%125 = getelementptr inbounds %struct.IMMENSE, %struct.IMMENSE* %6, i64 0, i32 0
%126 = getelementptr inbounds %struct.IMMENSE, %struct.IMMENSE* %6, i64 0, i32 1
%127 = bitcast %struct.IMMENSE* %6 to i8*
call void @llvm.memset.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(16) %127, i8 0, i64 16, i1 false)
br label %128
128: ; preds = %124, %128
%129 = phi i64 [ 32, %124 ], [ %161, %128 ]
%130 = phi i64 [ 64, %124 ], [ %162, %128 ]
%131 = load i64, i64* %126, align 8, !tbaa !14
%132 = shl i64 %131, 1
store i64 %132, i64* %126, align 8, !tbaa !14
%133 = getelementptr inbounds [65 x i8], [65 x i8]* @des.ipm, i64 0, i64 %129
%134 = load i8, i8* %133, align 1, !tbaa !17
%135 = icmp sgt i8 %134, 32
%136 = sext i8 %134 to i64
%137 = add nsw i64 %136, -32
%138 = select i1 %135, i64 %137, i64 %136
%139 = select i1 %135, i64 %113, i64 %121
%140 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %138
%141 = load i64, i64* %140, align 8, !tbaa !5
%142 = and i64 %141, %139
%143 = icmp ne i64 %142, 0
%144 = zext i1 %143 to i64
%145 = or i64 %132, %144
store i64 %145, i64* %126, align 8, !tbaa !14
%146 = load i64, i64* %125, align 8, !tbaa !16
%147 = shl i64 %146, 1
store i64 %147, i64* %125, align 8, !tbaa !16
%148 = getelementptr inbounds [65 x i8], [65 x i8]* @des.ipm, i64 0, i64 %130
%149 = load i8, i8* %148, align 1, !tbaa !17
%150 = icmp sgt i8 %149, 32
%151 = sext i8 %149 to i64
%152 = add nsw i64 %151, -32
%153 = select i1 %150, i64 %152, i64 %151
%154 = select i1 %150, i64 %113, i64 %121
%155 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %153
%156 = load i64, i64* %155, align 8, !tbaa !5
%157 = and i64 %156, %154
%158 = icmp ne i64 %157, 0
%159 = zext i1 %158 to i64
%160 = or i64 %147, %159
store i64 %160, i64* %125, align 8, !tbaa !16
%161 = add nsw i64 %129, -1
%162 = add nsw i64 %130, -1
%163 = icmp ugt i64 %129, 1
br i1 %163, label %128, label %164, !llvm.loop !23
164: ; preds = %128
call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %11) #6
call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %10) #6
ret void
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: mustprogress nofree norecurse nosync nounwind readonly sspstrong uwtable willreturn
define dso_local i64 @getbit(i64 %0, i64 %1, i32 %2, i32 %3) local_unnamed_addr #2 {
%5 = icmp sgt i32 %2, %3
%6 = select i1 %5, i32 %3, i32 0
%7 = sub nsw i32 %2, %6
%8 = select i1 %5, i64 %0, i64 %1
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %9
%11 = load i64, i64* %10, align 8, !tbaa !5
%12 = and i64 %11, %8
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i64
ret i64 %14
}
; Function Attrs: argmemonly mustprogress nofree nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #3
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @ks(i32 %0, %struct.GREAT* nocapture %1) local_unnamed_addr #4 {
switch i32 %0, label %3 [
i32 16, label %6
i32 9, label %6
i32 2, label %6
i32 1, label %6
]
3: ; preds = %2
%4 = load i64, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 1), align 8, !tbaa !14
%5 = load i64, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 0), align 8, !tbaa !16
br label %17
6: ; preds = %2, %2, %2, %2
%7 = load i64, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 1), align 8, !tbaa !14
%8 = shl i64 %7, 28
%9 = and i64 %8, 268435456
%10 = or i64 %9, %7
%11 = lshr i64 %10, 1
store i64 %11, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 1), align 8, !tbaa !14
%12 = load i64, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 0), align 8, !tbaa !16
%13 = shl i64 %12, 28
%14 = and i64 %13, 268435456
%15 = or i64 %14, %12
%16 = lshr i64 %15, 1
br label %32
17: ; preds = %3, %17
%18 = phi i32 [ 1, %3 ], [ %29, %17 ]
%19 = phi i64 [ %4, %3 ], [ %24, %17 ]
%20 = phi i64 [ %5, %3 ], [ %28, %17 ]
%21 = shl i64 %19, 28
%22 = and i64 %21, 268435456
%23 = or i64 %22, %19
%24 = lshr i64 %23, 1
%25 = shl i64 %20, 28
%26 = and i64 %25, 268435456
%27 = or i64 %26, %20
%28 = lshr i64 %27, 1
%29 = add nuw nsw i32 %18, 1
%30 = icmp eq i32 %29, 3
br i1 %30, label %31, label %17, !llvm.loop !24
31: ; preds = %17
store i64 %24, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 1), align 8, !tbaa !14
br label %32
32: ; preds = %31, %6
%33 = phi i64 [ %16, %6 ], [ %28, %31 ]
store i64 %33, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 0), align 8, !tbaa !16
%34 = getelementptr inbounds %struct.GREAT, %struct.GREAT* %1, i64 0, i32 0
%35 = getelementptr inbounds %struct.GREAT, %struct.GREAT* %1, i64 0, i32 1
%36 = getelementptr inbounds %struct.GREAT, %struct.GREAT* %1, i64 0, i32 2
%37 = bitcast %struct.GREAT* %1 to i8*
call void @llvm.memset.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(24) %37, i8 0, i64 24, i1 false)
%38 = load i64, i64* getelementptr inbounds (%struct.IMMENSE, %struct.IMMENSE* @icd, i64 0, i32 1), align 8
br label %39
39: ; preds = %32, %39
%40 = phi i64 [ 16, %32 ], [ %82, %39 ]
%41 = phi i64 [ 32, %32 ], [ %83, %39 ]
%42 = phi i64 [ 48, %32 ], [ %84, %39 ]
%43 = load i64, i64* %36, align 8, !tbaa !25
%44 = shl i64 %43, 1
store i64 %44, i64* %36, align 8, !tbaa !25
%45 = getelementptr inbounds [49 x i8], [49 x i8]* @ipc2, i64 0, i64 %40
%46 = load i8, i8* %45, align 1, !tbaa !17
%47 = sext i8 %46 to i64
%48 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %47
%49 = load i64, i64* %48, align 8, !tbaa !5
%50 = and i64 %49, %38
%51 = icmp ne i64 %50, 0
%52 = zext i1 %51 to i64
%53 = or i64 %44, %52
store i64 %53, i64* %36, align 8, !tbaa !25
%54 = load i64, i64* %35, align 8, !tbaa !27
%55 = shl i64 %54, 1
store i64 %55, i64* %35, align 8, !tbaa !27
%56 = getelementptr inbounds [49 x i8], [49 x i8]* @ipc2, i64 0, i64 %41
%57 = load i8, i8* %56, align 1, !tbaa !17
%58 = add nsw i64 %41, -25
%59 = icmp ult i64 %58, 24
%60 = sext i8 %57 to i64
%61 = add nsw i64 %60, -28
%62 = select i1 %59, i64 %61, i64 %60
%63 = select i1 %59, i64 %33, i64 %38
%64 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %62
%65 = load i64, i64* %64, align 8, !tbaa !5
%66 = and i64 %65, %63
%67 = icmp ne i64 %66, 0
%68 = zext i1 %67 to i64
%69 = or i64 %55, %68
store i64 %69, i64* %35, align 8, !tbaa !27
%70 = load i64, i64* %34, align 8, !tbaa !28
%71 = shl i64 %70, 1
store i64 %71, i64* %34, align 8, !tbaa !28
%72 = getelementptr inbounds [49 x i8], [49 x i8]* @ipc2, i64 0, i64 %42
%73 = load i8, i8* %72, align 1, !tbaa !17
%74 = sext i8 %73 to i64
%75 = add nsw i64 %74, -28
%76 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %75
%77 = load i64, i64* %76, align 8, !tbaa !5
%78 = and i64 %77, %33
%79 = icmp ne i64 %78, 0
%80 = zext i1 %79 to i64
%81 = or i64 %71, %80
store i64 %81, i64* %34, align 8, !tbaa !28
%82 = add nsw i64 %40, -1
%83 = add nsw i64 %41, -1
%84 = add nsw i64 %42, -1
%85 = icmp ugt i64 %40, 1
br i1 %85, label %39, label %86, !llvm.loop !29
86: ; preds = %39
ret void
}
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local void @cyfun(i64 %0, %struct.GREAT* nocapture readonly byval(%struct.GREAT) align 8 %1, i64* nocapture %2) local_unnamed_addr #0 {
%4 = alloca [9 x i8], align 1
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
call void @llvm.lifetime.start.p0i8(i64 9, i8* nonnull %5) #6
br label %6
6: ; preds = %3, %6
%7 = phi i64 [ 16, %3 ], [ %43, %6 ]
%8 = phi i64 [ 32, %3 ], [ %44, %6 ]
%9 = phi i64 [ 48, %3 ], [ %45, %6 ]
%10 = phi i64 [ 0, %3 ], [ %22, %6 ]
%11 = phi i64 [ 0, %3 ], [ %32, %6 ]
%12 = phi i64 [ 0, %3 ], [ %42, %6 ]
%13 = shl i64 %10, 1
%14 = getelementptr inbounds [49 x i32], [49 x i32]* @cyfun.iet, i64 0, i64 %7
%15 = load i32, i32* %14, align 4, !tbaa !12
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %16
%18 = load i64, i64* %17, align 8, !tbaa !5
%19 = and i64 %18, %0
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i64
%22 = or i64 %13, %21
%23 = shl i64 %11, 1
%24 = getelementptr inbounds [49 x i32], [49 x i32]* @cyfun.iet, i64 0, i64 %8
%25 = load i32, i32* %24, align 4, !tbaa !12
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %26
%28 = load i64, i64* %27, align 8, !tbaa !5
%29 = and i64 %28, %0
%30 = icmp ne i64 %29, 0
%31 = zext i1 %30 to i64
%32 = or i64 %23, %31
%33 = shl i64 %12, 1
%34 = getelementptr inbounds [49 x i32], [49 x i32]* @cyfun.iet, i64 0, i64 %9
%35 = load i32, i32* %34, align 4, !tbaa !12
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %36
%38 = load i64, i64* %37, align 8, !tbaa !5
%39 = and i64 %38, %0
%40 = icmp ne i64 %39, 0
%41 = zext i1 %40 to i64
%42 = or i64 %33, %41
%43 = add nsw i64 %7, -1
%44 = add nsw i64 %8, -1
%45 = add nsw i64 %9, -1
%46 = icmp ugt i64 %7, 1
br i1 %46, label %6, label %47, !llvm.loop !30
47: ; preds = %6
%48 = getelementptr inbounds %struct.GREAT, %struct.GREAT* %1, i64 0, i32 2
%49 = load i64, i64* %48, align 8, !tbaa !25
%50 = xor i64 %49, %22
%51 = getelementptr inbounds %struct.GREAT, %struct.GREAT* %1, i64 0, i32 1
%52 = load i64, i64* %51, align 8, !tbaa !27
%53 = xor i64 %52, %32
%54 = getelementptr inbounds %struct.GREAT, %struct.GREAT* %1, i64 0, i32 0
%55 = load i64, i64* %54, align 8, !tbaa !28
%56 = xor i64 %55, %42
%57 = shl i64 %53, 16
%58 = add i64 %57, %50
%59 = shl i64 %56, 8
%60 = lshr i64 %53, 8
%61 = add i64 %59, %60
br label %62
62: ; preds = %47, %62
%63 = phi i64 [ 1, %47 ], [ %75, %62 ]
%64 = phi i64 [ 5, %47 ], [ %76, %62 ]
%65 = phi i64 [ %61, %47 ], [ %74, %62 ]
%66 = phi i64 [ %58, %47 ], [ %73, %62 ]
%67 = trunc i64 %66 to i8
%68 = and i8 %67, 63
%69 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 %63
store i8 %68, i8* %69, align 1, !tbaa !17
%70 = trunc i64 %65 to i8
%71 = and i8 %70, 63
%72 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 %64
store i8 %71, i8* %72, align 1, !tbaa !17
%73 = lshr i64 %66, 6
%74 = lshr i64 %65, 6
%75 = add nuw nsw i64 %63, 1
%76 = add nuw nsw i64 %64, 1
%77 = icmp eq i64 %75, 5
br i1 %77, label %78, label %62, !llvm.loop !31
78: ; preds = %62, %78
%79 = phi i64 [ %109, %78 ], [ 8, %62 ]
%80 = phi i64 [ %108, %78 ], [ 0, %62 ]
%81 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 %79
%82 = load i8, i8* %81, align 1, !tbaa !17
%83 = sext i8 %82 to i32
%84 = shl nsw i32 %83, 1
%85 = and i32 %84, 2
%86 = lshr i32 %83, 5
%87 = and i32 %86, 1
%88 = or i32 %85, %87
%89 = shl nsw i32 %83, 2
%90 = and i32 %89, 8
%91 = and i32 %83, 4
%92 = or i32 %90, %91
%93 = lshr i32 %83, 2
%94 = and i32 %93, 2
%95 = or i32 %92, %94
%96 = lshr i32 %83, 4
%97 = and i32 %96, 1
%98 = or i32 %95, %97
%99 = zext i32 %98 to i64
%100 = zext i32 %88 to i64
%101 = getelementptr inbounds [16 x [4 x [9 x i8]]], [16 x [4 x [9 x i8]]]* @cyfun.is, i64 0, i64 %99, i64 %100, i64 %79
%102 = load i8, i8* %101, align 1, !tbaa !17
%103 = shl i64 %80, 4
%104 = sext i8 %102 to i64
%105 = getelementptr inbounds [16 x i8], [16 x i8]* @cyfun.ibin, i64 0, i64 %104
%106 = load i8, i8* %105, align 1, !tbaa !17
%107 = sext i8 %106 to i64
%108 = or i64 %103, %107
%109 = add nsw i64 %79, -1
%110 = icmp ugt i64 %79, 1
br i1 %110, label %78, label %111, !llvm.loop !32
111: ; preds = %78
store i64 0, i64* %2, align 8, !tbaa !5
br label %112
112: ; preds = %111, %112
%113 = phi i64 [ 32, %111 ], [ %125, %112 ]
%114 = load i64, i64* %2, align 8, !tbaa !5
%115 = shl i64 %114, 1
store i64 %115, i64* %2, align 8, !tbaa !5
%116 = getelementptr inbounds [33 x i32], [33 x i32]* @cyfun.ipp, i64 0, i64 %113
%117 = load i32, i32* %116, align 4, !tbaa !12
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [33 x i64], [33 x i64]* @bit, i64 0, i64 %118
%120 = load i64, i64* %119, align 8, !tbaa !5
%121 = and i64 %120, %108
%122 = icmp ne i64 %121, 0
%123 = zext i1 %122 to i64
%124 = or i64 %115, %123
store i64 %124, i64* %2, align 8, !tbaa !5
%125 = add nsw i64 %113, -1
%126 = icmp ugt i64 %113, 1
br i1 %126, label %112, label %127, !llvm.loop !33
127: ; preds = %112
call void @llvm.lifetime.end.p0i8(i64 9, i8* nonnull %5) #6
ret void
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
%1 = alloca %struct.IMMENSE, align 8
%2 = alloca i32, align 4
%3 = bitcast %struct.IMMENSE* %1 to i8*
call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %3) #6
%4 = bitcast i32* %2 to i8*
call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #6
%5 = load i32, i32* @value, align 4, !tbaa !12
store i32 %5, i32* %2, align 4, !tbaa !12
call void @des(i64 35, i64 26, i64 2, i64 16, i32* nonnull %2, i32 %5, %struct.IMMENSE* nonnull %1)
call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #6
call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %3) #6
ret i32 0
}
; Function Attrs: argmemonly nofree nounwind willreturn writeonly
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #5
attributes #0 = { nofree nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
attributes #2 = { mustprogress nofree norecurse nosync nounwind readonly sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { argmemonly mustprogress nofree nounwind willreturn }
attributes #4 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { argmemonly nofree nounwind willreturn writeonly }
attributes #6 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"IMMENSE", !6, i64 0, !6, i64 8}
!16 = !{!15, !6, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !10, !11}
!19 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5}
!20 = distinct !{!20, !10, !11}
!21 = distinct !{!21, !10, !11}
!22 = distinct !{!22, !10, !11}
!23 = distinct !{!23, !10, !11}
!24 = distinct !{!24, !10, !11}
!25 = !{!26, !6, i64 16}
!26 = !{!"GREAT", !6, i64 0, !6, i64 8, !6, i64 16}
!27 = !{!26, !6, i64 8}
!28 = !{!26, !6, i64 0}
!29 = distinct !{!29, !10, !11}
!30 = distinct !{!30, !10, !11}
!31 = distinct !{!31, !10, !11}
!32 = distinct !{!32, !10, !11}
!33 = distinct !{!33, !10, !11}

133
test/ns.ll Normal file

File diff suppressed because one or more lines are too long

6705
test/nsichneu.ll Normal file

File diff suppressed because it is too large Load Diff

122
test/prime.ll Normal file
View File

@ -0,0 +1,122 @@
; ModuleID = 'prime.c'
source_filename = "prime.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn
define dso_local zeroext i8 @divides(i32 %0, i32 %1) local_unnamed_addr #0 {
%3 = urem i32 %1, %0
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i8
ret i8 %5
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn
define dso_local zeroext i8 @even(i32 %0) local_unnamed_addr #0 {
%2 = trunc i32 %0 to i8
%3 = and i8 %2, 1
%4 = xor i8 %3, 1
ret i8 %4
}
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local zeroext i8 @prime(i32 %0) local_unnamed_addr #1 {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = icmp ult i32 %0, 9
br i1 %5, label %16, label %11
6: ; preds = %1
%7 = icmp eq i32 %0, 2
br label %18
8: ; preds = %11
%9 = mul i32 %15, %15
%10 = icmp ugt i32 %9, %0
br i1 %10, label %16, label %11, !llvm.loop !5
11: ; preds = %4, %8
%12 = phi i32 [ %15, %8 ], [ 3, %4 ]
%13 = urem i32 %0, %12
%14 = icmp eq i32 %13, 0
%15 = add i32 %12, 2
br i1 %14, label %18, label %8
16: ; preds = %8, %4
%17 = icmp ugt i32 %0, 1
br label %18
18: ; preds = %11, %16, %6
%19 = phi i1 [ %7, %6 ], [ %17, %16 ], [ false, %11 ]
%20 = zext i1 %19 to i8
ret i8 %20
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn
define dso_local void @swap(i32* nocapture %0, i32* nocapture %1) local_unnamed_addr #2 {
%3 = load i32, i32* %0, align 4, !tbaa !8
%4 = load i32, i32* %1, align 4, !tbaa !8
store i32 %4, i32* %0, align 4, !tbaa !8
store i32 %3, i32* %1, align 4, !tbaa !8
ret void
}
; Function Attrs: nofree nosync nounwind readnone sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 3, %0 ], [ %5, %1 ]
%3 = urem i32 513239, %2
%4 = icmp eq i32 %3, 0
%5 = add nuw nsw i32 %2, 2
%6 = mul i32 %5, %5
%7 = icmp ugt i32 %6, 513239
%8 = select i1 %4, i1 true, i1 %7
br i1 %8, label %9, label %1, !llvm.loop !5
9: ; preds = %1
br i1 %4, label %20, label %10
10: ; preds = %9, %10
%11 = phi i32 [ %14, %10 ], [ 3, %9 ]
%12 = urem i32 21649, %11
%13 = icmp eq i32 %12, 0
%14 = add nuw nsw i32 %11, 2
%15 = mul i32 %14, %14
%16 = icmp ugt i32 %15, 21649
%17 = select i1 %13, i1 true, i1 %16
br i1 %17, label %18, label %10, !llvm.loop !5
18: ; preds = %10
%19 = zext i1 %13 to i32
br label %20
20: ; preds = %18, %9
%21 = phi i32 [ 1, %9 ], [ %19, %18 ]
ret i32 %21
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree norecurse nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.unroll.disable"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}

232
test/qsort-exam.ll Normal file
View File

@ -0,0 +1,232 @@
; ModuleID = 'qsort-exam.c'
source_filename = "qsort-exam.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@arr = dso_local local_unnamed_addr global [20 x float] [float 5.000000e+00, float 4.000000e+00, float 0x40249999A0000000, float 0x3FF19999A0000000, float 0x4016CCCCC0000000, float 1.000000e+02, float 2.310000e+02, float 1.110000e+02, float 4.950000e+01, float 9.900000e+01, float 1.000000e+01, float 1.500000e+02, float 0x406BC70A40000000, float 1.010000e+02, float 7.700000e+01, float 4.400000e+01, float 3.500000e+01, float 0x40348A3D80000000, float 0x4058FF5C20000000, float 0x40563851E0000000], align 16
@istack = dso_local local_unnamed_addr global [100 x i32] zeroinitializer, align 16
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local void @sort(i64 %0) local_unnamed_addr #0 {
br label %2
2: ; preds = %50, %1
%3 = phi i64 [ %0, %1 ], [ %51, %50 ]
%4 = phi i64 [ 1, %1 ], [ %52, %50 ]
%5 = phi i32 [ 0, %1 ], [ %53, %50 ]
%6 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %3
br label %7
7: ; preds = %2, %111
%8 = phi i64 [ %84, %111 ], [ %4, %2 ]
%9 = phi i32 [ %98, %111 ], [ %5, %2 ]
%10 = sub i64 %3, %8
%11 = icmp ult i64 %10, 7
br i1 %11, label %12, label %54
12: ; preds = %7
%13 = add i64 %8, 1
%14 = icmp ugt i64 %13, %3
br i1 %14, label %37, label %15
15: ; preds = %12, %31
%16 = phi i64 [ %35, %31 ], [ %13, %12 ]
%17 = phi i64 [ %16, %31 ], [ %8, %12 ]
%18 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %16
%19 = load float, float* %18, align 4, !tbaa !5
%20 = icmp ult i64 %17, %8
br i1 %20, label %31, label %21
21: ; preds = %15, %26
%22 = phi i64 [ %29, %26 ], [ %17, %15 ]
%23 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %22
%24 = load float, float* %23, align 4, !tbaa !5
%25 = fcmp ugt float %24, %19
br i1 %25, label %26, label %31
26: ; preds = %21
%27 = add i64 %22, 1
%28 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %27
store float %24, float* %28, align 4, !tbaa !5
%29 = add i64 %22, -1
%30 = icmp ult i64 %29, %8
br i1 %30, label %31, label %21, !llvm.loop !9
31: ; preds = %26, %21, %15
%32 = phi i64 [ %17, %15 ], [ %29, %26 ], [ %22, %21 ]
%33 = add i64 %32, 1
%34 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %33
store float %19, float* %34, align 4, !tbaa !5
%35 = add i64 %16, 1
%36 = icmp ugt i64 %35, %3
br i1 %36, label %37, label %15, !llvm.loop !12
37: ; preds = %31, %12
%38 = icmp eq i32 %9, 0
br i1 %38, label %120, label %39
39: ; preds = %37
%40 = add nsw i32 %9, -1
%41 = sext i32 %9 to i64
%42 = getelementptr inbounds [100 x i32], [100 x i32]* @istack, i64 0, i64 %41
%43 = load i32, i32* %42, align 4, !tbaa !13
%44 = sext i32 %43 to i64
%45 = add nsw i32 %9, -2
%46 = sext i32 %40 to i64
%47 = getelementptr inbounds [100 x i32], [100 x i32]* @istack, i64 0, i64 %46
%48 = load i32, i32* %47, align 4, !tbaa !13
%49 = sext i32 %48 to i64
br label %50
50: ; preds = %39, %102
%51 = phi i64 [ %110, %102 ], [ %44, %39 ]
%52 = phi i64 [ %8, %102 ], [ %49, %39 ]
%53 = phi i32 [ %98, %102 ], [ %45, %39 ]
br label %2, !llvm.loop !15
54: ; preds = %7
%55 = add i64 %8, %3
%56 = lshr i64 %55, 1
%57 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %56
%58 = load float, float* %57, align 4, !tbaa !5
%59 = add i64 %8, 1
%60 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %59
%61 = load float, float* %60, align 4, !tbaa !5
store float %61, float* %57, align 4, !tbaa !5
store float %58, float* %60, align 4, !tbaa !5
%62 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %8
%63 = load float, float* %62, align 4, !tbaa !5
%64 = load float, float* %6, align 4, !tbaa !5
%65 = fcmp ogt float %63, %64
br i1 %65, label %66, label %67
66: ; preds = %54
store float %64, float* %62, align 4, !tbaa !5
store float %63, float* %6, align 4, !tbaa !5
br label %67
67: ; preds = %66, %54
%68 = load float, float* %60, align 4, !tbaa !5
%69 = load float, float* %6, align 4, !tbaa !5
%70 = fcmp ogt float %68, %69
br i1 %70, label %71, label %72
71: ; preds = %67
store float %69, float* %60, align 4, !tbaa !5
store float %68, float* %6, align 4, !tbaa !5
br label %72
72: ; preds = %71, %67
%73 = load float, float* %62, align 4, !tbaa !5
%74 = load float, float* %60, align 4, !tbaa !5
%75 = fcmp ogt float %73, %74
br i1 %75, label %76, label %77
76: ; preds = %72
store float %74, float* %62, align 4, !tbaa !5
store float %73, float* %60, align 4, !tbaa !5
br label %77
77: ; preds = %76, %72
%78 = load float, float* %60, align 4, !tbaa !5
br label %79
79: ; preds = %96, %77
%80 = phi i64 [ %3, %77 ], [ %90, %96 ]
%81 = phi i64 [ %59, %77 ], [ %84, %96 ]
br label %82
82: ; preds = %82, %79
%83 = phi i64 [ %81, %79 ], [ %84, %82 ]
%84 = add i64 %83, 1
%85 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %84
%86 = load float, float* %85, align 4, !tbaa !5
%87 = fcmp olt float %86, %78
br i1 %87, label %82, label %88, !llvm.loop !16
88: ; preds = %82, %88
%89 = phi i64 [ %90, %88 ], [ %80, %82 ]
%90 = add i64 %89, -1
%91 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %90
%92 = load float, float* %91, align 4, !tbaa !5
%93 = fcmp ogt float %92, %78
br i1 %93, label %88, label %94, !llvm.loop !17
94: ; preds = %88
%95 = icmp ult i64 %90, %84
br i1 %95, label %97, label %96
96: ; preds = %94
store float %92, float* %85, align 4, !tbaa !5
store float %86, float* %91, align 4, !tbaa !5
br label %79, !llvm.loop !18
97: ; preds = %94
store float %92, float* %60, align 4, !tbaa !5
store float %78, float* %91, align 4, !tbaa !5
%98 = add nsw i32 %9, 2
%99 = sub i64 %3, %83
%100 = sub i64 %90, %8
%101 = icmp ult i64 %99, %100
br i1 %101, label %111, label %102
102: ; preds = %97
%103 = trunc i64 %3 to i32
%104 = sext i32 %98 to i64
%105 = getelementptr inbounds [100 x i32], [100 x i32]* @istack, i64 0, i64 %104
store i32 %103, i32* %105, align 4, !tbaa !13
%106 = trunc i64 %84 to i32
%107 = add nsw i32 %9, 1
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [100 x i32], [100 x i32]* @istack, i64 0, i64 %108
store i32 %106, i32* %109, align 4, !tbaa !13
%110 = add i64 %89, -2
br label %50
111: ; preds = %97
%112 = trunc i64 %89 to i32
%113 = add i32 %112, -2
%114 = sext i32 %98 to i64
%115 = getelementptr inbounds [100 x i32], [100 x i32]* @istack, i64 0, i64 %114
store i32 %113, i32* %115, align 4, !tbaa !13
%116 = trunc i64 %8 to i32
%117 = add nsw i32 %9, 1
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [100 x i32], [100 x i32]* @istack, i64 0, i64 %118
store i32 %116, i32* %119, align 4, !tbaa !13
br label %7, !llvm.loop !15
120: ; preds = %37
ret void
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
call void @sort(i64 20)
ret i32 0
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !10, !11}
!17 = distinct !{!17, !10, !11}
!18 = distinct !{!18, !11}

207
test/qurt.ll Normal file
View File

@ -0,0 +1,207 @@
; ModuleID = 'qurt.c'
source_filename = "qurt.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@a = dso_local local_unnamed_addr global [3 x double] zeroinitializer, align 16
@flag = dso_local local_unnamed_addr global i32 0, align 4
@x1 = dso_local local_unnamed_addr global [2 x double] zeroinitializer, align 16
@x2 = dso_local local_unnamed_addr global [2 x double] zeroinitializer, align 16
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn
define dso_local double @qurt_fabs(double %0) local_unnamed_addr #0 {
%2 = fcmp ult double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
ret double %4
}
; Function Attrs: nofree norecurse nosync nounwind readnone sspstrong uwtable
define dso_local double @qurt_sqrt(double %0) local_unnamed_addr #1 {
%2 = fcmp oeq double %0, 0.000000e+00
br i1 %2, label %28, label %3
3: ; preds = %1
%4 = fdiv double %0, 1.000000e+01
br label %5
5: ; preds = %3, %23
%6 = phi i32 [ 0, %3 ], [ %25, %23 ]
%7 = phi i32 [ 1, %3 ], [ %26, %23 ]
%8 = phi double [ %4, %3 ], [ %24, %23 ]
%9 = icmp eq i32 %6, 0
br i1 %9, label %10, label %23
10: ; preds = %5
%11 = fmul double %8, %8
%12 = fsub double %0, %11
%13 = fmul double %8, 2.000000e+00
%14 = fdiv double %12, %13
%15 = fadd double %8, %14
%16 = fmul double %15, %15
%17 = fsub double %0, %16
%18 = fcmp ult double %17, 0.000000e+00
%19 = fneg double %17
%20 = select i1 %18, double %19, double %17
%21 = fcmp ugt double %20, 1.000000e-05
br i1 %21, label %23, label %22
22: ; preds = %10
br label %23
23: ; preds = %22, %10, %5
%24 = phi double [ %8, %5 ], [ %15, %22 ], [ %15, %10 ]
%25 = phi i32 [ 1, %5 ], [ 1, %22 ], [ 0, %10 ]
%26 = add nuw nsw i32 %7, 1
%27 = icmp eq i32 %26, 20
br i1 %27, label %28, label %5, !llvm.loop !5
28: ; preds = %23, %1
%29 = phi double [ 0.000000e+00, %1 ], [ %24, %23 ]
ret double %29
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
store double 1.000000e+00, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 0), align 16, !tbaa !8
store double -3.000000e+00, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 1), align 8, !tbaa !8
store double 2.000000e+00, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 2), align 16, !tbaa !8
%1 = call i32 @qurt()
store double 1.000000e+00, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 0), align 16, !tbaa !8
store double -2.000000e+00, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 1), align 8, !tbaa !8
store double 1.000000e+00, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 2), align 16, !tbaa !8
%2 = call i32 @qurt()
store double 1.000000e+00, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 0), align 16, !tbaa !8
store double -4.000000e+00, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 1), align 8, !tbaa !8
store double 8.000000e+00, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 2), align 16, !tbaa !8
%3 = call i32 @qurt()
ret i32 0
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @qurt() local_unnamed_addr #2 {
%1 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 0), align 16, !tbaa !8
%2 = fcmp oeq double %1, 0.000000e+00
br i1 %2, label %61, label %3
3: ; preds = %0
%4 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 1), align 8, !tbaa !8
%5 = fmul double %4, %4
%6 = fmul double %1, 4.000000e+00
%7 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @a, i64 0, i64 2), align 16, !tbaa !8
%8 = fmul double %6, %7
%9 = fsub double %5, %8
%10 = fmul double %1, 2.000000e+00
%11 = fcmp ult double %9, 0.000000e+00
%12 = fneg double %9
%13 = select i1 %11, double %12, double %9
%14 = fcmp oeq double %13, 0.000000e+00
br i1 %14, label %40, label %15
15: ; preds = %3
%16 = fdiv double %13, 1.000000e+01
br label %17
17: ; preds = %35, %15
%18 = phi i32 [ 0, %15 ], [ %37, %35 ]
%19 = phi i32 [ 1, %15 ], [ %38, %35 ]
%20 = phi double [ %16, %15 ], [ %36, %35 ]
%21 = icmp eq i32 %18, 0
br i1 %21, label %22, label %35
22: ; preds = %17
%23 = fmul double %20, %20
%24 = fsub double %13, %23
%25 = fmul double %20, 2.000000e+00
%26 = fdiv double %24, %25
%27 = fadd double %20, %26
%28 = fmul double %27, %27
%29 = fsub double %13, %28
%30 = fcmp ult double %29, 0.000000e+00
%31 = fneg double %29
%32 = select i1 %30, double %31, double %29
%33 = fcmp ugt double %32, 1.000000e-05
br i1 %33, label %35, label %34
34: ; preds = %22
br label %35
35: ; preds = %34, %22, %17
%36 = phi double [ %20, %17 ], [ %27, %34 ], [ %27, %22 ]
%37 = phi i32 [ 1, %17 ], [ 1, %34 ], [ 0, %22 ]
%38 = add nuw nsw i32 %19, 1
%39 = icmp eq i32 %38, 20
br i1 %39, label %40, label %17, !llvm.loop !5
40: ; preds = %35, %3
%41 = phi double [ 0.000000e+00, %3 ], [ %36, %35 ]
%42 = fcmp ogt double %9, 0.000000e+00
br i1 %42, label %43, label %49
43: ; preds = %40
store i32 1, i32* @flag, align 4, !tbaa !12
%44 = fsub double %41, %4
%45 = fdiv double %44, %10
store double %45, double* getelementptr inbounds ([2 x double], [2 x double]* @x1, i64 0, i64 0), align 16, !tbaa !8
store double 0.000000e+00, double* getelementptr inbounds ([2 x double], [2 x double]* @x1, i64 0, i64 1), align 8, !tbaa !8
%46 = fneg double %4
%47 = fsub double %46, %41
%48 = fdiv double %47, %10
store double %48, double* getelementptr inbounds ([2 x double], [2 x double]* @x2, i64 0, i64 0), align 16, !tbaa !8
br label %59
49: ; preds = %40
%50 = fcmp oeq double %9, 0.000000e+00
br i1 %50, label %51, label %54
51: ; preds = %49
store i32 0, i32* @flag, align 4, !tbaa !12
%52 = fneg double %4
%53 = fdiv double %52, %10
store double %53, double* getelementptr inbounds ([2 x double], [2 x double]* @x1, i64 0, i64 0), align 16, !tbaa !8
store double 0.000000e+00, double* getelementptr inbounds ([2 x double], [2 x double]* @x1, i64 0, i64 1), align 8, !tbaa !8
store double %53, double* getelementptr inbounds ([2 x double], [2 x double]* @x2, i64 0, i64 0), align 16, !tbaa !8
br label %59
54: ; preds = %49
store i32 -1, i32* @flag, align 4, !tbaa !12
%55 = fdiv double %41, %10
%56 = fneg double %4
%57 = fdiv double %56, %10
store double %57, double* getelementptr inbounds ([2 x double], [2 x double]* @x1, i64 0, i64 0), align 16, !tbaa !8
store double %55, double* getelementptr inbounds ([2 x double], [2 x double]* @x1, i64 0, i64 1), align 8, !tbaa !8
store double %57, double* getelementptr inbounds ([2 x double], [2 x double]* @x2, i64 0, i64 0), align 16, !tbaa !8
%58 = fneg double %55
br label %59
59: ; preds = %43, %51, %54
%60 = phi double [ %58, %54 ], [ 0.000000e+00, %51 ], [ 0.000000e+00, %43 ]
store double %60, double* getelementptr inbounds ([2 x double], [2 x double]* @x2, i64 0, i64 1), align 8, !tbaa !8
br label %61
61: ; preds = %59, %0
%62 = phi i32 [ 999, %0 ], [ 0, %59 ]
ret i32 %62
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree norecurse nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.unroll.disable"}
!8 = !{!9, !9, i64 0}
!9 = !{!"double", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !10, i64 0}

82
test/recursion.ll Normal file
View File

@ -0,0 +1,82 @@
; ModuleID = 'recursion.c'
source_filename = "recursion.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@In = external global i32, align 4
; Function Attrs: nofree nosync nounwind readnone sspstrong uwtable
define dso_local i32 @fib(i32 %0) local_unnamed_addr #0 {
%2 = icmp ult i32 %0, 2
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = add nsw i32 %0, -1
%5 = call i32 @fib(i32 %4)
%6 = add nsw i32 %0, -2
%7 = call i32 @fib(i32 %6)
%8 = add nsw i32 %7, %5
br label %9
9: ; preds = %1, %3
%10 = phi i32 [ %8, %3 ], [ 1, %1 ]
ret i32 %10
}
; Function Attrs: nofree nosync nounwind readnone sspstrong uwtable
define dso_local i32 @kalle(i32 %0) local_unnamed_addr #0 {
%2 = icmp slt i32 %0, 1
br i1 %2, label %8, label %3
3: ; preds = %1
%4 = icmp eq i32 %0, 1
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = add nsw i32 %0, -2
%7 = call i32 @kalle(i32 %6) #2
br label %8
8: ; preds = %5, %3, %1
%9 = phi i32 [ 0, %1 ], [ %7, %5 ], [ 1, %3 ]
ret i32 %9
}
; Function Attrs: nofree nosync nounwind readnone sspstrong uwtable
define dso_local i32 @anka(i32 %0) local_unnamed_addr #0 {
%2 = icmp slt i32 %0, 1
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = add nsw i32 %0, -1
%5 = call i32 @kalle(i32 %4)
br label %6
6: ; preds = %1, %3
%7 = phi i32 [ %5, %3 ], [ 1, %1 ]
ret i32 %7
}
; Function Attrs: nofree nounwind sspstrong uwtable
define dso_local void @main() local_unnamed_addr #1 {
%1 = call i32 @fib(i32 10)
store volatile i32 %1, i32* @In, align 4, !tbaa !5
ret void
}
attributes #0 = { nofree nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}

172
test/select.ll Normal file
View File

@ -0,0 +1,172 @@
; ModuleID = 'select.c'
source_filename = "select.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@arr = dso_local local_unnamed_addr global [20 x float] [float 5.000000e+00, float 4.000000e+00, float 0x40249999A0000000, float 0x3FF19999A0000000, float 0x4016CCCCC0000000, float 1.000000e+02, float 2.310000e+02, float 1.110000e+02, float 4.950000e+01, float 9.900000e+01, float 1.000000e+01, float 1.500000e+02, float 0x406BC70A40000000, float 1.010000e+02, float 7.700000e+01, float 4.400000e+01, float 3.500000e+01, float 0x40348A3D80000000, float 0x4058FF5C20000000, float 0x408BC70A40000000], align 16
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local float @select(i64 %0, i64 %1) local_unnamed_addr #0 {
br label %3
3: ; preds = %2, %79
%4 = phi i32 [ 0, %2 ], [ %83, %79 ]
%5 = phi i64 [ %1, %2 ], [ %81, %79 ]
%6 = phi i64 [ 1, %2 ], [ %80, %79 ]
%7 = add i64 %6, 1
%8 = icmp ugt i64 %5, %7
br i1 %8, label %18, label %9
9: ; preds = %3
%10 = icmp eq i64 %5, %7
br i1 %10, label %11, label %79
11: ; preds = %9
%12 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %5
%13 = load float, float* %12, align 4, !tbaa !5
%14 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %6
%15 = load float, float* %14, align 4, !tbaa !5
%16 = fcmp olt float %13, %15
br i1 %16, label %17, label %79
17: ; preds = %11
store float %13, float* %14, align 4, !tbaa !5
store float %15, float* %12, align 4, !tbaa !5
br label %79
18: ; preds = %3
%19 = add i64 %5, %6
%20 = lshr i64 %19, 1
%21 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %20
%22 = load float, float* %21, align 4, !tbaa !5
%23 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %7
%24 = load float, float* %23, align 4, !tbaa !5
store float %24, float* %21, align 4, !tbaa !5
store float %22, float* %23, align 4, !tbaa !5
%25 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %5
%26 = load float, float* %25, align 4, !tbaa !5
%27 = fcmp ogt float %22, %26
br i1 %27, label %28, label %29
28: ; preds = %18
store float %26, float* %23, align 4, !tbaa !5
store float %22, float* %25, align 4, !tbaa !5
br label %29
29: ; preds = %28, %18
%30 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %6
%31 = load float, float* %30, align 4, !tbaa !5
%32 = load float, float* %25, align 4, !tbaa !5
%33 = fcmp ogt float %31, %32
br i1 %33, label %34, label %35
34: ; preds = %29
store float %32, float* %30, align 4, !tbaa !5
store float %31, float* %25, align 4, !tbaa !5
br label %35
35: ; preds = %34, %29
%36 = phi float [ %31, %34 ], [ %22, %29 ]
%37 = load float, float* %23, align 4, !tbaa !5
%38 = load float, float* %30, align 4, !tbaa !5
%39 = fcmp ogt float %37, %38
br i1 %39, label %40, label %41
40: ; preds = %35
store float %38, float* %23, align 4, !tbaa !5
store float %37, float* %30, align 4, !tbaa !5
br label %41
41: ; preds = %40, %35
%42 = phi float [ %37, %40 ], [ %36, %35 ]
%43 = load float, float* %30, align 4, !tbaa !5
%44 = icmp eq i32 %4, 0
br i1 %44, label %45, label %68
45: ; preds = %41, %62
%46 = phi i32 [ %64, %62 ], [ %4, %41 ]
%47 = phi float [ %66, %62 ], [ %42, %41 ]
%48 = phi i64 [ %52, %62 ], [ %7, %41 ]
%49 = phi i64 [ %58, %62 ], [ %5, %41 ]
br label %50
50: ; preds = %45, %50
%51 = phi i64 [ %52, %50 ], [ %48, %45 ]
%52 = add i64 %51, 1
%53 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %52
%54 = load float, float* %53, align 4, !tbaa !5
%55 = fcmp olt float %54, %43
br i1 %55, label %50, label %56, !llvm.loop !9
56: ; preds = %50, %56
%57 = phi i64 [ %58, %56 ], [ %49, %50 ]
%58 = add i64 %57, -1
%59 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %58
%60 = load float, float* %59, align 4, !tbaa !5
%61 = fcmp ogt float %60, %43
br i1 %61, label %56, label %62, !llvm.loop !12
62: ; preds = %56
%63 = icmp ult i64 %58, %52
%64 = select i1 %63, i32 1, i32 %46
%65 = icmp eq i32 %64, 0
%66 = select i1 %65, float %54, float %47
store float %60, float* %53, align 4, !tbaa !5
store float %66, float* %59, align 4, !tbaa !5
%67 = icmp eq i32 %64, 0
br i1 %67, label %45, label %68, !llvm.loop !13
68: ; preds = %62, %41
%69 = phi i64 [ %5, %41 ], [ %58, %62 ]
%70 = phi i64 [ %7, %41 ], [ %52, %62 ]
%71 = phi i32 [ %4, %41 ], [ %64, %62 ]
%72 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %69
%73 = load float, float* %72, align 4, !tbaa !5
store float %73, float* %30, align 4, !tbaa !5
store float %43, float* %72, align 4, !tbaa !5
%74 = icmp ult i64 %69, %0
%75 = add i64 %69, -1
%76 = select i1 %74, i64 %5, i64 %75
%77 = icmp ugt i64 %69, %0
%78 = select i1 %77, i64 %6, i64 %70
br label %79
79: ; preds = %68, %9, %17, %11
%80 = phi i64 [ %6, %11 ], [ %6, %17 ], [ %6, %9 ], [ %78, %68 ]
%81 = phi i64 [ %5, %11 ], [ %5, %17 ], [ %5, %9 ], [ %76, %68 ]
%82 = phi i1 [ false, %11 ], [ false, %17 ], [ false, %9 ], [ true, %68 ]
%83 = phi i32 [ %4, %11 ], [ %4, %17 ], [ %4, %9 ], [ %71, %68 ]
br i1 %82, label %3, label %84, !llvm.loop !14
84: ; preds = %79
%85 = getelementptr inbounds [20 x float], [20 x float]* @arr, i64 0, i64 %0
%86 = load float, float* %85, align 4, !tbaa !5
ret float %86
}
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
%1 = call float @select(i64 10, i64 20)
ret i32 0
}
attributes #0 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10, !11}

78
test/sqrt.ll Normal file
View File

@ -0,0 +1,78 @@
; ModuleID = 'sqrt.c'
source_filename = "sqrt.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn
define dso_local float @fabs(float %0) local_unnamed_addr #0 {
%2 = fcmp olt float %0, 0.000000e+00
%3 = fneg float %0
%4 = select i1 %2, float %3, float %0
ret float %4
}
; Function Attrs: nofree nosync nounwind readnone sspstrong uwtable
define dso_local float @sqrtfcn(float %0) local_unnamed_addr #1 {
%2 = fcmp oeq float %0, 0.000000e+00
br i1 %2, label %30, label %3
3: ; preds = %1
%4 = fdiv float %0, 1.000000e+01
br label %5
5: ; preds = %3, %25
%6 = phi i32 [ 0, %3 ], [ %27, %25 ]
%7 = phi i32 [ 1, %3 ], [ %28, %25 ]
%8 = phi float [ %4, %3 ], [ %26, %25 ]
%9 = icmp eq i32 %6, 0
br i1 %9, label %10, label %25
10: ; preds = %5
%11 = fmul float %8, %8
%12 = fsub float %0, %11
%13 = fpext float %12 to double
%14 = fpext float %8 to double
%15 = fmul double %14, 2.000000e+00
%16 = fdiv double %13, %15
%17 = fptrunc double %16 to float
%18 = fadd float %8, %17
%19 = fmul float %18, %18
%20 = fsub float %0, %19
%21 = call float @llvm.fabs.f32(float %20)
%22 = fpext float %21 to double
%23 = fcmp ugt double %22, 1.000000e-05
br i1 %23, label %25, label %24
24: ; preds = %10
br label %25
25: ; preds = %24, %10, %5
%26 = phi float [ %8, %5 ], [ %18, %24 ], [ %18, %10 ]
%27 = phi i32 [ 1, %5 ], [ 1, %24 ], [ 0, %10 ]
%28 = add nuw nsw i32 %7, 1
%29 = icmp eq i32 %28, 20
br i1 %29, label %30, label %5, !llvm.loop !5
30: ; preds = %25, %1
%31 = phi float [ 0.000000e+00, %1 ], [ %26, %25 ]
ret float %31
}
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare float @llvm.fabs.f32(float) #2
attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nosync nounwind readnone sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree nosync nounwind readnone speculatable willreturn }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.unroll.disable"}

2
test/src/README.md Normal file
View File

@ -0,0 +1,2 @@
# Mälardalen WCET
Taken from [Link](https://www.mrtc.mdh.se/projects/wcet/benchmarks.html).

878
test/src/adpcm.c Executable file
View File

@ -0,0 +1,878 @@
/* $Id: adpcm.c,v 1.7 2005/06/15 07:27:31 ael01 Exp $ */
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* 6. Printouts removed (Jan G) */
/* */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: adpcm.c */
/* SOURCE : C Algorithms for Real-Time DSP by P. M. Embree */
/* */
/* DESCRIPTION : */
/* */
/* CCITT G.722 ADPCM (Adaptive Differential Pulse Code Modulation) */
/* algorithm. */
/* 16khz sample rate data is stored in the array test_data[SIZE]. */
/* Results are stored in the array compressed[SIZE] and result[SIZE].*/
/* Execution time is determined by the constant SIZE (default value */
/* is 2000). */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
/* To be able to run with printouts
#include <stdio.h> */
/* common sampling rate for sound cards on IBM/PC */
#define SAMPLE_RATE 11025
#define PI 3141
#define SIZE 3
#define IN_END 4
/* COMPLEX STRUCTURE */
typedef struct {
int real, imag;
} COMPLEX;
/* function prototypes for fft and filter functions */
void fft(COMPLEX *,int);
int fir_filter(int input,int *coef,int n,int *history);
int iir_filter(int input,int *coef,int n,int *history);
int gaussian(void);
int my_abs(int n);
void setup_codec(int),key_down(),int_enable(),int_disable();
int flags(int);
int getinput(void);
void sendout(int),flush();
int encode(int,int);
void decode(int);
int filtez(int *bpl,int *dlt);
void upzero(int dlt,int *dlti,int *bli);
int filtep(int rlt1,int al1,int rlt2,int al2);
int quantl(int el,int detl);
/* int invqxl(int il,int detl,int *code_table,int mode); */
int logscl(int il,int nbl);
int scalel(int nbl,int shift_constant);
int uppol2(int al1,int al2,int plt,int plt1,int plt2);
int uppol1(int al1,int apl2,int plt,int plt1);
/* int invqah(int ih,int deth); */
int logsch(int ih,int nbh);
void reset();
int my_fabs(int n);
int my_cos(int n);
int my_sin(int n);
/* G722 C code */
/* variables for transimit quadrature mirror filter here */
int tqmf[24];
/* QMF filter coefficients:
scaled by a factor of 4 compared to G722 CCITT recommendation */
int h[24] = {
12, -44, -44, 212, 48, -624, 128, 1448,
-840, -3220, 3804, 15504, 15504, 3804, -3220, -840,
1448, 128, -624, 48, 212, -44, -44, 12
};
int xl,xh;
/* variables for receive quadrature mirror filter here */
int accumc[11],accumd[11];
/* outputs of decode() */
int xout1,xout2;
int xs,xd;
/* variables for encoder (hi and lo) here */
int il,szl,spl,sl,el;
int qq4_code4_table[16] = {
0, -20456, -12896, -8968, -6288, -4240, -2584, -1200,
20456, 12896, 8968, 6288, 4240, 2584, 1200, 0
};
int qq5_code5_table[32] = {
-280, -280, -23352, -17560, -14120, -11664, -9752, -8184,
-6864, -5712, -4696, -3784, -2960, -2208, -1520, -880,
23352, 17560, 14120, 11664, 9752, 8184, 6864, 5712,
4696, 3784, 2960, 2208, 1520, 880, 280, -280
};
int qq6_code6_table[64] = {
-136, -136, -136, -136, -24808, -21904, -19008, -16704,
-14984, -13512, -12280, -11192, -10232, -9360, -8576, -7856,
-7192, -6576, -6000, -5456, -4944, -4464, -4008, -3576,
-3168, -2776, -2400, -2032, -1688, -1360, -1040, -728,
24808, 21904, 19008, 16704, 14984, 13512, 12280, 11192,
10232, 9360, 8576, 7856, 7192, 6576, 6000, 5456,
4944, 4464, 4008, 3576, 3168, 2776, 2400, 2032,
1688, 1360, 1040, 728, 432, 136, -432, -136
};
int delay_bpl[6];
int delay_dltx[6];
int wl_code_table[16] = {
-60, 3042, 1198, 538, 334, 172, 58, -30,
3042, 1198, 538, 334, 172, 58, -30, -60
};
int wl_table[8] = {
-60, -30, 58, 172, 334, 538, 1198, 3042
};
int ilb_table[32] = {
2048, 2093, 2139, 2186, 2233, 2282, 2332, 2383,
2435, 2489, 2543, 2599, 2656, 2714, 2774, 2834,
2896, 2960, 3025, 3091, 3158, 3228, 3298, 3371,
3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008
};
int nbl; /* delay line */
int al1,al2;
int plt,plt1,plt2;
int rs;
int dlt;
int rlt,rlt1,rlt2;
/* decision levels - pre-multiplied by 8, 0 to indicate end */
int decis_levl[30] = {
280, 576, 880, 1200, 1520, 1864, 2208, 2584,
2960, 3376, 3784, 4240, 4696, 5200, 5712, 6288,
6864, 7520, 8184, 8968, 9752, 10712, 11664, 12896,
14120, 15840, 17560, 20456, 23352, 32767
};
int detl;
/* quantization table 31 long to make quantl look-up easier,
last entry is for mil=30 case when wd is max */
int quant26bt_pos[31] = {
61, 60, 59, 58, 57, 56, 55, 54,
53, 52, 51, 50, 49, 48, 47, 46,
45, 44, 43, 42, 41, 40, 39, 38,
37, 36, 35, 34, 33, 32, 32
};
/* quantization table 31 long to make quantl look-up easier,
last entry is for mil=30 case when wd is max */
int quant26bt_neg[31] = {
63, 62, 31, 30, 29, 28, 27, 26,
25, 24, 23, 22, 21, 20, 19, 18,
17, 16, 15, 14, 13, 12, 11, 10,
9, 8, 7, 6, 5, 4, 4
};
int deth;
int sh; /* this comes from adaptive predictor */
int eh;
int qq2_code2_table[4] = {
-7408, -1616, 7408, 1616
};
int wh_code_table[4] = {
798, -214, 798, -214
};
int dh,ih;
int nbh,szh;
int sph,ph,yh,rh;
int delay_dhx[6];
int delay_bph[6];
int ah1,ah2;
int ph1,ph2;
int rh1,rh2;
/* variables for decoder here */
int ilr,yl,rl;
int dec_deth,dec_detl,dec_dlt;
int dec_del_bpl[6];
int dec_del_dltx[6];
int dec_plt,dec_plt1,dec_plt2;
int dec_szl,dec_spl,dec_sl;
int dec_rlt1,dec_rlt2,dec_rlt;
int dec_al1,dec_al2;
int dl;
int dec_nbl,dec_yh,dec_dh,dec_nbh;
/* variables used in filtez */
int dec_del_bph[6];
int dec_del_dhx[6];
int dec_szh;
/* variables used in filtep */
int dec_rh1,dec_rh2;
int dec_ah1,dec_ah2;
int dec_ph,dec_sph;
int dec_sh,dec_rh;
int dec_ph1,dec_ph2;
/* G722 encode function two ints in, one 8 bit output */
/* put input samples in xin1 = first value, xin2 = second value */
/* returns il and ih stored together */
/* MAX: 1 */
int my_abs(int n)
{
int m;
if (n >= 0) m = n;
else m = -n;
return m;
}
/* MAX: 1 */
int my_fabs(int n)
{
int f;
if (n >= 0) f = n;
else f = -n;
return f;
}
int my_sin(int rad)
{
int diff;
int app=0;
int inc = 1;
/* MAX dependent on rad's value, say 50 */
while (rad > 2*PI)
rad -= 2*PI;
/* MAX dependent on rad's value, say 50 */
while (rad < -2*PI)
rad += 2*PI;
diff = rad;
app = diff;
diff = (diff * (-(rad*rad))) /
((2 * inc) * (2 * inc + 1));
app = app + diff;
inc++;
/* REALLY: while(my_fabs(diff) >= 0.00001) { */
/* MAX: 1000 */
while(my_fabs(diff) >= 1) {
diff = (diff * (-(rad*rad))) /
((2 * inc) * (2 * inc + 1));
app = app + diff;
inc++;
}
return app;
}
int my_cos(int rad)
{
return (my_sin (PI / 2 - rad));
}
/* MAX: 1 */
int encode(int xin1,int xin2)
{
int i;
int *h_ptr,*tqmf_ptr,*tqmf_ptr1;
long int xa,xb;
int decis;
/* transmit quadrature mirror filters implemented here */
h_ptr = h;
tqmf_ptr = tqmf;
xa = (long)(*tqmf_ptr++) * (*h_ptr++);
xb = (long)(*tqmf_ptr++) * (*h_ptr++);
/* main multiply accumulate loop for samples and coefficients */
/* MAX: 10 */
for(i = 0 ; i < 10 ; i++) {
xa += (long)(*tqmf_ptr++) * (*h_ptr++);
xb += (long)(*tqmf_ptr++) * (*h_ptr++);
}
/* final mult/accumulate */
xa += (long)(*tqmf_ptr++) * (*h_ptr++);
xb += (long)(*tqmf_ptr) * (*h_ptr++);
/* update delay line tqmf */
tqmf_ptr1 = tqmf_ptr - 2;
/* MAX: 22 */
for(i = 0 ; i < 22 ; i++) *tqmf_ptr-- = *tqmf_ptr1--;
*tqmf_ptr-- = xin1;
*tqmf_ptr = xin2;
/* scale outputs */
xl = (xa + xb) >> 15;
xh = (xa - xb) >> 15;
/* end of quadrature mirror filter code */
/* starting with lower sub band encoder */
/* filtez - compute predictor output section - zero section */
szl = filtez(delay_bpl,delay_dltx);
/* filtep - compute predictor output signal (pole section) */
spl = filtep(rlt1,al1,rlt2,al2);
/* compute the predictor output value in the lower sub_band encoder */
sl = szl + spl;
el = xl - sl;
/* quantl: quantize the difference signal */
il = quantl(el,detl);
/* invqxl: computes quantized difference signal */
/* for invqbl, truncate by 2 lsbs, so mode = 3 */
dlt = ((long)detl*qq4_code4_table[il >> 2]) >> 15;
/* logscl: updates logarithmic quant. scale factor in low sub band */
nbl = logscl(il,nbl);
/* scalel: compute the quantizer scale factor in the lower sub band */
/* calling parameters nbl and 8 (constant such that scalel can be scaleh) */
detl = scalel(nbl,8);
/* parrec - simple addition to compute recontructed signal for adaptive pred */
plt = dlt + szl;
/* upzero: update zero section predictor coefficients (sixth order)*/
/* calling parameters: dlt, dlt1, dlt2, ..., dlt6 from dlt */
/* bpli (linear_buffer in which all six values are delayed */
/* return params: updated bpli, delayed dltx */
upzero(dlt,delay_dltx,delay_bpl);
/* uppol2- update second predictor coefficient apl2 and delay it as al2 */
/* calling parameters: al1, al2, plt, plt1, plt2 */
al2 = uppol2(al1,al2,plt,plt1,plt2);
/* uppol1 :update first predictor coefficient apl1 and delay it as al1 */
/* calling parameters: al1, apl2, plt, plt1 */
al1 = uppol1(al1,al2,plt,plt1);
/* recons : compute recontructed signal for adaptive predictor */
rlt = sl + dlt;
/* done with lower sub_band encoder; now implement delays for next time*/
rlt2 = rlt1;
rlt1 = rlt;
plt2 = plt1;
plt1 = plt;
/* high band encode */
szh = filtez(delay_bph,delay_dhx);
sph = filtep(rh1,ah1,rh2,ah2);
/* predic: sh = sph + szh */
sh = sph + szh;
/* subtra: eh = xh - sh */
eh = xh - sh;
/* quanth - quantization of difference signal for higher sub-band */
/* quanth: in-place for speed params: eh, deth (has init. value) */
if(eh >= 0) {
ih = 3; /* 2,3 are pos codes */
}
else {
ih = 1; /* 0,1 are neg codes */
}
decis = (564L*(long)deth) >> 12L;
if(my_abs(eh) > decis) ih--; /* mih = 2 case */
/* invqah: compute the quantized difference signal, higher sub-band*/
dh = ((long)deth*qq2_code2_table[ih]) >> 15L ;
/* logsch: update logarithmic quantizer scale factor in hi sub-band*/
nbh = logsch(ih,nbh);
/* note : scalel and scaleh use same code, different parameters */
deth = scalel(nbh,10);
/* parrec - add pole predictor output to quantized diff. signal */
ph = dh + szh;
/* upzero: update zero section predictor coefficients (sixth order) */
/* calling parameters: dh, dhi, bphi */
/* return params: updated bphi, delayed dhx */
upzero(dh,delay_dhx,delay_bph);
/* uppol2: update second predictor coef aph2 and delay as ah2 */
/* calling params: ah1, ah2, ph, ph1, ph2 */
ah2 = uppol2(ah1,ah2,ph,ph1,ph2);
/* uppol1: update first predictor coef. aph2 and delay it as ah1 */
ah1 = uppol1(ah1,ah2,ph,ph1);
/* recons for higher sub-band */
yh = sh + dh;
/* done with higher sub-band encoder, now Delay for next time */
rh2 = rh1;
rh1 = yh;
ph2 = ph1;
ph1 = ph;
/* multiplex ih and il to get signals together */
return(il | (ih << 6));
}
/* decode function, result in xout1 and xout2 */
void decode(int input)
{
int i;
long int xa1,xa2; /* qmf accumulators */
int *h_ptr,*ac_ptr,*ac_ptr1,*ad_ptr,*ad_ptr1;
/* split transmitted word from input into ilr and ih */
ilr = input & 0x3f;
ih = input >> 6;
/* LOWER SUB_BAND DECODER */
/* filtez: compute predictor output for zero section */
dec_szl = filtez(dec_del_bpl,dec_del_dltx);
/* filtep: compute predictor output signal for pole section */
dec_spl = filtep(dec_rlt1,dec_al1,dec_rlt2,dec_al2);
dec_sl = dec_spl + dec_szl;
/* invqxl: compute quantized difference signal for adaptive predic */
dec_dlt = ((long)dec_detl*qq4_code4_table[ilr >> 2]) >> 15;
/* invqxl: compute quantized difference signal for decoder output */
dl = ((long)dec_detl*qq6_code6_table[il]) >> 15;
rl = dl + dec_sl;
/* logscl: quantizer scale factor adaptation in the lower sub-band */
dec_nbl = logscl(ilr,dec_nbl);
/* scalel: computes quantizer scale factor in the lower sub band */
dec_detl = scalel(dec_nbl,8);
/* parrec - add pole predictor output to quantized diff. signal */
/* for partially reconstructed signal */
dec_plt = dec_dlt + dec_szl;
/* upzero: update zero section predictor coefficients */
upzero(dec_dlt,dec_del_dltx,dec_del_bpl);
/* uppol2: update second predictor coefficient apl2 and delay it as al2 */
dec_al2 = uppol2(dec_al1,dec_al2,dec_plt,dec_plt1,dec_plt2);
/* uppol1: update first predictor coef. (pole setion) */
dec_al1 = uppol1(dec_al1,dec_al2,dec_plt,dec_plt1);
/* recons : compute recontructed signal for adaptive predictor */
dec_rlt = dec_sl + dec_dlt;
/* done with lower sub band decoder, implement delays for next time */
dec_rlt2 = dec_rlt1;
dec_rlt1 = dec_rlt;
dec_plt2 = dec_plt1;
dec_plt1 = dec_plt;
/* HIGH SUB-BAND DECODER */
/* filtez: compute predictor output for zero section */
dec_szh = filtez(dec_del_bph,dec_del_dhx);
/* filtep: compute predictor output signal for pole section */
dec_sph = filtep(dec_rh1,dec_ah1,dec_rh2,dec_ah2);
/* predic:compute the predictor output value in the higher sub_band decoder */
dec_sh = dec_sph + dec_szh;
/* invqah: in-place compute the quantized difference signal */
dec_dh = ((long)dec_deth*qq2_code2_table[ih]) >> 15L ;
/* logsch: update logarithmic quantizer scale factor in hi sub band */
dec_nbh = logsch(ih,dec_nbh);
/* scalel: compute the quantizer scale factor in the higher sub band */
dec_deth = scalel(dec_nbh,10);
/* parrec: compute partially recontructed signal */
dec_ph = dec_dh + dec_szh;
/* upzero: update zero section predictor coefficients */
upzero(dec_dh,dec_del_dhx,dec_del_bph);
/* uppol2: update second predictor coefficient aph2 and delay it as ah2 */
dec_ah2 = uppol2(dec_ah1,dec_ah2,dec_ph,dec_ph1,dec_ph2);
/* uppol1: update first predictor coef. (pole setion) */
dec_ah1 = uppol1(dec_ah1,dec_ah2,dec_ph,dec_ph1);
/* recons : compute recontructed signal for adaptive predictor */
rh = dec_sh + dec_dh;
/* done with high band decode, implementing delays for next time here */
dec_rh2 = dec_rh1;
dec_rh1 = rh;
dec_ph2 = dec_ph1;
dec_ph1 = dec_ph;
/* end of higher sub_band decoder */
/* end with receive quadrature mirror filters */
xd = rl - rh;
xs = rl + rh;
/* receive quadrature mirror filters implemented here */
h_ptr = h;
ac_ptr = accumc;
ad_ptr = accumd;
xa1 = (long)xd * (*h_ptr++);
xa2 = (long)xs * (*h_ptr++);
/* main multiply accumulate loop for samples and coefficients */
for(i = 0 ; i < 10 ; i++) {
xa1 += (long)(*ac_ptr++) * (*h_ptr++);
xa2 += (long)(*ad_ptr++) * (*h_ptr++);
}
/* final mult/accumulate */
xa1 += (long)(*ac_ptr) * (*h_ptr++);
xa2 += (long)(*ad_ptr) * (*h_ptr++);
/* scale by 2^14 */
xout1 = xa1 >> 14;
xout2 = xa2 >> 14;
/* update delay lines */
ac_ptr1 = ac_ptr - 1;
ad_ptr1 = ad_ptr - 1;
for(i = 0 ; i < 10 ; i++) {
*ac_ptr-- = *ac_ptr1--;
*ad_ptr-- = *ad_ptr1--;
}
*ac_ptr = xd;
*ad_ptr = xs;
return;
}
/* clear all storage locations */
void reset()
{
int i;
detl = dec_detl = 32; /* reset to min scale factor */
deth = dec_deth = 8;
nbl = al1 = al2 = plt1 = plt2 = rlt1 = rlt2 = 0;
nbh = ah1 = ah2 = ph1 = ph2 = rh1 = rh2 = 0;
dec_nbl = dec_al1 = dec_al2 = dec_plt1 = dec_plt2 = dec_rlt1 = dec_rlt2 = 0;
dec_nbh = dec_ah1 = dec_ah2 = dec_ph1 = dec_ph2 = dec_rh1 = dec_rh2 = 0;
for(i = 0 ; i < 6 ; i++) {
delay_dltx[i] = 0;
delay_dhx[i] = 0;
dec_del_dltx[i] = 0;
dec_del_dhx[i] = 0;
}
for(i = 0 ; i < 6 ; i++) {
delay_bpl[i] = 0;
delay_bph[i] = 0;
dec_del_bpl[i] = 0;
dec_del_bph[i] = 0;
}
for(i = 0 ; i < 23 ; i++) tqmf[i] = 0;
for(i = 0 ; i < 11 ; i++) {
accumc[i] = 0;
accumd[i] = 0;
}
return;
}
/* filtez - compute predictor output signal (zero section) */
/* input: bpl1-6 and dlt1-6, output: szl */
int filtez(int *bpl,int *dlt)
{
int i;
long int zl;
zl = (long)(*bpl++) * (*dlt++);
/* MAX: 6 */
for(i = 1 ; i < 6 ; i++)
zl += (long)(*bpl++) * (*dlt++);
return((int)(zl >> 14)); /* x2 here */
}
/* filtep - compute predictor output signal (pole section) */
/* input rlt1-2 and al1-2, output spl */
int filtep(int rlt1,int al1,int rlt2,int al2)
{
long int pl,pl2;
pl = 2*rlt1;
pl = (long)al1*pl;
pl2 = 2*rlt2;
pl += (long)al2*pl2;
return((int)(pl >> 15));
}
/* quantl - quantize the difference signal in the lower sub-band */
int quantl(int el,int detl)
{
int ril,mil;
long int wd,decis;
/* abs of difference signal */
wd = my_abs(el);
/* determine mil based on decision levels and detl gain */
/* MAX: 30 */
for(mil = 0 ; mil < 30 ; mil++) {
decis = (decis_levl[mil]*(long)detl) >> 15L;
if(wd <= decis) break;
}
/* if mil=30 then wd is less than all decision levels */
if(el >= 0) ril = quant26bt_pos[mil];
else ril = quant26bt_neg[mil];
return(ril);
}
/* invqxl is either invqbl or invqal depending on parameters passed */
/* returns dlt, code table is pre-multiplied by 8 */
/* int invqxl(int il,int detl,int *code_table,int mode) */
/* { */
/* long int dlt; */
/* dlt = (long)detl*code_table[il >> (mode-1)]; */
/* return((int)(dlt >> 15)); */
/* } */
/* logscl - update log quantizer scale factor in lower sub-band */
/* note that nbl is passed and returned */
int logscl(int il,int nbl)
{
long int wd;
wd = ((long)nbl * 127L) >> 7L; /* leak factor 127/128 */
nbl = (int)wd + wl_code_table[il >> 2];
if(nbl < 0) nbl = 0;
if(nbl > 18432) nbl = 18432;
return(nbl);
}
/* scalel: compute quantizer scale factor in lower or upper sub-band*/
int scalel(int nbl,int shift_constant)
{
int wd1,wd2,wd3;
wd1 = (nbl >> 6) & 31;
wd2 = nbl >> 11;
wd3 = ilb_table[wd1] >> (shift_constant + 1 - wd2);
return(wd3 << 3);
}
/* upzero - inputs: dlt, dlti[0-5], bli[0-5], outputs: updated bli[0-5] */
/* also implements delay of bli and update of dlti from dlt */
void upzero(int dlt,int *dlti,int *bli)
{
int i,wd2,wd3;
/*if dlt is zero, then no sum into bli */
if(dlt == 0) {
for(i = 0 ; i < 6 ; i++) {
bli[i] = (int)((255L*bli[i]) >> 8L); /* leak factor of 255/256 */
}
}
else {
for(i = 0 ; i < 6 ; i++) {
if((long)dlt*dlti[i] >= 0) wd2 = 128; else wd2 = -128;
wd3 = (int)((255L*bli[i]) >> 8L); /* leak factor of 255/256 */
bli[i] = wd2 + wd3;
}
}
/* implement delay line for dlt */
dlti[5] = dlti[4];
dlti[4] = dlti[3];
dlti[3] = dlti[2];
dlti[1] = dlti[0];
dlti[0] = dlt;
return;
}
/* uppol2 - update second predictor coefficient (pole section) */
/* inputs: al1, al2, plt, plt1, plt2. outputs: apl2 */
int uppol2(int al1,int al2,int plt,int plt1,int plt2)
{
long int wd2,wd4;
int apl2;
wd2 = 4L*(long)al1;
if((long)plt*plt1 >= 0L) wd2 = -wd2; /* check same sign */
wd2 = wd2 >> 7; /* gain of 1/128 */
if((long)plt*plt2 >= 0L) {
wd4 = wd2 + 128; /* same sign case */
}
else {
wd4 = wd2 - 128;
}
apl2 = wd4 + (127L*(long)al2 >> 7L); /* leak factor of 127/128 */
/* apl2 is limited to +-.75 */
if(apl2 > 12288) apl2 = 12288;
if(apl2 < -12288) apl2 = -12288;
return(apl2);
}
/* uppol1 - update first predictor coefficient (pole section) */
/* inputs: al1, apl2, plt, plt1. outputs: apl1 */
int uppol1(int al1,int apl2,int plt,int plt1)
{
long int wd2;
int wd3,apl1;
wd2 = ((long)al1*255L) >> 8L; /* leak factor of 255/256 */
if((long)plt*plt1 >= 0L) {
apl1 = (int)wd2 + 192; /* same sign case */
}
else {
apl1 = (int)wd2 - 192;
}
/* note: wd3= .9375-.75 is always positive */
wd3 = 15360 - apl2; /* limit value */
if(apl1 > wd3) apl1 = wd3;
if(apl1 < -wd3) apl1 = -wd3;
return(apl1);
}
/* INVQAH: inverse adaptive quantizer for the higher sub-band */
/* returns dh, code table is pre-multiplied by 8 */
/* int invqah(int ih,int deth) */
/* { */
/* long int rdh; */
/* rdh = ((long)deth*qq2_code2_table[ih]) >> 15L ; */
/* return((int)(rdh )); */
/* } */
/* logsch - update log quantizer scale factor in higher sub-band */
/* note that nbh is passed and returned */
int logsch(int ih,int nbh)
{
int wd;
wd = ((long)nbh * 127L) >> 7L; /* leak factor 127/128 */
nbh = wd + wh_code_table[ih];
if(nbh < 0) nbh = 0;
if(nbh > 22528) nbh = 22528;
return(nbh);
}
#ifndef Seoul_Mate
int main()
{
int i,j,f/*,answer*/;
static int test_data[SIZE*2],compressed[SIZE],result[SIZE*2];
/* reset, initialize required memory */
reset();
/* read in amplitude and frequency for test data */
/* scanf("%d",&j);
scanf("%d",&f); */
j = 10; f = 2000; /* körs men, används inte */
/* 16 KHz sample rate */
/* XXmain_0, MAX: 2 */
/* Since the number of times we loop in my_sin depends on the argument we
add the fact: xxmain_0:[]: */
for(i = 0 ; i < SIZE ; i++) {
test_data[i] = (int)j*my_cos(f*PI*i);
}
/* MAX: 2 */
/*******Antar att test_data[0] = 10 och test_data[1]=-6 från ovan, *******
och att anropet i forloopen blir encode(test_data[0],test_data[0]);
och encode(test_data[1],test_data[1]), eftersom att den annars går
*******över array gränsen *******/
for(i = 0 ; i < IN_END ; i += 2)
compressed[i/2] = encode(test_data[i],test_data[i+1]);
/* MAX: 2 */
for(i = 0 ; i < IN_END ; i += 2) {
decode(compressed[i/2]);
result[i] = xout1;
result[i+1] = xout2;
}
/*
for( ; j < 32767 ; j++) {
i=IN_END-1;
printf("\n%4d %4d %4d %4d %4d",j,compressed[i/2] >> 6,compressed[i/2] & 63,result[i],result[i-1]);
}
*/
/* print ih, il */
/*
for(i = 0 ; i < IN_END/2 ; i++) printf("\n%4d %2d %2d",
i,compressed[i] >> 6,compressed[i] & 63);
*/
return result[i]+result[i+1];
}
#endif

113
test/src/bs.c Executable file
View File

@ -0,0 +1,113 @@
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: bs.c */
/* SOURCE : Public Domain Code */
/* */
/* DESCRIPTION : */
/* */
/* Binary search for the array of 15 integer elements. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
struct DATA {
int key;
int value;
} ;
#ifdef DEBUG
int cnt1;
#endif
struct DATA data[15] = { {1, 100},
{5,200},
{6, 300},
{7, 700},
{8, 900},
{9, 250},
{10, 400},
{11, 600},
{12, 800},
{13, 1500},
{14, 1200},
{15, 110},
{16, 140},
{17, 133},
{18, 10} };
main()
{
binary_search(8);
}
binary_search(x)
{
int fvalue, mid, up, low ;
low = 0;
up = 14;
fvalue = -1 /* all data are positive */ ;
while (low <= up) {
mid = (low + up) >> 1;
if ( data[mid].key == x ) { /* found */
up = low - 1;
fvalue = data[mid].value;
#ifdef DEBUG
printf("FOUND!!\n");
#endif
}
else /* not found */
if ( data[mid].key > x ) {
up = mid - 1;
#ifdef DEBUG
printf("MID-1\n");
#endif
}
else {
low = mid + 1;
#ifdef DEBUG
printf("MID+1\n");
#endif
}
#ifdef DEBUG
cnt1++;
#endif
}
#ifdef DEBUG
printf("Loop Count : %d\n", cnt1);
#endif
return fvalue;
}

127
test/src/bsort100.c Executable file
View File

@ -0,0 +1,127 @@
/* bsort100.c */
/* All output disabled for wcsim */
#define WCSIM 1
/* A read from this address will result in an known value of 1 */
#define KNOWN_VALUE (int)(*((char *)0x80200001))
/* A read from this address will result in an unknown value */
#define UNKNOWN_VALUE (int)(*((char *)0x80200003))
#include <sys/types.h>
#include <sys/times.h>
#include <stdio.h>
#define WORSTCASE 1
#define FALSE 0
#define TRUE 1
#define NUMELEMS 100
#define MAXDIM (NUMELEMS+1)
/* BUBBLESORT BENCHMARK PROGRAM:
* This program tests the basic loop constructs, integer comparisons,
* and simple array handling of compilers by sorting 10 arrays of
* randomly generated integers.
*/
int Array[MAXDIM], Seed;
int factor;
main()
{
long StartTime, StopTime;
float TotalTime;
#ifndef WCSIM
printf("\n *** BUBBLE SORT BENCHMARK TEST ***\n\n");
printf("RESULTS OF TEST:\n\n");
#endif
Initialize(Array);
/* StartTime = ttime (); */
BubbleSort(Array);
/* StopTime = ttime(); */
/* TotalTime = (StopTime - StartTime) / 1000.0; */
#ifndef WCSIM
printf(" - Number of elements sorted is %d\n", NUMELEMS);
printf(" - Total time sorting is %3.3f seconds\n\n", TotalTime);
#endif
}
int ttime()
/*
* This function returns in milliseconds the amount of compiler time
* used prior to it being called.
*/
{
struct tms buffer;
int utime;
/* times(&buffer); not implemented */
utime = (buffer.tms_utime / 60.0) * 1000.0;
return(utime);
}
Initialize(Array)
int Array[];
/*
* Initializes given array with randomly generated integers.
*/
{
int Index, fact;
#ifdef WORSTCASE
factor = -1;
#else
factor = 1;
#endif
fact = factor;
for (Index = 1; Index <= NUMELEMS; Index ++)
Array[Index] = Index*fact * KNOWN_VALUE;
}
BubbleSort(Array)
int Array[];
/*
* Sorts an array of integers of size NUMELEMS in ascending order.
*/
{
int Sorted = FALSE;
int Temp, LastIndex, Index, i;
for (i = 1;
i <= NUMELEMS-1; /* apsim_loop 1 0 */
i++)
{
Sorted = TRUE;
for (Index = 1;
Index <= NUMELEMS-1; /* apsim_loop 10 1 */
Index ++) {
if (Index > NUMELEMS-i)
break;
if (Array[Index] > Array[Index + 1])
{
Temp = Array[Index];
Array[Index] = Array[Index+1];
Array[Index+1] = Temp;
Sorted = FALSE;
}
}
if (Sorted)
break;
}
#ifndef WCSIM
if (Sorted || i == 1)
fprintf(stderr, "array was successfully sorted in %d passes\n", i-1);
else
fprintf(stderr, "array was unsuccessfully sorted in %d passes\n", i-1);
#endif
}

133
test/src/cnt.c Executable file
View File

@ -0,0 +1,133 @@
/* $Id: cnt.c,v 1.3 2005/04/04 11:34:58 csg Exp $ */
/* sumcntmatrix.c */
//#include <sys/types.h>
//#include <sys/times.h>
// #define WORSTCASE 1
// #define MAXSIZE 100 Changed JG/Ebbe
#define MAXSIZE 10
// Typedefs
typedef int matrix [MAXSIZE][MAXSIZE];
// Forwards declarations
int main(void);
int Test(matrix);
int Initialize(matrix);
int InitSeed(void);
void Sum(matrix);
int RandomInteger(void);
// Globals
int Seed;
matrix Array;
int Postotal, Negtotal, Poscnt, Negcnt;
// The main function
int main (void)
{
InitSeed();
//printf("\n *** MATRIX SUM AND COUNT BENCHMARK TEST ***\n\n");
//printf("RESULTS OF THE TEST:\n");
Test(Array);
return 1;
}
int Test(matrix Array)
{
long StartTime, StopTime;
float TotalTime;
Initialize(Array);
StartTime = 1000.0; //ttime();
Sum(Array);
StopTime = 1500.0; //ttime();
TotalTime = (StopTime - StartTime) / 1000.0;
//printf(" - Size of array is %d\n", MAXSIZE);
//printf(" - Num pos was %d and Sum was %d\n", Poscnt, Postotal);
//printf(" - Num neg was %d and Sum was %d\n", Negcnt, Negtotal);
//printf(" - Num neg was %d\n", Negcnt);
//printf(" - Total sum time is %3.3f seconds\n\n", TotalTime);
return 0;
}
// Intializes the given array with random integers.
int Initialize(matrix Array)
{
register int OuterIndex, InnerIndex;
for (OuterIndex = 0; OuterIndex < MAXSIZE; OuterIndex++) //100 + 1
for (InnerIndex = 0; InnerIndex < MAXSIZE; InnerIndex++) //100 + 1
Array[OuterIndex][InnerIndex] = RandomInteger();
return 0;
}
// Initializes the seed used in the random number generator.
int InitSeed (void)
{
Seed = 0;
return 0;
}
void Sum(matrix Array)
{
register int Outer, Inner;
int Ptotal = 0; /* changed these to locals in order to drive worst case */
int Ntotal = 0;
int Pcnt = 0;
int Ncnt = 0;
for (Outer = 0; Outer < MAXSIZE; Outer++) //Maxsize = 100
for (Inner = 0; Inner < MAXSIZE; Inner++)
#ifdef WORSTCASE
if (Array[Outer][Inner] >= 0) {
#else
if (Array[Outer][Inner] < 0) {
#endif
Ptotal += Array[Outer][Inner];
Pcnt++;
}
else {
Ntotal += Array[Outer][Inner];
Ncnt++;
}
Postotal = Ptotal;
Poscnt = Pcnt;
Negtotal = Ntotal;
Negcnt = Ncnt;
}
// This function returns in milliseconds the amount of compiler time
//int ttime()
//{
// struct tms buffer;
//int utime;
//times(&buffer);
//utime = (buffer.tms_utime / 60.0) * 1000.0;
//return (utime);
//}
// Generates random integers between 0 and 8095
int RandomInteger(void)
{
Seed = ((Seed * 133) + 81) % 8095;
return Seed;
}

521
test/src/compress.c Executable file
View File

@ -0,0 +1,521 @@
/* MDH WCET BENCHMARK SUITE. File version $Id: compress.c,v 1.7 2005/12/21 09:37:18 jgn Exp $ */
/*
* Compress - data compression program
*
* Adopted from SPEC95 for WCET-calculation by Thomas Lundqvist, 1997-11-28.
* Only compression is done on a buffer (small one) containing
* totally random data. This should come closer to a worst case
* compared to the original SPEC95-version.
*
* All unused code removed by Jakob Engblom, february 2000. Cleaned
* up for IAR compilation.
*
* Removed the prototype declaration of "code_int getcode();" that is
* niether defined nor used. Christer Sandberg
*
* Changes:
* JG 2005/12/20: Changed declaration of maxmaxcode to avoid warning
* JG 2012/09/28: Comment within comment removed
*/
/* #define DO_TRACING */
#ifdef DO_TRACING /* ON PC */
#include <stdio.h>
#define TRACE(x) trace((x))
#undef TEST /* finished testing! */
/*
void trace(char *s)
{
printf("%s\n",s);
}
*/
#else /* ON TARGET */
#define TRACE(x)
#undef TEST
#endif
#define BUFFERSIZE 50
#define IN_COUNT BUFFERSIZE
#define HSIZE 257 /* 95% occupancy */
#define BITS 16
#define INIT_BITS 9 /* initial number of bits/code */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
#define min(a,b) ((a>b) ? b : a)
/*
* Set USERMEM to the maximum amount of physical user memory available
* in bytes. USERMEM is used to determine the maximum BITS that can be used
* for compression.
*
* SACREDMEM is the amount of physical memory saved for others; compress
* will hog the rest.
*/
/* For SPEC95 use, SACREDMEM automatically set to 0.
Jeff Reilly, 1/15/95 */
#define SACREDMEM 0
/* For SPEC95 use, USERMEM automatically set to 450000.
Jeff Reilly, 1/15/95 */
# define USERMEM 450000 /* default user memory */
#ifdef interdata /* (Perkin-Elmer) */
#define SIGNED_COMPARE_SLOW /* signed compare is slower than unsigned */
#endif
/* For SPEC95 use, PBITS and BITS automatically set to 16.
Jeff Reilyy, 1/15/95 */
#define PBITS 16
#define BITS 16
#define HSIZE 257 /* 95% occupancy was 69001 */
/*
* a code_int must be able to hold 2**BITS values of type int, and also -1
*/
#if BITS > 15
typedef long int code_int;
#else
typedef int code_int;
#endif
#ifdef SIGNED_COMPARE_SLOW
typedef unsigned long int count_int;
typedef unsigned short int count_short;
#else
typedef long int count_int;
#endif
typedef unsigned char char_type;
/* Defines for third byte of header */
#define BIT_MASK 0x1f
#define BLOCK_MASK 0x80
/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
a fourth header byte (for expansion).
*/
/* Global variables */
int n_bits; /* number of bits/code */
int maxbits = BITS; /* user settable max # bits/code */
code_int maxcode; /* maximum code, given n_bits */
#if BITS > 15
code_int maxmaxcode = 1L << BITS; /* should NEVER generate this code */
#else
code_int maxmaxcode = 1 << BITS; /* should NEVER generate this code */
#endif
# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
#define htabof(i) htab[i]
#define codetabof(i) codetab[i]
code_int hsize = HSIZE; /* for dynamic table sizing */
count_int fsize;
/*
* To save much memory, we overlay the table used by compress() with those
* used by decompress(). The tab_prefix table is the same size and type
* as the codetab. The tab_suffix table needs 2**BITS characters. We
* get this from the beginning of htab. The output stack uses the rest
* of htab, and contains characters. There is plenty of room for any
* possible stack (stack used to be 8000 characters).
*/
#define tab_prefixof(i) codetabof(i)
#define tab_suffixof(i) ((char_type *)(htab))[i]
#define de_stack ((char_type *)&tab_suffixof(1<<BITS))
code_int free_ent = 0; /* first unused entry */
int exit_stat = 0;
int nomagic = 1; /* Use a 3-byte magic number header, unless old file */
int zcat_flg = 0; /* Write output on stdout, suppress messages */
int quiet = 1; /* don't tell me about compression */
/*
* block compression parameters -- after all codes are used up,
* and compression rate changes, start over.
*/
int block_compress = BLOCK_MASK;
int clear_flg = 0;
long int ratio = 0;
#define CHECK_GAP 10000 /* ratio check interval */
count_int checkpoint = CHECK_GAP;
/*
* the next two codes should not be changed lightly, as they must not
* lie within the contiguous general code space.
*/
#define FIRST 257 /* first free entry */
#define CLEAR 256 /* table clear output code */
int force = 0;
char ofname [100];
int InCnt;
int apsim_InCnt;
unsigned char *InBuff;
unsigned char *OutBuff;
char orig_text_buffer[BUFFERSIZE];
char comp_text_buffer[BUFFERSIZE+5];
count_int htab [HSIZE];
unsigned short codetab [HSIZE];
char buf[BITS];
/*---------------------------------------------------- */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------- Prototypes */
void initbuffer(void);
void compress(void);
void cl_hash(count_int hsize); /* reset code table */
unsigned int getbyte(void);
void putbyte( char c );
void cl_block (void);
void output( code_int code );
void writebytes( char *buf, int n );
int main(void)
{
int count = IN_COUNT;
initbuffer();
/*if(maxbits < INIT_BITS) maxbits = INIT_BITS;*/
/* With our setting, maxbits = 16,
INIT_BITS = 9 */
/*if (maxbits > BITS) maxbits = BITS;*/
maxbits = BITS;
maxmaxcode = 1 << maxbits;
InCnt = count;
apsim_InCnt = IN_COUNT + 3;
InBuff = (unsigned char *)orig_text_buffer;
OutBuff = (unsigned char *)comp_text_buffer;
compress();
return (0);
}
void initbuffer(void)
{
int seed = 1;
int i;
int tabort;
for (i = 0 ; i < BUFFERSIZE ; i++) {
/* Generates random integers between 0 and 8095 */
tabort = i;
seed = ((seed * 133) + 81) % 8095;
orig_text_buffer[i] = seed % 256;
}
}
static int offset;
long int in_count = 1; /* length of input */
long int bytes_out; /* length of compressed output */
long int out_count = 0; /* # of codes output (for debugging) */
void compress(void)
{
register long fcode;
register code_int i = 0;
register int c;
register code_int ent;
register int disp;
register code_int hsize_reg;
register int hshift;
offset = 0;
bytes_out = 3; /* includes 3-byte header mojo */
out_count = 0;
clear_flg = 0;
ratio = 0;
in_count = 1;
checkpoint = CHECK_GAP;
maxcode = MAXCODE(n_bits = INIT_BITS);
free_ent = ((block_compress) ? (FIRST) : (256) );
ent = getbyte ();
hshift = 0;
for ( fcode = (long) hsize; fcode < 65536L; fcode *= 2L )
{
hshift++;
}
hshift = 8 - hshift; /* set hash code range bound */
hsize_reg = hsize;
cl_hash( (count_int) hsize_reg); /* clear hash table */
while ( InCnt > 0 ) /* apsim_loop 11 0 */
{
int apsim_bound111 = 0;
c = getbyte(); /* decrements InCnt */
in_count++;
fcode = (long) (((long) c << maxbits) + ent);
i = ((c << hshift) ^ ent); /* xor hashing */
if ( htabof (i) == fcode ) {
ent = codetabof (i);
continue;
} else if ( (long)htabof (i) < 0 ) { /* empty slot */
goto nomatch;
}
disp = hsize_reg - i; /* secondary hash (after G. Knott) */
if ( i == 0 ) {
disp = 1;
}
probe:
if ( (i -= disp) < 0 ) { /* apsim_loop 111 11 */
i += hsize_reg;
}
if ( htabof (i) == fcode ) {
ent = codetabof (i);
continue;
}
if ( (long)htabof (i) > 0 && (++apsim_bound111 < in_count) )
goto probe;
nomatch:
out_count++;
ent = c;
if ( free_ent < maxmaxcode ) {
codetabof (i) = free_ent++; /* apsim_unknown codetab */
htabof (i) = fcode; /* apsim_unknown htab */
} else if ( ((count_int)in_count >= checkpoint) && (block_compress) ) {
cl_block ();
}
}
if(bytes_out > in_count) { /* exit(2) if no savings */
exit_stat = 2;
}
return;
}
void cl_block (void) /* table clear for block compress */
{
register long int rat;
checkpoint = in_count + CHECK_GAP;
if(in_count > 0x007fffff) { /* shift will overflow */
rat = bytes_out >> 8;
if(rat == 0) { /* Don't divide by zero */
rat = 0x7fffffff;
} else {
rat = in_count / rat;
}
} else {
rat = (in_count << 8) / bytes_out; /* 8 fractional bits */
}
if ( rat > ratio ) {
ratio = rat;
} else {
ratio = 0;
cl_hash ( (count_int) hsize );
free_ent = FIRST;
clear_flg = 1;
output ( (code_int) CLEAR );
}
}
void cl_hash(count_int hsize) /* reset code table */
{
register count_int *htab_p = htab+hsize;
register long i;
register long m1 = -1;
i = hsize - 16;
do { /* might use Sys V memset(3) here */
*(htab_p-16) = m1;
*(htab_p-15) = m1;
*(htab_p-14) = m1;
*(htab_p-13) = m1;
*(htab_p-12) = m1;
*(htab_p-11) = m1;
*(htab_p-10) = m1;
*(htab_p-9) = m1;
*(htab_p-8) = m1;
*(htab_p-7) = m1;
*(htab_p-6) = m1;
*(htab_p-5) = m1;
*(htab_p-4) = m1;
*(htab_p-3) = m1;
*(htab_p-2) = m1;
*(htab_p-1) = m1;
htab_p -= 16;
} while ((i -= 16) >= 0);
for ( i += 16; i > 0; i-- ) {
*--htab_p = m1;
}
}
unsigned int getbyte(void)
{
if( InCnt > 0 && (apsim_InCnt-- > 0)) {
InCnt--;
return( (unsigned int)*InBuff++ );
} else {
return( -1 );
}
}
void putbyte( char c )
{
*OutBuff++ = c; /* apsim_unknown comp_text_buffer */
}
void writebytes( char *buf, int n )
{
int i;
for( i=0; (i<n) && /*apsim*/ (i < BITS) ; i++ ) {
*OutBuff++ = buf[i]; /* apsim_unknown comp_text_buffer */
}
}
/* apsim_rel 111 < 112 */
char_type lmask[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
void output( code_int code )
{
/*
* On the VAX, it is important to have the register declarations
* in exactly the order given, or the asm will break.
*/
register int r_off = offset, bits= n_bits;
register char * bp = buf;
if ( code >= 0 ) {
/*
* byte/bit numbering on the VAX is simulated by the following code
*/
/*
* Get to the first byte.
*/
bp += (r_off >> 3);
r_off &= 7;
/*
* Since code is always >= 8 bits, only need to mask the first
* hunk on the left.
*/
*bp = ((*bp & rmask[r_off]) | (code << r_off)) & lmask[r_off]; /* apsim_unknown buf */
bp++;
bits -= (8 - r_off);
code >>= 8 - r_off;
/* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
if ( bits >= 8 ) {
*bp++ = code; /* apsim_unknown buf */
code >>= 8;
bits -= 8;
}
/* Last bits. */
if(bits) {
*bp = code; /* apsim_unknown buf */
}
offset += n_bits;
if ( offset == (n_bits << 3) ) {
bp = buf;
bits = n_bits;
bytes_out += bits;
do {
putbyte(*bp++);
} while(( --bits) && ((bp - buf < BITS)));
offset = 0;
}
/*
* If the next entry is going to be too big for the code size,
* then increase it, if possible.
*/
if ( free_ent > maxcode || ((clear_flg > 0))) {
/*
* Write the whole buffer, because the input side won't
* discover the size increase until after it has read it.
*/
if ( offset > 0 ) {
writebytes( buf, n_bits );
bytes_out += n_bits;
}
offset = 0;
if ( clear_flg ) {
maxcode = MAXCODE (n_bits = INIT_BITS);
clear_flg = 0;
} else {
n_bits++;
if ( n_bits == maxbits )
{
maxcode = maxmaxcode;
}
else
{
maxcode = MAXCODE(n_bits);
}
}
}
} else {
/*
* At EOF, write the rest of the buffer.
*/
if ( offset > 0 )
{
writebytes( buf, ((offset + 7) / 8) );
}
bytes_out += (offset + 7) / 8;
offset = 0;
}
}

238
test/src/cover.c Executable file
View File

@ -0,0 +1,238 @@
int swi120(int c)
{
int i;
for (i=0; i<120; i++) {
switch (i) {
case 0: c++; break;
case 1: c++; break;
case 2: c++; break;
case 3: c++; break;
case 4: c++; break;
case 5: c++; break;
case 6: c++; break;
case 7: c++; break;
case 8: c++; break;
case 9: c++; break;
case 10: c++; break;
case 11: c++; break;
case 12: c++; break;
case 13: c++; break;
case 14: c++; break;
case 15: c++; break;
case 16: c++; break;
case 17: c++; break;
case 18: c++; break;
case 19: c++; break;
case 20: c++; break;
case 21: c++; break;
case 22: c++; break;
case 23: c++; break;
case 24: c++; break;
case 25: c++; break;
case 26: c++; break;
case 27: c++; break;
case 28: c++; break;
case 29: c++; break;
case 30: c++; break;
case 31: c++; break;
case 32: c++; break;
case 33: c++; break;
case 34: c++; break;
case 35: c++; break;
case 36: c++; break;
case 37: c++; break;
case 38: c++; break;
case 39: c++; break;
case 40: c++; break;
case 41: c++; break;
case 42: c++; break;
case 43: c++; break;
case 44: c++; break;
case 45: c++; break;
case 46: c++; break;
case 47: c++; break;
case 48: c++; break;
case 49: c++; break;
case 50: c++; break;
case 51: c++; break;
case 52: c++; break;
case 53: c++; break;
case 54: c++; break;
case 55: c++; break;
case 56: c++; break;
case 57: c++; break;
case 58: c++; break;
case 59: c++; break;
case 60: c++; break;
case 61: c++; break;
case 62: c++; break;
case 63: c++; break;
case 64: c++; break;
case 65: c++; break;
case 66: c++; break;
case 67: c++; break;
case 68: c++; break;
case 69: c++; break;
case 70: c++; break;
case 71: c++; break;
case 72: c++; break;
case 73: c++; break;
case 74: c++; break;
case 75: c++; break;
case 76: c++; break;
case 77: c++; break;
case 78: c++; break;
case 79: c++; break;
case 80: c++; break;
case 81: c++; break;
case 82: c++; break;
case 83: c++; break;
case 84: c++; break;
case 85: c++; break;
case 86: c++; break;
case 87: c++; break;
case 88: c++; break;
case 89: c++; break;
case 90: c++; break;
case 91: c++; break;
case 92: c++; break;
case 93: c++; break;
case 94: c++; break;
case 95: c++; break;
case 96: c++; break;
case 97: c++; break;
case 98: c++; break;
case 99: c++; break;
case 100: c++; break;
case 101: c++; break;
case 102: c++; break;
case 103: c++; break;
case 104: c++; break;
case 105: c++; break;
case 106: c++; break;
case 107: c++; break;
case 108: c++; break;
case 109: c++; break;
case 110: c++; break;
case 111: c++; break;
case 112: c++; break;
case 113: c++; break;
case 114: c++; break;
case 115: c++; break;
case 116: c++; break;
case 117: c++; break;
case 118: c++; break;
case 119: c++; break;
default: c--; break;
}
}
return c;
}
int swi50(int c)
{
int i;
for (i=0; i<50; i++) {
switch (i) {
case 0: c++; break;
case 1: c++; break;
case 2: c++; break;
case 3: c++; break;
case 4: c++; break;
case 5: c++; break;
case 6: c++; break;
case 7: c++; break;
case 8: c++; break;
case 9: c++; break;
case 10: c++; break;
case 11: c++; break;
case 12: c++; break;
case 13: c++; break;
case 14: c++; break;
case 15: c++; break;
case 16: c++; break;
case 17: c++; break;
case 18: c++; break;
case 19: c++; break;
case 20: c++; break;
case 21: c++; break;
case 22: c++; break;
case 23: c++; break;
case 24: c++; break;
case 25: c++; break;
case 26: c++; break;
case 27: c++; break;
case 28: c++; break;
case 29: c++; break;
case 30: c++; break;
case 31: c++; break;
case 32: c++; break;
case 33: c++; break;
case 34: c++; break;
case 35: c++; break;
case 36: c++; break;
case 37: c++; break;
case 38: c++; break;
case 39: c++; break;
case 40: c++; break;
case 41: c++; break;
case 42: c++; break;
case 43: c++; break;
case 44: c++; break;
case 45: c++; break;
case 46: c++; break;
case 47: c++; break;
case 48: c++; break;
case 49: c++; break;
case 50: c++; break;
case 51: c++; break;
case 52: c++; break;
case 53: c++; break;
case 54: c++; break;
case 55: c++; break;
case 56: c++; break;
case 57: c++; break;
case 58: c++; break;
case 59: c++; break;
default: c--; break;
}
}
return c;
}
int swi10(int c)
{
int i;
for (i=0; i<10; i++) {
switch (i) {
case 0: c++; break;
case 1: c++; break;
case 2: c++; break;
case 3: c++; break;
case 4: c++; break;
case 5: c++; break;
case 6: c++; break;
case 7: c++; break;
case 8: c++; break;
case 9: c++; break;
default: c--; break;
}
}
return c;
}
int main()
{
volatile int cnt=0;
cnt=swi10(cnt);
cnt=swi50(cnt);
cnt=swi120(cnt);
/* printf("cnt: %d\n", cnt); */
return cnt;
}

127
test/src/crc.c Executable file
View File

@ -0,0 +1,127 @@
/* $Id: crc.c,v 1.2 2005/04/04 11:34:58 csg Exp $ */
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: crc.c */
/* SOURCE : Numerical Recipes in C - The Second Edition */
/* */
/* DESCRIPTION : */
/* */
/* A demonstration for CRC (Cyclic Redundancy Check) operation. */
/* The CRC is manipulated as two functions, icrc1 and icrc. */
/* icrc1 is for one character and icrc uses icrc1 for a string. */
/* The input string is stored in array lin[]. */
/* icrc is called two times, one for X-Modem string CRC and the */
/* other for X-Modem packet CRC. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
typedef unsigned char uchar;
#define LOBYTE(x) ((uchar)((x) & 0xFF))
#define HIBYTE(x) ((uchar)((x) >> 8))
unsigned char lin[256] = "asdffeagewaHAFEFaeDsFEawFdsFaefaeerdjgp";
unsigned short icrc1(unsigned short crc, unsigned char onech)
{
int i;
unsigned short ans=(crc^onech << 8);
for (i=0;i<8;i++) {
if (ans & 0x8000)
ans = (ans <<= 1) ^ 4129;
else
ans <<= 1;
}
return ans;
}
unsigned short icrc(unsigned short crc, unsigned long len,
short jinit, int jrev)
{
unsigned short icrc1(unsigned short crc, unsigned char onech);
static unsigned short icrctb[256],init=0;
static uchar rchr[256];
unsigned short tmp1, tmp2, j,cword=crc;
static uchar it[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
if (!init) {
init=1;
for (j=0;j<=255;j++) {
icrctb[j]=icrc1(j << 8,(uchar)0);
rchr[j]=(uchar)(it[j & 0xF] << 4 | it[j >> 4]);
}
}
if (jinit >= 0) cword=((uchar) jinit) | (((uchar) jinit) << 8);
else if (jrev < 0)
cword=rchr[HIBYTE(cword)] | rchr[LOBYTE(cword)] << 8;
#ifdef DEBUG
printf("len = %d\n", len);
#endif
for (j=1;j<=len;j++) {
if (jrev < 0) {
tmp1 = rchr[lin[j]]^ HIBYTE(cword);
}
else {
tmp1 = lin[j]^ HIBYTE(cword);
}
cword = icrctb[tmp1] ^ LOBYTE(cword) << 8;
}
if (jrev >= 0) {
tmp2 = cword;
}
else {
tmp2 = rchr[HIBYTE(cword)] | rchr[LOBYTE(cword)] << 8;
}
return (tmp2 );
}
int main(void)
{
unsigned short i1,i2;
unsigned long n;
n=40;
lin[n+1]=0;
i1=icrc(0,n,(short)0,1);
lin[n+1]=HIBYTE(i1);
lin[n+2]=LOBYTE(i1);
i2=icrc(i1,n+2,(short)0,1);
return 0;
}

777
test/src/dijkstra.c Normal file
View File

@ -0,0 +1,777 @@
#include <stdint.h>
#include <stdio.h>
#define NUM_NODES 100
#define NONE 9999
// START MALLOC
#define SIMPLE_ALLOC_SIZE 16384
void *s_malloc(unsigned long size);
void s_free(void *mem);
volatile unsigned int sanity = 512;
char alloc_pool[SIMPLE_ALLOC_SIZE];
char *alloc_ptr = alloc_pool;
void *s_malloc(unsigned long size) {
char *copy = alloc_ptr;
alloc_ptr += size;
if (alloc_ptr >= alloc_pool + SIMPLE_ALLOC_SIZE) {
// Wraparound alloc
alloc_ptr = alloc_pool + size;
return alloc_pool;
}
return copy;
}
void s_free(void *mem) {}
// END MALLOC
// START DATA
unsigned long dijkstra_input_data[100][100] = {
{32, 32, 54, 12, 52, 56, 8, 30, 44, 94, 44, 39, 65, 19, 51, 91, 1,
5, 89, 34, 25, 58, 20, 51, 38, 65, 30, 7, 20, 10, 51, 18, 43, 71,
97, 61, 26, 5, 57, 70, 65, 0, 75, 29, 86, 93, 87, 87, 64, 75, 88,
89, 100, 7, 40, 37, 38, 36, 44, 24, 46, 95, 43, 89, 32, 5, 15, 58,
77, 72, 95, 8, 38, 69, 37, 24, 27, 90, 77, 92, 31, 30, 80, 30, 37,
86, 33, 76, 21, 77, 100, 68, 37, 8, 22, 69, 81, 38, 94, 57},
{76, 54, 65, 14, 89, 69, 4, 16, 24, 47, 7, 21, 78, 53, 17, 81, 39,
50, 22, 60, 93, 89, 94, 30, 97, 16, 65, 43, 20, 24, 67, 62, 78, 98,
42, 67, 32, 46, 49, 57, 60, 56, 44, 37, 75, 62, 17, 13, 11, 40, 40,
4, 95, 100, 0, 57, 82, 31, 0, 1, 56, 67, 30, 100, 64, 72, 66, 63,
18, 81, 19, 44, 2, 63, 81, 78, 91, 64, 91, 2, 70, 97, 73, 64, 97,
39, 21, 78, 70, 21, 46, 25, 54, 76, 92, 84, 47, 57, 46, 31},
{38, 31, 75, 40, 61, 21, 84, 51, 86, 41, 19, 21, 37, 58, 86, 100, 97,
73, 44, 67, 60, 90, 58, 13, 31, 49, 63, 44, 73, 76, 76, 77, 73, 16,
83, 100, 4, 67, 51, 56, 7, 36, 77, 10, 95, 28, 10, 57, 0, 54, 23,
60, 9, 48, 39, 40, 97, 69, 84, 35, 44, 25, 11, 83, 8, 61, 83, 12,
27, 100, 34, 0, 35, 10, 10, 96, 39, 87, 53, 5, 40, 42, 66, 15, 90,
71, 55, 87, 39, 5, 88, 49, 97, 100, 32, 4, 60, 81, 83, 53},
{80, 16, 53, 14, 94, 29, 77, 99, 16, 29, 3, 22, 71, 35, 4, 61, 6,
25, 13, 11, 30, 0, 27, 94, 66, 25, 64, 92, 5, 47, 44, 85, 29, 63,
65, 89, 59, 41, 87, 41, 36, 57, 29, 7, 92, 33, 34, 64, 59, 47, 76,
55, 13, 2, 48, 46, 27, 12, 37, 99, 25, 48, 83, 20, 77, 13, 9, 35,
55, 62, 76, 57, 18, 72, 64, 10, 4, 64, 74, 63, 77, 15, 18, 91, 84,
32, 36, 77, 10, 39, 75, 35, 87, 23, 22, 30, 37, 31, 65, 58},
{59, 7, 14, 78, 79, 45, 54, 83, 8, 94, 12, 86, 9, 97, 42, 93, 95,
44, 70, 5, 83, 10, 40, 36, 34, 62, 66, 71, 59, 97, 95, 18, 3, 8,
62, 48, 19, 15, 98, 28, 8, 9, 80, 84, 72, 21, 43, 66, 65, 79, 71,
13, 89, 78, 49, 22, 5, 14, 59, 65, 11, 53, 49, 81, 28, 77, 29, 47,
92, 26, 41, 66, 1, 20, 50, 73, 7, 59, 4, 72, 37, 76, 86, 25, 19,
0, 14, 24, 15, 73, 55, 93, 93, 3, 73, 87, 80, 68, 100, 37},
{94, 41, 3, 61, 27, 19, 33, 35, 78, 38, 73, 14, 80, 58, 5, 99, 59,
19, 22, 40, 59, 78, 32, 17, 47, 71, 3, 94, 39, 2, 97, 99, 9, 66,
60, 37, 85, 59, 38, 28, 63, 10, 8, 8, 35, 81, 6, 60, 100, 96, 66,
24, 39, 64, 41, 52, 34, 10, 11, 39, 80, 8, 4, 89, 74, 64, 92, 25,
89, 29, 19, 18, 6, 28, 26, 7, 8, 33, 67, 74, 95, 32, 99, 33, 96,
5, 51, 96, 83, 63, 35, 62, 71, 39, 16, 10, 69, 8, 35, 23},
{3, 55, 41, 76, 49, 68, 83, 23, 67, 15, 97, 61, 13, 61, 60, 75, 33,
77, 71, 15, 39, 72, 43, 76, 77, 59, 53, 11, 33, 88, 34, 37, 8, 76,
79, 23, 9, 62, 46, 76, 43, 9, 2, 57, 70, 28, 31, 69, 4, 68, 84,
10, 39, 26, 52, 82, 52, 4, 93, 85, 59, 94, 21, 33, 35, 67, 57, 44,
28, 69, 86, 37, 78, 54, 94, 14, 48, 25, 83, 18, 59, 33, 28, 99, 25,
81, 46, 77, 51, 39, 62, 9, 32, 49, 43, 33, 15, 100, 77, 9},
{68, 28, 47, 12, 82, 6, 26, 96, 98, 75, 13, 57, 7, 8, 55, 33, 55,
0, 76, 5, 5, 3, 15, 3, 53, 58, 36, 34, 23, 79, 10, 57, 6, 23,
69, 54, 29, 61, 49, 27, 36, 63, 84, 9, 71, 4, 8, 25, 71, 85, 97,
77, 88, 11, 46, 6, 35, 83, 7, 24, 27, 17, 82, 34, 40, 16, 88, 69,
44, 3, 62, 46, 32, 45, 55, 2, 49, 64, 94, 87, 14, 90, 63, 68, 68,
75, 75, 2, 23, 82, 27, 51, 65, 75, 85, 71, 57, 38, 39, 0},
{7, 1, 46, 39, 12, 68, 41, 28, 31, 0, 14, 45, 91, 43, 12, 58, 17,
53, 26, 41, 0, 19, 92, 31, 60, 42, 1, 17, 46, 41, 84, 54, 8, 97,
93, 20, 64, 0, 14, 61, 0, 28, 72, 57, 71, 50, 81, 89, 70, 7, 96,
70, 26, 87, 1, 87, 95, 69, 70, 40, 9, 19, 94, 84, 15, 87, 71, 45,
87, 85, 5, 53, 13, 43, 10, 50, 94, 91, 38, 63, 98, 33, 99, 91, 86,
66, 43, 80, 35, 79, 20, 10, 98, 80, 61, 13, 66, 31, 24, 18},
{82, 97, 72, 61, 39, 48, 11, 99, 38, 49, 27, 2, 49, 26, 59, 0, 58,
1, 81, 59, 80, 67, 70, 77, 46, 97, 56, 79, 27, 81, 63, 75, 77, 0,
36, 82, 48, 47, 81, 53, 62, 7, 55, 77, 100, 13, 78, 24, 81, 24, 83,
26, 91, 18, 2, 2, 14, 25, 47, 7, 72, 10, 83, 14, 10, 18, 96, 25,
65, 42, 78, 93, 16, 32, 70, 15, 11, 47, 5, 58, 71, 89, 84, 27, 73,
86, 96, 88, 77, 43, 95, 48, 19, 43, 62, 96, 61, 24, 20, 92},
{66, 98, 85, 82, 96, 20, 64, 73, 67, 69, 30, 3, 23, 13, 97, 97, 66,
58, 50, 42, 0, 44, 57, 86, 54, 85, 82, 14, 8, 1, 73, 41, 66, 23,
22, 61, 43, 86, 0, 9, 21, 30, 79, 44, 44, 75, 40, 76, 99, 56, 17,
100, 67, 40, 51, 20, 25, 32, 0, 100, 0, 73, 40, 66, 96, 29, 93, 38,
81, 93, 13, 1, 90, 92, 46, 100, 32, 52, 75, 31, 8, 58, 97, 75, 99,
13, 61, 90, 46, 61, 89, 12, 34, 96, 78, 96, 24, 36, 34, 4},
{96, 13, 73, 85, 72, 18, 50, 70, 36, 24, 67, 10, 82, 29, 51, 80, 43,
11, 35, 89, 39, 24, 0, 73, 86, 44, 34, 9, 46, 34, 80, 41, 48, 52,
92, 19, 36, 41, 55, 39, 31, 22, 49, 13, 51, 67, 59, 94, 44, 95, 48,
83, 85, 48, 21, 70, 58, 56, 45, 4, 90, 91, 11, 3, 43, 70, 89, 45,
77, 44, 84, 8, 66, 100, 88, 83, 66, 46, 77, 76, 6, 24, 59, 91, 39,
46, 26, 97, 68, 37, 0, 58, 28, 79, 27, 37, 48, 16, 82, 24},
{60, 66, 32, 92, 65, 19, 74, 97, 32, 16, 72, 38, 41, 97, 96, 46, 43,
88, 42, 77, 25, 9, 34, 19, 88, 28, 56, 1, 44, 3, 25, 70, 69, 24,
27, 100, 9, 0, 96, 7, 84, 34, 12, 91, 30, 7, 36, 39, 95, 78, 16,
86, 53, 16, 71, 6, 44, 26, 7, 54, 30, 100, 23, 65, 23, 50, 65, 99,
17, 26, 73, 67, 60, 85, 57, 57, 92, 93, 96, 52, 36, 78, 4, 90, 61,
75, 96, 4, 68, 3, 25, 64, 69, 14, 28, 58, 31, 59, 56, 48},
{86, 28, 81, 45, 12, 37, 1, 70, 29, 64, 89, 31, 41, 93, 20, 1, 67,
83, 73, 0, 52, 98, 64, 20, 78, 93, 78, 8, 17, 100, 22, 2, 95, 2,
48, 6, 39, 15, 43, 34, 79, 31, 66, 87, 23, 52, 54, 56, 34, 93, 57,
52, 56, 87, 72, 34, 79, 15, 42, 63, 15, 65, 65, 9, 67, 79, 82, 73,
95, 91, 6, 39, 21, 38, 92, 10, 91, 46, 67, 91, 38, 90, 43, 95, 76,
81, 28, 21, 63, 70, 84, 78, 0, 48, 53, 68, 94, 0, 40, 88},
{92, 12, 93, 12, 17, 85, 23, 7, 30, 56, 64, 34, 45, 73, 28, 87, 20,
22, 7, 83, 59, 91, 26, 59, 5, 79, 26, 99, 79, 32, 52, 70, 11, 44,
83, 28, 95, 72, 1, 91, 27, 65, 25, 38, 4, 19, 24, 24, 8, 99, 73,
67, 89, 99, 25, 60, 77, 18, 24, 21, 16, 42, 58, 27, 53, 6, 55, 47,
78, 56, 38, 71, 88, 29, 8, 58, 48, 99, 48, 56, 97, 20, 89, 52, 18,
14, 78, 61, 99, 2, 48, 14, 44, 5, 42, 97, 11, 63, 10, 55},
{19, 48, 25, 73, 77, 100, 30, 91, 99, 78, 13, 95, 98, 1, 12, 82, 82,
91, 8, 80, 93, 22, 61, 2, 28, 2, 66, 5, 65, 76, 61, 50, 90, 86,
22, 32, 52, 52, 22, 50, 96, 1, 10, 59, 70, 90, 40, 51, 80, 14, 98,
38, 37, 58, 40, 31, 60, 72, 2, 91, 47, 63, 7, 2, 15, 29, 34, 67,
48, 23, 83, 9, 24, 59, 69, 94, 48, 8, 11, 27, 90, 8, 31, 93, 32,
38, 90, 58, 9, 92, 48, 23, 55, 55, 25, 36, 51, 60, 69, 65},
{83, 51, 74, 73, 76, 42, 67, 24, 17, 44, 17, 73, 18, 49, 65, 50, 87,
54, 7, 62, 11, 21, 85, 32, 77, 10, 68, 94, 70, 36, 24, 52, 53, 98,
24, 96, 6, 57, 86, 90, 67, 2, 62, 85, 17, 26, 34, 70, 46, 41, 32,
23, 63, 16, 56, 5, 26, 23, 65, 62, 26, 89, 80, 45, 52, 71, 6, 58,
27, 92, 47, 61, 61, 75, 45, 78, 67, 46, 14, 12, 53, 46, 36, 82, 28,
58, 87, 21, 47, 17, 83, 73, 72, 63, 85, 24, 33, 91, 48, 26},
{49, 62, 53, 9, 36, 99, 53, 3, 10, 67, 82, 63, 79, 84, 45, 7, 41,
98, 95, 89, 82, 43, 27, 53, 5, 78, 77, 4, 69, 25, 98, 17, 53, 16,
93, 89, 81, 45, 58, 91, 12, 40, 54, 91, 90, 65, 64, 31, 62, 58, 86,
43, 1, 12, 63, 73, 91, 39, 44, 25, 30, 7, 8, 83, 23, 0, 38, 4,
45, 96, 61, 23, 1, 14, 81, 92, 45, 44, 89, 74, 69, 74, 83, 36, 52,
45, 75, 8, 85, 18, 100, 81, 92, 7, 30, 82, 74, 34, 52, 86},
{96, 12, 8, 98, 94, 89, 55, 38, 100, 43, 11, 68, 83, 95, 3, 0, 39,
78, 9, 90, 63, 8, 37, 20, 83, 67, 1, 56, 67, 53, 7, 62, 66, 16,
25, 25, 71, 80, 63, 70, 89, 75, 3, 37, 35, 6, 38, 74, 51, 47, 30,
80, 21, 67, 100, 3, 100, 68, 26, 66, 87, 33, 27, 52, 15, 53, 43, 53,
99, 6, 22, 88, 47, 26, 24, 82, 99, 28, 21, 15, 75, 51, 95, 63, 84,
61, 66, 83, 28, 58, 14, 14, 58, 42, 33, 39, 61, 76, 92, 25},
{48, 14, 79, 95, 6, 70, 76, 4, 98, 98, 87, 39, 14, 81, 1, 99, 7,
33, 81, 1, 92, 96, 16, 15, 3, 15, 54, 30, 57, 12, 55, 5, 93, 0,
100, 99, 70, 42, 69, 67, 39, 21, 5, 53, 2, 6, 51, 76, 40, 99, 78,
98, 60, 60, 79, 63, 75, 99, 59, 98, 10, 80, 2, 2, 80, 69, 67, 49,
10, 2, 16, 49, 23, 88, 68, 92, 95, 86, 68, 0, 84, 11, 64, 43, 71,
42, 72, 45, 40, 97, 42, 17, 76, 11, 86, 56, 80, 19, 4, 90},
{88, 87, 4, 77, 75, 72, 69, 35, 23, 2, 35, 6, 80, 99, 15, 50, 6,
53, 61, 46, 49, 69, 29, 25, 80, 15, 47, 25, 34, 51, 14, 21, 38, 85,
98, 79, 57, 32, 13, 46, 0, 48, 53, 80, 12, 34, 29, 18, 54, 56, 30,
2, 25, 60, 94, 4, 41, 40, 30, 75, 58, 10, 62, 62, 96, 59, 40, 18,
58, 53, 64, 24, 67, 83, 4, 79, 17, 100, 63, 37, 56, 93, 39, 81, 18,
100, 51, 59, 5, 81, 100, 63, 58, 61, 24, 53, 87, 64, 37, 10},
{83, 67, 34, 49, 50, 38, 27, 33, 4, 56, 70, 60, 15, 75, 6, 33, 40,
57, 59, 46, 4, 24, 75, 62, 86, 100, 81, 38, 29, 17, 48, 79, 84, 48,
27, 100, 87, 21, 32, 57, 77, 68, 16, 92, 9, 22, 92, 49, 79, 16, 95,
83, 40, 70, 10, 25, 35, 91, 29, 30, 74, 43, 8, 24, 92, 2, 23, 44,
23, 22, 0, 66, 56, 16, 58, 65, 4, 15, 14, 49, 31, 75, 32, 71, 10,
8, 63, 45, 100, 92, 42, 73, 1, 50, 97, 93, 18, 87, 36, 41},
{75, 36, 7, 30, 18, 31, 96, 22, 12, 76, 71, 43, 50, 69, 80, 61, 78,
42, 72, 43, 0, 13, 15, 68, 30, 79, 60, 48, 31, 62, 56, 5, 98, 29,
1, 82, 26, 97, 3, 38, 72, 40, 81, 89, 76, 26, 15, 53, 35, 87, 96,
1, 67, 77, 69, 97, 21, 28, 10, 18, 90, 32, 23, 53, 61, 25, 34, 87,
88, 3, 91, 26, 9, 37, 81, 85, 64, 96, 3, 99, 82, 65, 100, 48, 42,
68, 10, 29, 62, 88, 48, 17, 19, 37, 70, 47, 28, 70, 100, 16},
{73, 91, 8, 82, 94, 89, 33, 57, 84, 36, 21, 31, 1, 87, 46, 9, 20,
56, 4, 82, 9, 52, 99, 96, 56, 34, 8, 84, 3, 7, 66, 42, 64, 74,
24, 58, 28, 23, 81, 11, 59, 2, 9, 26, 55, 55, 1, 76, 77, 6, 23,
87, 24, 89, 82, 80, 22, 90, 30, 93, 63, 96, 34, 27, 36, 24, 51, 30,
47, 98, 8, 73, 100, 17, 99, 21, 72, 0, 97, 48, 73, 86, 34, 97, 74,
82, 43, 63, 37, 73, 55, 0, 34, 55, 94, 36, 80, 10, 67, 93},
{7, 75, 65, 74, 92, 64, 95, 63, 30, 57, 77, 2, 42, 11, 65, 16, 59,
7, 45, 97, 46, 66, 63, 81, 20, 56, 83, 66, 32, 49, 59, 39, 90, 23,
12, 81, 53, 73, 9, 49, 29, 87, 17, 72, 64, 83, 54, 89, 90, 65, 85,
36, 30, 13, 83, 16, 35, 65, 83, 67, 14, 7, 73, 70, 97, 85, 51, 16,
24, 26, 65, 53, 79, 83, 91, 8, 65, 10, 98, 20, 41, 48, 22, 71, 62,
4, 54, 63, 36, 36, 30, 16, 9, 2, 86, 5, 53, 36, 88, 77},
{29, 53, 97, 74, 1, 53, 83, 32, 30, 46, 52, 71, 94, 41, 42, 21, 45,
62, 85, 81, 98, 81, 97, 73, 83, 83, 44, 1, 85, 32, 45, 80, 85, 41,
54, 52, 60, 2, 84, 90, 48, 1, 61, 7, 42, 69, 96, 54, 30, 46, 0,
94, 26, 64, 32, 75, 46, 76, 42, 97, 7, 87, 43, 58, 94, 97, 9, 54,
99, 59, 43, 12, 61, 70, 19, 69, 4, 14, 22, 0, 26, 23, 60, 52, 53,
92, 93, 65, 68, 35, 61, 75, 88, 70, 33, 82, 66, 8, 35, 30},
{68, 44, 8, 95, 81, 28, 63, 85, 8, 52, 86, 35, 41, 11, 53, 94, 3,
12, 58, 71, 13, 85, 11, 0, 55, 44, 82, 87, 19, 83, 84, 87, 27, 92,
81, 7, 86, 9, 58, 61, 27, 9, 62, 68, 21, 81, 61, 24, 93, 85, 61,
72, 70, 72, 73, 91, 16, 20, 77, 35, 3, 26, 88, 97, 18, 34, 3, 70,
9, 27, 30, 37, 37, 92, 4, 24, 73, 32, 48, 31, 83, 8, 3, 52, 80,
42, 8, 62, 62, 52, 63, 65, 78, 16, 27, 62, 50, 30, 32, 26},
{24, 62, 63, 27, 20, 67, 51, 59, 65, 65, 90, 48, 73, 93, 66, 18, 0,
75, 47, 63, 26, 76, 94, 3, 59, 21, 66, 75, 17, 64, 0, 41, 25, 63,
68, 11, 97, 85, 70, 61, 49, 60, 8, 88, 18, 41, 6, 19, 15, 19, 48,
41, 61, 41, 10, 19, 62, 42, 95, 46, 5, 95, 53, 98, 58, 21, 8, 20,
5, 79, 81, 21, 4, 56, 8, 89, 97, 81, 74, 11, 100, 21, 18, 61, 29,
95, 46, 57, 37, 40, 2, 42, 1, 56, 5, 59, 43, 14, 79, 14},
{59, 25, 35, 29, 81, 44, 84, 43, 24, 58, 20, 91, 45, 38, 17, 74, 100,
63, 31, 36, 3, 33, 44, 71, 55, 50, 96, 98, 30, 40, 12, 55, 65, 13,
50, 12, 57, 33, 55, 48, 91, 42, 38, 36, 46, 55, 76, 45, 17, 6, 81,
87, 6, 25, 57, 61, 41, 52, 25, 37, 92, 3, 92, 23, 16, 7, 35, 74,
40, 56, 21, 98, 98, 59, 100, 44, 80, 75, 89, 97, 82, 36, 50, 54, 27,
6, 14, 68, 25, 5, 4, 83, 8, 62, 5, 25, 69, 40, 65, 75},
{63, 52, 72, 60, 10, 71, 70, 56, 12, 59, 52, 94, 95, 68, 13, 21, 41,
94, 55, 66, 100, 25, 48, 7, 53, 54, 99, 88, 60, 63, 62, 22, 14, 34,
49, 91, 71, 18, 46, 83, 77, 65, 42, 37, 32, 55, 24, 39, 15, 45, 4,
14, 36, 19, 21, 89, 39, 87, 76, 99, 49, 4, 88, 64, 4, 36, 54, 75,
20, 67, 24, 64, 31, 32, 0, 29, 54, 92, 69, 69, 36, 39, 83, 39, 58,
70, 27, 63, 56, 70, 28, 5, 74, 15, 35, 78, 17, 55, 18, 37},
{88, 8, 0, 85, 41, 68, 14, 95, 59, 49, 63, 61, 54, 11, 66, 79, 81,
94, 41, 3, 29, 69, 75, 69, 50, 9, 46, 33, 30, 30, 71, 18, 39, 37,
2, 80, 4, 83, 40, 29, 98, 2, 57, 52, 13, 22, 30, 60, 82, 71, 29,
10, 6, 3, 79, 22, 79, 91, 56, 76, 21, 26, 94, 26, 63, 62, 72, 34,
45, 11, 29, 42, 13, 86, 94, 93, 75, 90, 18, 56, 27, 48, 33, 33, 17,
78, 55, 63, 69, 10, 38, 56, 2, 31, 48, 32, 93, 19, 32, 3},
{30, 61, 46, 43, 13, 5, 1, 88, 96, 86, 9, 89, 100, 42, 21, 17, 20,
42, 80, 55, 19, 17, 10, 88, 14, 58, 19, 6, 77, 17, 77, 73, 79, 22,
15, 58, 94, 83, 45, 55, 68, 20, 43, 68, 63, 30, 51, 49, 39, 97, 3,
58, 13, 80, 45, 27, 3, 31, 100, 80, 48, 76, 52, 93, 64, 33, 50, 24,
82, 61, 45, 15, 82, 89, 49, 10, 85, 100, 59, 23, 96, 28, 81, 75, 7,
93, 68, 10, 90, 34, 56, 3, 76, 74, 97, 6, 73, 12, 30, 20},
{40, 75, 35, 88, 29, 85, 64, 14, 50, 22, 37, 12, 16, 85, 87, 23, 77,
21, 100, 66, 55, 21, 35, 30, 95, 31, 2, 33, 10, 32, 53, 16, 74, 54,
70, 69, 38, 33, 83, 55, 55, 87, 67, 71, 71, 19, 60, 13, 40, 25, 45,
61, 46, 80, 58, 6, 78, 60, 39, 88, 93, 58, 70, 32, 11, 39, 0, 16,
72, 50, 71, 93, 36, 37, 29, 6, 56, 55, 19, 63, 80, 64, 23, 25, 43,
81, 98, 87, 41, 2, 40, 100, 60, 9, 31, 37, 14, 98, 53, 86},
{47, 90, 44, 83, 26, 73, 55, 49, 27, 40, 11, 73, 70, 0, 64, 13, 82,
61, 66, 89, 29, 6, 88, 89, 15, 85, 93, 30, 82, 11, 82, 96, 1, 26,
78, 27, 65, 100, 42, 93, 39, 53, 31, 9, 54, 96, 89, 1, 22, 54, 90,
52, 60, 43, 6, 42, 27, 99, 72, 75, 10, 19, 70, 11, 45, 14, 4, 10,
13, 47, 69, 52, 66, 100, 27, 86, 61, 15, 53, 84, 36, 42, 35, 96, 85,
41, 37, 78, 40, 75, 53, 16, 95, 22, 94, 5, 36, 98, 15, 15},
{10, 50, 34, 77, 16, 61, 28, 77, 43, 82, 60, 79, 90, 95, 74, 41, 2,
78, 18, 8, 18, 71, 24, 12, 60, 17, 85, 62, 81, 66, 78, 92, 16, 11,
34, 32, 38, 28, 75, 81, 9, 1, 59, 66, 62, 100, 6, 64, 43, 24, 72,
61, 62, 62, 40, 21, 79, 24, 49, 26, 90, 26, 84, 72, 3, 84, 70, 8,
11, 45, 89, 88, 46, 14, 53, 74, 80, 59, 38, 89, 83, 9, 15, 10, 38,
55, 31, 83, 45, 81, 8, 1, 73, 92, 73, 43, 75, 9, 51, 53},
{54, 5, 40, 66, 86, 59, 39, 31, 17, 43, 19, 66, 19, 1, 77, 57, 22,
74, 39, 68, 20, 14, 35, 60, 5, 7, 2, 47, 16, 19, 66, 36, 91, 5,
68, 43, 30, 74, 40, 47, 83, 26, 79, 1, 27, 21, 24, 49, 96, 64, 83,
82, 78, 17, 41, 49, 92, 9, 62, 74, 28, 27, 77, 86, 99, 44, 95, 28,
84, 34, 41, 33, 60, 20, 34, 87, 41, 59, 36, 2, 89, 85, 85, 32, 2,
25, 47, 94, 35, 9, 67, 29, 2, 43, 81, 1, 54, 75, 96, 3},
{9, 37, 36, 35, 23, 37, 22, 30, 62, 24, 33, 50, 8, 84, 48, 77, 8,
95, 70, 9, 70, 37, 5, 73, 46, 86, 74, 100, 27, 35, 70, 2, 72, 5,
37, 95, 42, 25, 25, 3, 49, 24, 19, 24, 7, 67, 0, 82, 28, 71, 92,
98, 74, 63, 70, 86, 14, 9, 52, 41, 45, 21, 43, 83, 93, 47, 44, 35,
72, 35, 4, 88, 59, 91, 11, 32, 57, 11, 13, 51, 48, 71, 49, 88, 33,
85, 40, 48, 61, 92, 55, 5, 79, 65, 54, 71, 11, 98, 72, 83},
{32, 43, 70, 57, 33, 47, 89, 56, 25, 69, 7, 73, 39, 56, 27, 39, 6,
67, 53, 67, 24, 74, 38, 2, 38, 93, 73, 49, 56, 11, 99, 89, 54, 34,
11, 87, 48, 67, 42, 73, 35, 49, 11, 40, 71, 4, 45, 78, 71, 98, 10,
95, 38, 49, 63, 76, 41, 36, 92, 97, 47, 56, 51, 0, 56, 63, 53, 3,
29, 95, 76, 30, 44, 54, 70, 81, 58, 82, 58, 96, 45, 69, 56, 83, 84,
19, 59, 24, 21, 16, 87, 34, 72, 4, 0, 27, 33, 53, 31, 28},
{47, 73, 58, 57, 26, 94, 38, 85, 75, 62, 80, 87, 97, 35, 69, 80, 20,
27, 3, 41, 43, 57, 75, 81, 27, 75, 8, 60, 27, 5, 88, 41, 78, 11,
98, 71, 71, 1, 55, 12, 64, 0, 99, 60, 1, 67, 40, 22, 61, 9, 63,
70, 32, 4, 51, 59, 79, 25, 18, 73, 30, 72, 13, 7, 49, 77, 78, 87,
79, 99, 99, 42, 65, 63, 68, 67, 96, 7, 55, 56, 84, 84, 93, 15, 88,
43, 75, 33, 34, 59, 72, 64, 98, 85, 37, 12, 27, 82, 99, 5},
{80, 63, 13, 11, 92, 48, 44, 88, 55, 99, 9, 4, 48, 1, 20, 2, 10,
61, 1, 44, 86, 73, 74, 83, 23, 11, 62, 50, 93, 26, 22, 38, 90, 1,
15, 47, 49, 59, 34, 71, 23, 44, 75, 38, 11, 61, 40, 22, 21, 41, 32,
7, 13, 6, 56, 36, 84, 17, 52, 76, 44, 74, 80, 100, 42, 96, 46, 91,
20, 81, 27, 10, 91, 2, 48, 1, 29, 88, 90, 51, 95, 22, 58, 7, 95,
13, 9, 78, 31, 61, 19, 41, 1, 65, 40, 43, 26, 86, 100, 47},
{32, 94, 23, 22, 62, 71, 91, 91, 58, 80, 41, 18, 68, 65, 25, 62, 79,
0, 5, 76, 27, 24, 83, 28, 56, 22, 37, 82, 74, 3, 95, 6, 97, 17,
95, 24, 54, 85, 14, 78, 31, 56, 96, 99, 20, 87, 27, 65, 87, 32, 6,
14, 23, 89, 8, 45, 77, 12, 26, 51, 82, 88, 23, 44, 71, 17, 68, 25,
69, 82, 2, 100, 3, 99, 64, 91, 85, 91, 21, 38, 90, 28, 52, 79, 83,
26, 23, 60, 38, 49, 10, 86, 2, 33, 29, 74, 16, 97, 65, 51},
{45, 67, 16, 48, 31, 81, 4, 16, 37, 26, 20, 93, 20, 38, 71, 2, 64,
94, 62, 69, 9, 72, 54, 11, 71, 84, 51, 54, 80, 15, 4, 24, 83, 88,
39, 80, 68, 43, 62, 71, 35, 82, 64, 55, 19, 0, 58, 84, 95, 19, 18,
3, 58, 72, 81, 95, 55, 32, 14, 1, 47, 19, 92, 96, 6, 30, 76, 40,
40, 37, 77, 75, 19, 6, 30, 38, 7, 54, 88, 68, 73, 5, 71, 97, 78,
51, 58, 99, 49, 72, 66, 97, 57, 58, 58, 63, 54, 33, 69, 60},
{37, 12, 1, 56, 18, 31, 60, 92, 51, 14, 59, 90, 19, 29, 87, 63, 47,
10, 28, 96, 82, 94, 58, 39, 17, 16, 68, 38, 15, 3, 64, 52, 15, 65,
74, 100, 62, 0, 92, 12, 14, 50, 2, 33, 46, 55, 63, 59, 65, 91, 20,
46, 50, 79, 51, 34, 61, 19, 72, 76, 89, 35, 95, 3, 67, 68, 69, 28,
68, 60, 41, 82, 77, 43, 82, 22, 98, 44, 47, 28, 0, 67, 74, 50, 11,
92, 84, 72, 77, 21, 14, 65, 23, 8, 34, 90, 42, 2, 84, 10},
{63, 24, 58, 5, 33, 5, 94, 97, 15, 40, 24, 15, 6, 65, 32, 18, 56,
82, 56, 32, 70, 70, 97, 93, 78, 30, 48, 87, 99, 31, 97, 27, 22, 20,
32, 55, 93, 25, 52, 7, 31, 42, 90, 4, 6, 88, 89, 62, 35, 44, 60,
4, 81, 56, 63, 24, 52, 10, 10, 17, 8, 73, 44, 30, 94, 77, 51, 86,
68, 69, 59, 66, 11, 48, 70, 84, 1, 58, 12, 37, 68, 72, 41, 48, 95,
71, 73, 12, 47, 83, 29, 55, 56, 74, 51, 15, 16, 2, 67, 50},
{71, 92, 15, 82, 6, 51, 66, 7, 75, 44, 44, 43, 15, 52, 57, 9, 22,
96, 89, 35, 79, 17, 91, 0, 57, 7, 82, 73, 9, 14, 90, 81, 5, 4,
28, 11, 22, 60, 19, 97, 3, 29, 5, 86, 81, 63, 61, 69, 58, 49, 71,
2, 67, 27, 69, 90, 34, 50, 29, 44, 64, 18, 91, 36, 89, 85, 47, 10,
45, 32, 7, 14, 62, 12, 100, 8, 41, 61, 44, 100, 9, 14, 68, 42, 41,
37, 99, 75, 87, 27, 85, 17, 45, 75, 53, 33, 26, 66, 10, 71},
{99, 84, 85, 60, 62, 51, 68, 3, 11, 11, 69, 87, 92, 36, 96, 32, 39,
94, 74, 93, 87, 58, 9, 31, 100, 28, 30, 25, 94, 6, 62, 92, 90, 12,
17, 52, 29, 86, 55, 40, 63, 90, 94, 21, 92, 55, 53, 31, 14, 93, 23,
0, 17, 99, 98, 16, 26, 27, 7, 86, 34, 35, 78, 90, 13, 95, 41, 43,
46, 62, 49, 76, 51, 42, 97, 9, 63, 15, 40, 77, 8, 63, 43, 25, 61,
40, 7, 53, 68, 81, 38, 68, 82, 82, 57, 95, 43, 65, 37, 55},
{93, 87, 30, 10, 95, 93, 19, 58, 75, 59, 0, 83, 88, 44, 74, 14, 50,
47, 67, 17, 94, 71, 51, 75, 53, 75, 69, 96, 5, 73, 16, 98, 59, 13,
7, 19, 5, 93, 43, 80, 17, 44, 28, 4, 54, 68, 18, 3, 14, 51, 88,
7, 22, 4, 48, 41, 45, 17, 2, 50, 90, 18, 14, 14, 31, 88, 33, 3,
81, 77, 49, 98, 87, 44, 2, 6, 11, 87, 76, 93, 4, 63, 66, 26, 34,
14, 33, 79, 98, 35, 29, 53, 19, 43, 67, 51, 30, 66, 20, 77},
{8, 69, 75, 61, 79, 43, 33, 91, 96, 9, 49, 100, 38, 14, 25, 72, 28,
58, 51, 92, 59, 46, 44, 79, 55, 77, 96, 51, 9, 15, 28, 17, 50, 69,
45, 29, 11, 78, 86, 6, 53, 34, 73, 92, 48, 98, 29, 43, 22, 46, 34,
47, 92, 79, 25, 12, 55, 87, 64, 64, 68, 58, 48, 18, 93, 59, 13, 70,
2, 99, 76, 56, 32, 14, 13, 46, 12, 42, 89, 0, 89, 23, 13, 46, 1,
5, 59, 22, 92, 89, 53, 60, 12, 67, 44, 4, 92, 57, 74, 94},
{55, 15, 15, 53, 30, 28, 99, 8, 71, 88, 75, 59, 77, 88, 4, 44, 93,
29, 66, 51, 17, 85, 10, 96, 17, 54, 100, 8, 77, 73, 2, 31, 89, 17,
50, 85, 46, 48, 93, 83, 35, 67, 7, 11, 54, 78, 21, 13, 7, 88, 64,
91, 38, 74, 87, 56, 94, 86, 64, 70, 25, 32, 67, 80, 50, 16, 64, 62,
30, 56, 10, 32, 89, 17, 9, 8, 95, 31, 21, 68, 18, 85, 59, 22, 24,
11, 78, 84, 97, 42, 19, 88, 40, 86, 67, 90, 68, 30, 17, 99},
{52, 27, 30, 40, 44, 5, 49, 5, 36, 70, 73, 20, 21, 31, 43, 11, 42,
20, 96, 5, 28, 14, 93, 69, 67, 26, 24, 34, 56, 8, 99, 75, 35, 95,
14, 46, 0, 29, 51, 36, 66, 23, 57, 87, 21, 100, 98, 29, 86, 59, 0,
81, 74, 60, 15, 40, 86, 39, 40, 7, 47, 5, 82, 49, 100, 63, 95, 66,
92, 11, 2, 57, 0, 25, 9, 21, 91, 74, 17, 76, 32, 17, 22, 72, 43,
37, 78, 28, 77, 18, 36, 90, 90, 84, 38, 89, 46, 99, 21, 4},
{9, 90, 27, 10, 14, 3, 98, 4, 77, 14, 46, 75, 99, 35, 47, 41, 72,
24, 70, 48, 8, 72, 4, 98, 55, 42, 53, 68, 7, 74, 72, 16, 63, 99,
26, 43, 1, 24, 13, 44, 4, 25, 19, 2, 60, 32, 10, 32, 22, 80, 46,
98, 17, 50, 95, 38, 59, 13, 5, 66, 87, 77, 48, 15, 42, 41, 58, 9,
31, 71, 54, 35, 97, 39, 4, 56, 37, 14, 88, 59, 60, 0, 56, 77, 50,
17, 81, 75, 30, 87, 6, 84, 29, 55, 99, 37, 96, 57, 47, 26},
{94, 67, 27, 56, 5, 98, 12, 8, 11, 66, 67, 37, 66, 90, 80, 83, 6,
61, 23, 2, 47, 30, 86, 42, 51, 51, 80, 46, 74, 26, 38, 67, 59, 31,
23, 64, 29, 1, 38, 6, 33, 4, 44, 100, 60, 90, 48, 32, 50, 71, 1,
63, 67, 87, 5, 17, 3, 51, 29, 77, 77, 33, 10, 35, 65, 100, 65, 60,
0, 2, 32, 33, 73, 42, 99, 100, 32, 12, 31, 48, 84, 99, 11, 50, 86,
83, 34, 55, 33, 63, 32, 76, 97, 8, 77, 27, 7, 7, 53, 74},
{76, 85, 73, 14, 27, 72, 13, 59, 50, 11, 73, 33, 9, 84, 50, 61, 32,
84, 16, 31, 12, 14, 6, 8, 89, 49, 1, 96, 56, 54, 35, 31, 39, 7,
46, 32, 45, 59, 57, 96, 36, 29, 95, 46, 80, 10, 73, 11, 94, 89, 9,
73, 69, 15, 47, 57, 31, 49, 18, 87, 69, 53, 18, 74, 27, 30, 5, 38,
55, 28, 33, 92, 58, 95, 3, 37, 4, 76, 14, 65, 31, 23, 37, 66, 5,
50, 23, 36, 99, 41, 22, 68, 61, 6, 7, 88, 2, 13, 92, 58},
{41, 92, 15, 65, 86, 18, 1, 56, 60, 83, 87, 57, 5, 90, 23, 10, 40,
12, 12, 38, 19, 35, 72, 80, 7, 80, 33, 10, 59, 25, 34, 66, 16, 49,
31, 68, 33, 99, 23, 59, 47, 10, 16, 53, 100, 5, 29, 39, 17, 42, 44,
2, 43, 82, 49, 16, 27, 82, 93, 86, 73, 26, 18, 55, 75, 49, 89, 7,
13, 79, 33, 61, 55, 15, 80, 20, 20, 75, 60, 3, 83, 70, 5, 92, 17,
54, 8, 45, 2, 0, 30, 41, 27, 14, 63, 68, 29, 51, 42, 43},
{96, 75, 70, 50, 90, 49, 71, 9, 90, 97, 79, 73, 66, 50, 64, 83, 4,
72, 27, 73, 39, 24, 80, 32, 4, 42, 100, 34, 60, 41, 43, 55, 82, 12,
5, 71, 27, 42, 46, 16, 38, 24, 89, 3, 41, 19, 52, 11, 57, 46, 84,
96, 36, 29, 27, 40, 72, 94, 40, 98, 0, 83, 18, 83, 95, 90, 53, 88,
31, 66, 71, 69, 56, 59, 38, 97, 44, 57, 7, 1, 2, 57, 97, 4, 87,
91, 10, 24, 84, 51, 21, 84, 33, 39, 66, 95, 96, 86, 82, 26},
{51, 52, 96, 73, 78, 33, 70, 21, 90, 77, 89, 58, 0, 86, 28, 87, 42,
39, 10, 25, 56, 98, 75, 89, 2, 7, 49, 98, 59, 98, 24, 76, 15, 86,
48, 59, 18, 17, 81, 75, 61, 69, 99, 61, 20, 27, 13, 62, 32, 90, 53,
88, 87, 95, 42, 89, 1, 58, 53, 60, 55, 43, 1, 70, 28, 49, 29, 12,
33, 76, 53, 60, 10, 52, 87, 98, 45, 100, 25, 43, 89, 79, 97, 41, 73,
4, 96, 40, 62, 48, 66, 16, 91, 67, 53, 85, 82, 48, 98, 14},
{90, 50, 74, 66, 68, 26, 63, 12, 25, 89, 55, 80, 33, 17, 20, 72, 22,
83, 11, 84, 30, 77, 67, 88, 9, 86, 72, 91, 33, 35, 72, 89, 86, 11,
54, 53, 38, 17, 32, 29, 72, 53, 76, 71, 71, 62, 42, 93, 44, 19, 76,
41, 62, 42, 28, 71, 27, 66, 27, 26, 1, 99, 14, 87, 10, 35, 5, 14,
52, 37, 43, 90, 91, 18, 60, 27, 81, 68, 19, 24, 87, 95, 31, 48, 3,
59, 18, 97, 92, 11, 90, 93, 10, 70, 45, 20, 4, 16, 34, 22},
{54, 43, 11, 10, 62, 37, 37, 8, 4, 22, 99, 57, 83, 30, 4, 86, 55,
89, 49, 46, 0, 38, 38, 77, 74, 49, 97, 79, 66, 97, 0, 86, 5, 79,
62, 33, 15, 65, 41, 87, 87, 6, 9, 35, 2, 14, 21, 57, 69, 36, 3,
35, 40, 7, 11, 13, 23, 74, 92, 55, 36, 93, 40, 42, 37, 68, 75, 18,
32, 83, 71, 85, 89, 81, 19, 91, 61, 6, 13, 29, 8, 16, 65, 48, 91,
76, 62, 80, 16, 19, 34, 52, 78, 74, 94, 14, 7, 69, 33, 5},
{17, 3, 56, 5, 84, 41, 62, 44, 48, 75, 40, 56, 58, 71, 71, 14, 12,
99, 94, 28, 17, 27, 81, 96, 67, 74, 76, 74, 8, 75, 45, 25, 79, 0,
97, 28, 41, 58, 39, 55, 100, 45, 11, 23, 15, 48, 37, 27, 46, 97, 56,
63, 90, 36, 24, 56, 76, 0, 96, 85, 41, 40, 9, 19, 6, 6, 14, 47,
30, 19, 2, 96, 64, 80, 18, 45, 27, 21, 72, 39, 17, 94, 1, 6, 96,
93, 28, 72, 59, 90, 56, 100, 96, 31, 86, 1, 3, 66, 15, 0},
{85, 17, 96, 14, 63, 81, 59, 90, 1, 97, 28, 19, 57, 96, 92, 52, 54,
87, 23, 12, 76, 45, 79, 72, 43, 64, 39, 46, 29, 54, 12, 80, 37, 8,
60, 100, 89, 85, 55, 56, 47, 49, 75, 3, 45, 33, 56, 99, 19, 45, 78,
61, 91, 56, 99, 33, 86, 4, 45, 81, 58, 58, 60, 96, 32, 19, 61, 87,
70, 16, 42, 16, 65, 84, 20, 76, 83, 42, 41, 68, 87, 18, 28, 77, 40,
94, 76, 25, 98, 88, 5, 21, 11, 31, 16, 43, 16, 44, 29, 86},
{60, 37, 1, 24, 20, 88, 67, 69, 29, 7, 36, 16, 25, 65, 59, 65, 24,
1, 56, 21, 89, 61, 42, 100, 58, 25, 8, 74, 69, 3, 25, 95, 40, 26,
85, 27, 81, 51, 96, 9, 58, 32, 25, 49, 63, 51, 80, 87, 52, 35, 74,
40, 62, 82, 5, 19, 73, 13, 59, 7, 16, 84, 1, 56, 77, 53, 49, 57,
3, 45, 66, 28, 43, 58, 77, 72, 8, 57, 58, 60, 92, 98, 66, 20, 79,
71, 39, 52, 84, 65, 59, 100, 48, 27, 21, 91, 80, 71, 47, 83},
{82, 80, 10, 24, 37, 54, 62, 45, 10, 86, 71, 68, 83, 36, 88, 27, 6,
94, 79, 56, 58, 4, 55, 72, 98, 42, 63, 77, 12, 9, 25, 60, 89, 2,
50, 92, 56, 11, 2, 32, 97, 73, 100, 79, 75, 88, 73, 47, 47, 17, 2,
4, 21, 23, 42, 18, 66, 4, 61, 44, 81, 87, 71, 35, 89, 20, 27, 10,
32, 96, 42, 95, 69, 41, 40, 9, 95, 12, 23, 41, 29, 25, 11, 17, 15,
54, 1, 47, 24, 63, 57, 4, 49, 27, 40, 3, 48, 33, 13, 46},
{95, 55, 40, 29, 96, 46, 39, 57, 58, 62, 98, 54, 53, 76, 71, 68, 29,
72, 81, 53, 34, 38, 24, 49, 65, 30, 52, 79, 29, 31, 24, 23, 86, 31,
53, 48, 77, 92, 4, 1, 19, 68, 55, 72, 9, 92, 6, 38, 63, 87, 58,
64, 24, 82, 79, 56, 78, 98, 34, 6, 28, 25, 29, 81, 22, 82, 28, 65,
39, 99, 66, 58, 32, 87, 97, 42, 78, 2, 46, 7, 55, 3, 71, 46, 51,
49, 1, 28, 46, 1, 34, 41, 26, 30, 21, 48, 11, 49, 80, 17},
{13, 45, 75, 11, 99, 37, 53, 76, 39, 66, 83, 95, 35, 19, 40, 87, 69,
7, 81, 81, 8, 82, 21, 35, 11, 42, 49, 89, 57, 95, 5, 36, 40, 47,
14, 38, 84, 33, 80, 23, 99, 29, 84, 34, 48, 90, 87, 16, 97, 67, 64,
71, 48, 51, 72, 59, 60, 88, 48, 83, 82, 53, 86, 21, 66, 100, 25, 50,
32, 72, 39, 31, 0, 22, 65, 48, 78, 51, 31, 40, 84, 61, 10, 32, 11,
83, 57, 71, 70, 4, 20, 51, 24, 5, 39, 90, 4, 30, 5, 36},
{1, 44, 33, 68, 66, 64, 16, 9, 81, 13, 49, 65, 74, 60, 97, 51, 42,
19, 89, 11, 24, 8, 28, 14, 13, 67, 70, 84, 64, 76, 86, 65, 19, 19,
100, 52, 83, 15, 61, 64, 95, 10, 95, 34, 70, 57, 85, 78, 76, 73, 55,
66, 47, 83, 80, 60, 16, 16, 9, 80, 92, 96, 10, 77, 14, 9, 28, 63,
91, 56, 93, 85, 32, 87, 18, 68, 43, 70, 45, 19, 42, 66, 85, 56, 48,
31, 82, 30, 47, 92, 9, 4, 87, 87, 81, 67, 96, 76, 29, 87},
{31, 89, 37, 63, 75, 22, 97, 85, 92, 41, 70, 100, 73, 20, 55, 20, 51,
37, 17, 64, 28, 93, 68, 81, 79, 15, 47, 75, 91, 42, 27, 88, 30, 64,
16, 72, 52, 12, 56, 43, 19, 25, 43, 92, 45, 64, 78, 63, 0, 95, 26,
95, 54, 61, 75, 32, 76, 88, 73, 32, 30, 66, 86, 26, 97, 1, 98, 48,
80, 19, 92, 99, 10, 0, 56, 56, 64, 33, 85, 65, 95, 77, 59, 48, 3,
0, 46, 45, 88, 19, 77, 84, 51, 62, 10, 47, 29, 74, 96, 8},
{94, 53, 73, 3, 53, 28, 25, 16, 62, 76, 47, 22, 53, 73, 70, 22, 73,
15, 68, 60, 0, 10, 44, 52, 73, 54, 65, 68, 94, 60, 77, 53, 79, 15,
23, 31, 44, 48, 14, 72, 91, 27, 94, 9, 100, 29, 31, 72, 44, 99, 32,
11, 9, 76, 29, 48, 96, 94, 15, 55, 20, 58, 8, 99, 40, 31, 97, 84,
45, 77, 55, 35, 3, 14, 44, 3, 43, 42, 75, 87, 40, 73, 64, 15, 14,
93, 29, 76, 53, 11, 31, 73, 69, 39, 37, 8, 70, 100, 58, 81},
{76, 79, 16, 80, 93, 26, 49, 35, 68, 23, 89, 75, 63, 18, 56, 77, 11,
86, 53, 30, 97, 84, 2, 31, 89, 5, 6, 24, 5, 64, 4, 47, 43, 87,
26, 1, 13, 41, 3, 47, 65, 92, 88, 94, 9, 44, 70, 87, 29, 89, 16,
25, 72, 85, 56, 26, 57, 62, 50, 62, 93, 55, 8, 1, 7, 1, 2, 20,
42, 5, 34, 73, 63, 21, 66, 39, 31, 2, 25, 60, 91, 8, 51, 29, 59,
74, 55, 15, 1, 5, 77, 94, 26, 52, 95, 33, 19, 64, 20, 27},
{35, 54, 0, 99, 41, 32, 37, 73, 34, 28, 99, 92, 2, 50, 20, 62, 23,
75, 77, 24, 46, 20, 85, 72, 38, 45, 72, 57, 75, 92, 84, 10, 11, 50,
75, 18, 83, 78, 91, 83, 72, 56, 74, 75, 72, 60, 36, 95, 1, 79, 85,
47, 99, 35, 19, 36, 47, 91, 59, 21, 48, 43, 31, 59, 59, 72, 77, 7,
49, 34, 91, 21, 56, 30, 96, 27, 57, 98, 88, 58, 76, 38, 4, 41, 74,
90, 43, 20, 46, 2, 7, 94, 11, 39, 18, 70, 77, 62, 78, 26},
{62, 34, 47, 17, 30, 8, 10, 87, 72, 98, 44, 47, 1, 15, 54, 75, 4,
98, 61, 17, 100, 69, 10, 10, 74, 96, 46, 50, 23, 23, 42, 85, 23, 55,
68, 54, 29, 44, 40, 0, 41, 51, 14, 42, 66, 68, 84, 36, 31, 10, 53,
30, 45, 30, 6, 85, 25, 53, 1, 14, 42, 43, 65, 66, 65, 32, 86, 94,
42, 25, 95, 83, 42, 8, 91, 74, 42, 40, 10, 74, 51, 63, 70, 62, 59,
77, 47, 50, 96, 48, 64, 3, 57, 28, 35, 21, 26, 20, 15, 68},
{12, 9, 16, 54, 84, 74, 28, 92, 13, 4, 65, 30, 33, 1, 93, 93, 78,
5, 42, 39, 53, 73, 42, 9, 0, 78, 98, 94, 98, 12, 61, 76, 88, 44,
30, 37, 17, 24, 28, 97, 28, 60, 27, 61, 27, 86, 53, 4, 91, 62, 9,
9, 34, 17, 85, 0, 61, 82, 94, 25, 60, 21, 0, 13, 65, 30, 50, 48,
54, 45, 44, 48, 71, 37, 9, 98, 89, 62, 68, 45, 23, 43, 54, 23, 60,
5, 24, 21, 87, 17, 12, 13, 4, 12, 26, 69, 9, 43, 83, 29},
{88, 94, 78, 24, 30, 87, 21, 86, 14, 55, 30, 4, 98, 51, 27, 57, 56,
17, 44, 8, 35, 56, 21, 39, 69, 14, 75, 44, 57, 23, 73, 10, 16, 50,
34, 13, 2, 55, 99, 17, 9, 95, 21, 6, 45, 14, 29, 0, 32, 74, 9,
33, 96, 97, 38, 30, 10, 79, 74, 33, 2, 47, 43, 85, 63, 77, 98, 66,
98, 62, 83, 73, 57, 70, 45, 68, 50, 75, 69, 82, 14, 44, 81, 9, 6,
19, 40, 84, 64, 80, 16, 66, 26, 60, 51, 90, 36, 14, 55, 34},
{43, 3, 73, 100, 73, 18, 67, 89, 93, 1, 37, 6, 11, 17, 82, 85, 2,
88, 68, 67, 68, 50, 99, 60, 9, 15, 49, 12, 30, 70, 12, 73, 73, 85,
38, 11, 2, 71, 67, 95, 39, 3, 67, 16, 20, 15, 0, 90, 69, 34, 22,
36, 85, 20, 63, 94, 36, 11, 72, 32, 48, 84, 71, 87, 69, 75, 65, 37,
11, 31, 99, 50, 34, 31, 33, 20, 46, 100, 76, 15, 34, 98, 17, 18, 18,
80, 78, 20, 58, 16, 18, 72, 100, 55, 58, 34, 96, 89, 72, 6},
{86, 36, 23, 86, 67, 56, 6, 80, 21, 48, 61, 55, 46, 78, 39, 30, 24,
84, 50, 48, 100, 34, 19, 65, 89, 43, 100, 84, 32, 37, 56, 17, 73, 79,
3, 5, 0, 76, 85, 22, 23, 45, 43, 35, 23, 83, 65, 13, 32, 14, 61,
31, 14, 46, 96, 2, 89, 61, 52, 87, 64, 8, 4, 2, 53, 74, 8, 54,
15, 93, 42, 38, 4, 85, 40, 94, 67, 4, 6, 99, 86, 33, 96, 100, 79,
58, 69, 33, 85, 20, 20, 49, 95, 91, 17, 14, 64, 25, 68, 79},
{85, 76, 83, 89, 60, 22, 82, 94, 27, 54, 58, 79, 87, 54, 78, 31, 78,
12, 64, 62, 100, 84, 10, 94, 74, 28, 7, 37, 19, 41, 82, 70, 16, 31,
58, 43, 19, 5, 36, 12, 59, 94, 91, 11, 13, 69, 42, 91, 81, 6, 53,
80, 90, 29, 40, 30, 23, 13, 33, 9, 21, 15, 79, 3, 12, 37, 46, 31,
8, 48, 44, 34, 42, 34, 45, 21, 69, 54, 12, 16, 60, 65, 96, 15, 60,
1, 45, 84, 82, 45, 93, 2, 60, 71, 5, 38, 74, 18, 69, 49},
{66, 12, 83, 74, 47, 94, 96, 15, 47, 74, 31, 6, 4, 94, 89, 64, 61,
100, 13, 42, 44, 72, 44, 70, 9, 16, 7, 83, 34, 77, 98, 66, 55, 80,
40, 1, 74, 1, 84, 20, 41, 81, 94, 45, 40, 48, 8, 1, 47, 89, 43,
58, 60, 54, 27, 69, 36, 1, 18, 70, 44, 15, 1, 99, 96, 7, 0, 35,
75, 50, 21, 15, 30, 14, 60, 37, 62, 35, 38, 76, 23, 47, 33, 49, 67,
60, 18, 2, 27, 2, 38, 71, 17, 6, 70, 79, 13, 36, 80, 89},
{86, 1, 3, 82, 15, 30, 18, 44, 31, 22, 19, 54, 36, 52, 69, 69, 78,
53, 72, 5, 55, 76, 42, 73, 82, 11, 17, 62, 47, 98, 50, 99, 99, 19,
81, 80, 15, 65, 23, 46, 54, 8, 66, 56, 60, 35, 24, 4, 88, 62, 76,
43, 38, 17, 82, 86, 29, 65, 47, 42, 62, 63, 41, 26, 49, 88, 6, 64,
18, 96, 10, 72, 4, 42, 94, 64, 77, 18, 34, 31, 80, 9, 40, 84, 27,
21, 70, 22, 86, 83, 64, 14, 46, 4, 40, 61, 92, 46, 24, 10},
{42, 0, 48, 12, 9, 42, 76, 86, 26, 77, 83, 5, 86, 22, 56, 79, 43,
92, 0, 96, 40, 65, 76, 52, 35, 15, 12, 94, 28, 3, 3, 36, 3, 17,
48, 79, 25, 90, 65, 51, 66, 47, 23, 18, 36, 79, 97, 79, 36, 98, 40,
76, 28, 15, 28, 63, 98, 40, 56, 25, 43, 25, 27, 13, 9, 75, 92, 34,
30, 22, 86, 97, 36, 75, 81, 72, 19, 77, 16, 55, 40, 23, 97, 68, 4,
24, 31, 1, 31, 53, 93, 40, 79, 19, 19, 88, 60, 78, 88, 91},
{66, 39, 53, 1, 13, 33, 39, 32, 76, 22, 53, 16, 11, 16, 84, 15, 40,
81, 17, 37, 34, 76, 44, 79, 96, 63, 32, 21, 6, 86, 11, 73, 25, 30,
40, 4, 29, 46, 3, 5, 68, 56, 21, 79, 72, 71, 60, 79, 18, 77, 82,
52, 53, 25, 97, 14, 55, 95, 35, 61, 80, 13, 33, 4, 9, 74, 9, 39,
19, 12, 10, 53, 34, 98, 98, 73, 68, 57, 17, 52, 0, 99, 3, 19, 24,
66, 100, 79, 60, 34, 39, 40, 13, 39, 44, 23, 79, 19, 28, 64},
{98, 38, 16, 32, 35, 80, 71, 69, 36, 88, 21, 2, 86, 91, 21, 76, 57,
87, 20, 83, 21, 26, 22, 0, 65, 33, 90, 9, 18, 17, 73, 16, 55, 55,
14, 56, 34, 85, 92, 36, 38, 79, 5, 90, 35, 93, 66, 58, 80, 86, 41,
67, 78, 29, 67, 8, 62, 57, 17, 47, 74, 90, 63, 96, 44, 43, 17, 44,
27, 75, 47, 65, 53, 52, 54, 55, 10, 86, 12, 90, 38, 53, 56, 15, 49,
23, 24, 77, 46, 41, 23, 19, 98, 86, 81, 7, 95, 65, 18, 21},
{39, 31, 52, 59, 49, 73, 13, 59, 24, 25, 49, 62, 45, 4, 44, 60, 94,
34, 36, 39, 41, 60, 25, 4, 11, 72, 12, 6, 36, 97, 94, 76, 27, 12,
34, 76, 85, 13, 34, 75, 4, 83, 3, 49, 54, 47, 8, 47, 47, 11, 53,
88, 71, 44, 59, 48, 15, 71, 54, 52, 67, 14, 27, 94, 26, 27, 69, 77,
6, 69, 51, 10, 52, 54, 26, 72, 67, 0, 85, 80, 11, 37, 34, 48, 81,
93, 97, 97, 29, 16, 14, 96, 30, 7, 55, 56, 34, 90, 99, 6},
{58, 50, 16, 76, 70, 8, 47, 3, 9, 32, 49, 87, 69, 83, 35, 16, 75,
98, 79, 3, 13, 93, 65, 44, 100, 86, 66, 100, 75, 65, 5, 33, 81, 88,
75, 16, 97, 22, 86, 72, 54, 35, 58, 89, 17, 59, 71, 59, 56, 49, 28,
70, 41, 60, 80, 40, 45, 11, 5, 20, 42, 10, 19, 22, 99, 94, 5, 61,
82, 91, 32, 1, 25, 90, 57, 9, 49, 27, 34, 71, 43, 62, 40, 50, 21,
86, 91, 33, 98, 62, 53, 39, 73, 38, 28, 37, 98, 33, 98, 80},
{90, 29, 47, 82, 85, 3, 57, 100, 98, 91, 71, 40, 18, 77, 90, 6, 63,
46, 39, 26, 8, 58, 31, 47, 96, 59, 84, 59, 58, 47, 38, 48, 76, 52,
96, 26, 55, 52, 26, 52, 42, 63, 58, 26, 5, 48, 32, 68, 60, 37, 60,
68, 95, 92, 14, 56, 16, 64, 15, 75, 10, 19, 89, 52, 71, 84, 79, 26,
1, 71, 44, 43, 100, 2, 35, 4, 16, 68, 39, 76, 4, 99, 10, 100, 56,
91, 21, 73, 55, 36, 13, 31, 56, 1, 84, 93, 51, 28, 85, 52},
{65, 29, 61, 64, 98, 96, 68, 13, 29, 73, 55, 34, 38, 65, 100, 94, 56,
87, 32, 77, 23, 45, 7, 45, 12, 91, 37, 29, 85, 22, 47, 49, 17, 74,
12, 14, 70, 47, 94, 65, 86, 48, 99, 23, 13, 64, 84, 35, 51, 15, 11,
40, 27, 18, 51, 5, 76, 88, 1, 26, 76, 48, 76, 59, 22, 54, 73, 58,
67, 32, 22, 53, 81, 88, 76, 60, 17, 25, 95, 34, 7, 5, 40, 34, 90,
91, 5, 31, 45, 6, 58, 20, 21, 33, 80, 9, 53, 18, 67, 20},
{51, 55, 73, 31, 42, 14, 57, 26, 40, 51, 60, 13, 22, 0, 47, 78, 91,
18, 9, 1, 92, 33, 22, 79, 32, 68, 88, 85, 86, 20, 71, 2, 75, 43,
100, 84, 24, 56, 9, 30, 6, 35, 43, 95, 1, 56, 73, 59, 40, 48, 60,
31, 81, 82, 9, 12, 15, 97, 63, 1, 83, 34, 70, 58, 43, 70, 41, 67,
25, 16, 63, 99, 17, 5, 93, 19, 27, 31, 78, 68, 79, 37, 99, 59, 86,
75, 37, 0, 37, 67, 68, 20, 0, 38, 78, 43, 7, 85, 77, 99},
{67, 39, 97, 84, 11, 90, 2, 38, 20, 46, 5, 100, 50, 71, 24, 35, 45,
28, 1, 82, 95, 36, 68, 61, 40, 11, 70, 47, 62, 46, 11, 28, 52, 8,
79, 63, 98, 81, 67, 84, 94, 39, 49, 43, 9, 40, 78, 20, 68, 45, 68,
28, 81, 36, 89, 20, 47, 58, 33, 9, 71, 45, 37, 22, 53, 82, 51, 16,
29, 84, 100, 22, 22, 15, 65, 98, 55, 8, 17, 22, 19, 86, 16, 0, 21,
4, 87, 34, 28, 20, 43, 99, 31, 47, 87, 50, 28, 3, 66, 57},
{88, 31, 45, 76, 46, 9, 74, 0, 84, 91, 89, 3, 42, 4, 3, 63, 8,
56, 98, 3, 76, 6, 1, 73, 53, 55, 22, 48, 58, 54, 71, 11, 86, 16,
88, 98, 92, 61, 99, 76, 17, 53, 79, 60, 58, 48, 89, 32, 3, 52, 35,
46, 59, 3, 18, 78, 24, 7, 92, 48, 61, 63, 60, 12, 79, 47, 10, 70,
74, 75, 11, 91, 27, 90, 16, 51, 3, 5, 84, 74, 57, 85, 19, 15, 54,
3, 60, 44, 10, 51, 93, 38, 13, 52, 50, 58, 65, 60, 28, 38},
{34, 39, 95, 28, 96, 11, 79, 99, 16, 28, 38, 73, 80, 57, 55, 100, 27,
14, 44, 3, 65, 36, 41, 79, 54, 92, 2, 18, 17, 30, 56, 18, 36, 50,
46, 98, 27, 24, 62, 43, 19, 0, 83, 99, 23, 37, 98, 50, 51, 41, 20,
82, 43, 61, 26, 97, 18, 29, 14, 2, 25, 36, 20, 61, 53, 66, 24, 80,
56, 87, 90, 41, 87, 72, 39, 9, 8, 3, 26, 25, 44, 46, 73, 54, 73,
100, 50, 58, 95, 31, 60, 19, 67, 80, 47, 86, 11, 71, 32, 33},
{23, 21, 75, 9, 93, 80, 86, 67, 83, 11, 58, 94, 23, 30, 47, 96, 96,
63, 19, 56, 94, 79, 42, 27, 24, 89, 12, 1, 25, 44, 35, 49, 65, 76,
58, 23, 21, 9, 90, 4, 87, 13, 64, 9, 10, 77, 72, 72, 39, 91, 28,
33, 70, 70, 60, 60, 24, 72, 62, 49, 83, 63, 64, 47, 4, 89, 37, 25,
98, 26, 96, 85, 6, 25, 94, 16, 1, 31, 54, 41, 22, 48, 74, 58, 17,
100, 17, 7, 71, 45, 57, 19, 74, 20, 67, 78, 75, 3, 70, 73},
{96, 65, 57, 68, 57, 16, 50, 58, 14, 4, 99, 36, 52, 38, 60, 36, 37,
43, 43, 75, 89, 66, 94, 62, 53, 60, 6, 27, 29, 76, 100, 92, 6, 22,
59, 63, 5, 9, 21, 19, 13, 86, 21, 31, 24, 47, 67, 61, 90, 10, 35,
44, 42, 29, 73, 95, 55, 79, 22, 51, 54, 88, 42, 26, 10, 0, 56, 82,
9, 77, 67, 89, 28, 88, 20, 52, 34, 53, 80, 90, 29, 14, 34, 72, 9,
6, 66, 65, 85, 54, 82, 4, 42, 23, 97, 18, 23, 52, 100, 100},
{95, 66, 54, 23, 19, 40, 75, 19, 60, 20, 8, 89, 35, 42, 60, 10, 48,
93, 41, 99, 46, 22, 69, 54, 45, 66, 38, 35, 17, 37, 0, 12, 69, 54,
35, 54, 61, 76, 73, 20, 97, 48, 8, 98, 90, 35, 7, 4, 94, 15, 69,
5, 37, 38, 60, 83, 3, 98, 84, 20, 1, 84, 99, 36, 3, 100, 57, 64,
76, 96, 50, 38, 43, 25, 35, 100, 60, 8, 70, 53, 23, 38, 58, 27, 42,
84, 76, 11, 48, 59, 99, 15, 8, 97, 51, 11, 97, 7, 42, 38},
{70, 58, 76, 12, 83, 77, 11, 42, 51, 47, 61, 75, 86, 86, 68, 94, 69,
43, 5, 16, 1, 3, 31, 9, 100, 49, 87, 62, 22, 95, 100, 92, 53, 41,
71, 35, 17, 48, 44, 69, 96, 4, 9, 47, 56, 77, 40, 25, 86, 45, 7,
87, 48, 5, 62, 14, 20, 48, 76, 8, 43, 76, 67, 62, 16, 37, 97, 0,
85, 6, 35, 80, 78, 10, 26, 33, 53, 33, 24, 38, 78, 32, 24, 93, 3,
52, 6, 90, 100, 48, 98, 8, 90, 64, 70, 6, 67, 33, 73, 52},
{39, 7, 98, 16, 84, 91, 16, 36, 23, 40, 74, 67, 38, 64, 59, 41, 15,
31, 97, 81, 80, 61, 56, 35, 24, 25, 41, 92, 24, 80, 9, 30, 53, 6,
12, 36, 97, 28, 72, 86, 69, 11, 53, 6, 75, 78, 14, 56, 76, 10, 37,
55, 37, 93, 56, 62, 84, 98, 19, 75, 43, 28, 4, 97, 0, 83, 32, 98,
11, 71, 49, 80, 82, 1, 52, 23, 80, 66, 45, 55, 43, 48, 76, 80, 40,
31, 7, 91, 95, 93, 31, 38, 20, 1, 0, 88, 84, 32, 51, 95},
{2, 100, 40, 85, 1, 59, 74, 47, 91, 18, 68, 33, 67, 9, 80, 73, 6,
53, 29, 1, 46, 60, 5, 32, 61, 5, 86, 11, 3, 36, 72, 6, 36, 12,
57, 37, 71, 97, 50, 61, 14, 17, 61, 47, 93, 6, 20, 99, 25, 15, 66,
37, 76, 71, 36, 2, 42, 21, 80, 12, 58, 52, 18, 94, 30, 41, 97, 67,
3, 12, 94, 17, 96, 54, 31, 88, 26, 51, 86, 18, 66, 52, 55, 7, 89,
91, 77, 98, 79, 56, 9, 36, 74, 94, 96, 3, 34, 92, 70, 37},
{3, 64, 20, 65, 84, 51, 52, 77, 68, 37, 95, 0, 55, 15, 7, 10, 6,
50, 7, 85, 73, 16, 87, 46, 9, 82, 50, 9, 39, 86, 12, 8, 49, 32,
73, 100, 50, 24, 76, 17, 27, 70, 17, 83, 51, 92, 93, 23, 7, 66, 74,
80, 82, 60, 26, 57, 41, 42, 66, 80, 27, 78, 88, 77, 76, 26, 42, 25,
50, 17, 9, 78, 53, 26, 26, 3, 84, 85, 27, 92, 50, 0, 71, 31, 27,
63, 88, 34, 4, 19, 14, 32, 97, 68, 75, 72, 95, 16, 64, 10},
{100, 73, 88, 52, 65, 80, 21, 49, 64, 14, 6, 13, 15, 77, 10, 8, 6,
64, 42, 10, 83, 22, 8, 45, 91, 49, 84, 51, 65, 47, 27, 30, 86, 82,
82, 50, 61, 70, 65, 92, 84, 71, 71, 65, 14, 82, 73, 20, 11, 15, 97,
61, 37, 5, 72, 94, 54, 55, 10, 86, 68, 38, 15, 53, 19, 64, 70, 80,
33, 34, 37, 16, 72, 8, 82, 86, 56, 54, 5, 33, 69, 1, 94, 73, 73,
66, 66, 27, 87, 77, 79, 55, 14, 94, 74, 100, 57, 43, 45, 90},
{44, 83, 73, 15, 91, 54, 0, 46, 74, 72, 79, 9, 39, 39, 82, 12, 71,
13, 5, 57, 90, 84, 11, 70, 77, 52, 69, 0, 95, 14, 56, 38, 63, 28,
19, 53, 48, 19, 65, 89, 57, 9, 98, 97, 14, 45, 8, 85, 58, 80, 42,
14, 63, 19, 50, 5, 71, 86, 72, 66, 66, 28, 70, 28, 56, 90, 81, 71,
75, 11, 59, 32, 87, 56, 28, 1, 67, 2, 86, 91, 82, 27, 71, 10, 47,
21, 82, 17, 6, 54, 49, 38, 82, 86, 66, 3, 75, 12, 74, 15},
{23, 99, 47, 9, 20, 75, 10, 87, 43, 63, 44, 91, 90, 14, 0, 2, 35,
83, 87, 7, 2, 1, 45, 84, 87, 77, 53, 27, 89, 94, 43, 78, 92, 90,
88, 12, 31, 64, 65, 74, 93, 8, 65, 49, 23, 31, 51, 24, 80, 3, 99,
82, 5, 9, 31, 92, 87, 85, 19, 41, 78, 62, 19, 35, 17, 73, 13, 48,
2, 79, 89, 96, 53, 19, 44, 42, 50, 61, 67, 30, 65, 31, 78, 36, 40,
9, 94, 93, 60, 12, 34, 3, 40, 53, 38, 24, 92, 52, 72, 94},
{97, 60, 89, 15, 79, 99, 58, 96, 26, 91, 92, 91, 21, 69, 93, 27, 44,
86, 20, 3, 65, 54, 6, 71, 73, 11, 95, 64, 29, 67, 23, 92, 93, 79,
6, 38, 77, 30, 33, 2, 20, 91, 59, 7, 59, 51, 1, 3, 3, 21, 73,
68, 41, 46, 4, 80, 57, 100, 9, 86, 32, 32, 43, 24, 10, 49, 28, 88,
80, 27, 56, 66, 17, 82, 40, 77, 32, 41, 46, 1, 28, 85, 35, 69, 30,
40, 14, 53, 39, 23, 4, 71, 55, 47, 61, 66, 97, 56, 19, 42},
{83, 41, 74, 0, 22, 80, 77, 21, 20, 89, 22, 14, 73, 58, 83, 70, 98,
63, 22, 2, 86, 27, 39, 41, 40, 66, 73, 36, 21, 92, 44, 4, 32, 85,
4, 21, 64, 47, 42, 85, 1, 64, 65, 40, 88, 48, 9, 51, 77, 99, 53,
63, 92, 58, 3, 31, 24, 76, 34, 11, 33, 44, 15, 31, 28, 86, 52, 93,
99, 94, 43, 100, 24, 7, 40, 11, 21, 15, 63, 99, 13, 82, 61, 4, 40,
30, 2, 30, 72, 36, 41, 71, 80, 23, 1, 8, 8, 20, 67, 7}};
struct _NODE {
long iDist;
long iPrev;
};
typedef struct _NODE NODE;
struct _QITEM {
long iNode;
long iDist;
long iPrev;
struct _QITEM *qNext;
};
typedef struct _QITEM QITEM;
QITEM *qHead = NULL;
long AdjMatrix[NUM_NODES][NUM_NODES];
long g_qCount = 0;
NODE rgnNodes[NUM_NODES];
long ch;
long iPrev, iNode;
long i, iCost, iDist;
void print_path(NODE *rgnNodes, long chNode) {
if (rgnNodes[chNode].iPrev != NONE) {
print_path(rgnNodes, rgnNodes[chNode].iPrev);
}
printf(" %ld", chNode);
}
void enqueue(long iNode, long iDist, long iPrev) {
QITEM *qNew = (QITEM *)s_malloc(sizeof(QITEM));
QITEM *qLast = qHead;
if (!qNew) {
printf("Out of memory\n");
while (1)
;
}
qNew->iNode = iNode;
qNew->iDist = iDist;
qNew->iPrev = iPrev;
qNew->qNext = NULL;
if (!qLast) {
qHead = qNew;
} else {
while (qLast->qNext)
qLast = qLast->qNext;
qLast->qNext = qNew;
}
g_qCount++;
// ASSERT(g_qCount);
}
void dequeue(long *piNode, long *piDist, long *piPrev) {
QITEM *qKill = qHead;
if (qHead) {
// ASSERT(g_qCount);
*piNode = qHead->iNode;
*piDist = qHead->iDist;
*piPrev = qHead->iPrev;
qHead = qHead->qNext;
s_free(qKill);
g_qCount--;
}
}
int qcount(void) { return (g_qCount); }
void dijkstra(long chStart, long chEnd) {
for (ch = 0; ch < NUM_NODES; ch++) {
rgnNodes[ch].iDist = NONE;
rgnNodes[ch].iPrev = NONE;
}
if (chStart == chEnd) {
printf("Shortest path is 0 in cost. Just stay where you are.\n");
} else {
rgnNodes[chStart].iDist = 0;
rgnNodes[chStart].iPrev = NONE;
enqueue(chStart, 0, NONE);
while (qcount() > 0) {
dequeue(&iNode, &iDist, &iPrev);
for (i = 0; i < NUM_NODES; i++) {
if ((iCost = AdjMatrix[iNode][i]) != NONE) {
if ((NONE == rgnNodes[i].iDist) ||
(rgnNodes[i].iDist > (iCost + iDist))) {
rgnNodes[i].iDist = iDist + iCost;
rgnNodes[i].iPrev = iNode;
enqueue(i, iDist + iCost, iNode);
}
}
}
}
printf("Shortest path is %ld in cost.\n", rgnNodes[chEnd].iDist);
printf("Path is: \n");
print_path(rgnNodes, chEnd);
printf("\n");
}
}
int main(int argc, char *argv[]) {
// printf("Switched stack\n");
long i, j;
/* make a fully connected matrix */
for (i = 0; i < NUM_NODES; i++) {
for (j = 0; j < NUM_NODES; j++) {
/* make it more sparce */
// printf("Sanity Check: %d, %d \n", sanity, *rot_cnt);
AdjMatrix[i][j] = dijkstra_input_data[i][j];
}
}
/* finds 10 shortest paths between nodes */
for (i = 0, j = NUM_NODES / 2; i < 100; i++, j++) {
j = j % NUM_NODES;
// printf("Sanity Check: %d, %d \n", sanity, *rot_cnt);
dijkstra(i, j);
}
}
void print_dijkstra() {
for (int i = 0; i < 100; i++) {
printf("Data @ %d : %d\n", i, (int)dijkstra_input_data[i][0]);
}
}

86
test/src/duff.c Executable file
View File

@ -0,0 +1,86 @@
/* $Id: duff.c,v 1.2 2005/04/04 11:34:58 csg Exp $ */
/*----------------------------------------------------------------------
* WCET Benchmark created by Jakob Engblom, Uppsala university,
* February 2000.
*
* The purpose of this benchmark is to force the compiler to emit an
* unstructured loop, which is usually problematic for WCET tools to
* handle.
*
* The execution time should be constant.
*
* The original code is "Duff's Device", see the Jargon File, e.g. at
* http://www.tf.hut.fi/cgi-bin/jargon. Created in the early 1980s
* as a way to express loop unrolling in C.
*
*----------------------------------------------------------------------*/
#define ARRAYSIZE 100
#define INVOCATION_COUNT 43 /* exec time depends on this one! */
void duffcopy( char *to, char *from, int count)
{
int n=(count+7)/8;
switch(count%8){
case 0: do{ *to++ = *from++;
case 7: *to++ = *from++;
case 6: *to++ = *from++;
case 5: *to++ = *from++;
case 4: *to++ = *from++;
case 3: *to++ = *from++;
case 2: *to++ = *from++;
case 1: *to++ = *from++;
} while(--n>0);
}
}
void initialize( char *arr, int length)
{
int i;
for(i=0;i<length;i++)
{
arr[i] = length-i;
}
}
char source[ARRAYSIZE];
char target[ARRAYSIZE];
void main(void)
{
initialize( source, ARRAYSIZE );
duffcopy( source, target, INVOCATION_COUNT );
}
/*------------------------------------------------------------
* $Id: duff.c,v 1.2 2005/04/04 11:34:58 csg Exp $
*------------------------------------------------------------
* $Log: duff.c,v $
* Revision 1.2 2005/04/04 11:34:58 csg
* again
*
* Revision 1.1 2005/03/29 09:34:13 jgn
* New file.
*
* Revision 1.8 2000/10/16 07:48:15 jakob
* *** empty log message ***
*
* Revision 1.7 2000/05/22 11:02:18 jakob
* Fixed minor errors.
*
* Revision 1.6 2000/02/27 16:56:52 jakob
* *** empty log message ***
*
* Revision 1.5 2000/02/15 14:09:24 jakob
* no message
*
* Revision 1.2 2000/02/15 13:32:16 jakob
* Added duff's device to benchmark suite for LCTES 00 paper.
*
*
*------------------------------------------------------------*/

284
test/src/edn.c Executable file
View File

@ -0,0 +1,284 @@
/*
* MDH WCET BENCHMARK SUITE. File version $Id: edn.c,v 1.1 2005/11/11
* 10:14:10 ael01 Exp $
*/
/************************************************************************
* Simple vector multiply *
************************************************************************/
/*
* Changes: JG 2005/12/22: Inserted prototypes, changed type of main to int
* etc. Added parenthesis in expressions in jpegdct. Removed unused variable
* dx. Changed int to long to avoid problems when compiling to 16 bit target
* Indented program.
* JG 2006-01-27: Removed code in codebook
*/
#define N 100
#define ORDER 50
void vec_mpy1(short y[], const short x[], short scaler);
long int mac(const short *a, const short *b, long int sqr, long int *sum);
void fir(const short array1[], const short coeff[], long int output[]);
void fir_no_red_ld(const short x[], const short h[], long int y[]);
long int latsynth(short b[], const short k[], long int n, long int f);
void iir1(const short *coefs, const short *input, long int *optr, long int *state);
long int codebook(long int mask, long int bitchanged, long int numbasis, long int codeword, long int g, const short *d, short ddim, short theta);
void jpegdct(short *d, short *r);
void
vec_mpy1(short y[], const short x[], short scaler)
{
long int i;
for (i = 0; i < 150; i++)
y[i] += ((scaler * x[i]) >> 15);
}
/*****************************************************
* Dot Product *
*****************************************************/
long int
mac(const short *a, const short *b, long int sqr, long int *sum)
{
long int i;
long int dotp = *sum;
for (i = 0; i < 150; i++) {
dotp += b[i] * a[i];
sqr += b[i] * b[i];
}
*sum = dotp;
return sqr;
}
/*****************************************************
* FIR Filter *
*****************************************************/
void
fir(const short array1[], const short coeff[], long int output[])
{
long int i, j, sum;
for (i = 0; i < N - ORDER; i++) {
sum = 0;
for (j = 0; j < ORDER; j++) {
sum += array1[i + j] * coeff[j];
}
output[i] = sum >> 15;
}
}
/****************************************************
* FIR Filter with Redundant Load Elimination
By doing two outer loops simultaneously, you can potentially reuse data (depending on the DSP architecture).
x and h only need to be loaded once, therefore reducing redundant loads.
This reduces memory bandwidth and power.
*****************************************************/
void
fir_no_red_ld(const short x[], const short h[], long int y[])
{
long int i, j;
long int sum0, sum1;
short x0, x1, h0, h1;
for (j = 0; j < 100; j += 2) {
sum0 = 0;
sum1 = 0;
x0 = x[j];
for (i = 0; i < 32; i += 2) {
x1 = x[j + i + 1];
h0 = h[i];
sum0 += x0 * h0;
sum1 += x1 * h0;
x0 = x[j + i + 2];
h1 = h[i + 1];
sum0 += x1 * h1;
sum1 += x0 * h1;
}
y[j] = sum0 >> 15;
y[j + 1] = sum1 >> 15;
}
}
/*******************************************************
* Lattice Synthesis *
* This function doesn't follow the typical DSP multiply two vector operation, but it will point out the compiler's flexibility ********************************************************/
long int
latsynth(short b[], const short k[], long int n, long int f)
{
long int i;
f -= b[n - 1] * k[n - 1];
for (i = n - 2; i >= 0; i--) {
f -= b[i] * k[i];
b[i + 1] = b[i] + ((k[i] * (f >> 16)) >> 16);
}
b[0] = f >> 16;
return f;
}
/*****************************************************
* IIR Filter *
*****************************************************/
void
iir1(const short *coefs, const short *input, long int *optr, long int *state)
{
long int x;
long int t;
long int n;
x = input[0];
for (n = 0; n < 50; n++) {
t = x + ((coefs[2] * state[0] + coefs[3] * state[1]) >> 15);
x = t + ((coefs[0] * state[0] + coefs[1] * state[1]) >> 15);
state[1] = state[0];
state[0] = t;
coefs += 4; /* point to next filter coefs */
state += 2; /* point to next filter states */
}
*optr++ = x;
}
/*****************************************************
* Vocoder Codebook Search *
*****************************************************/
long int
codebook(long int mask, long int bitchanged, long int numbasis, long int codeword, long int g, const short *d, short ddim, short theta)
/*
* dfm (mask=d bitchanged=1 numbasis=17 codeword=e[0] , g=d, d=a, ddim=c,
* theta =1
*/
{
long int j;
long int tmpMask;
tmpMask = mask << 1;
for (j = bitchanged + 1; j <= numbasis; j++) {
/*
* The following code is removed since it gave a memory access exception.
* It is OK since the return value does not control the flow.
* The loop always iterates a fixed number of times independent of the loop body.
if (theta == !(!(codeword & tmpMask)))
g += *(d + bitchanged * ddim + j);
else
g -= *(d + bitchanged * ddim + j);
tmpMask <<= 1;
*/
}
return g;
}
/*****************************************************
* JPEG Discrete Cosine Transform *
*****************************************************/
void
jpegdct(short *d, short *r)
{
long int t[12];
short i, j, k, m, n, p;
for (k = 1, m = 0, n = 13, p = 8; k <= 8; k += 7, m += 3, n += 3, p -= 7, d -= 64) {
for (i = 0; i < 8; i++, d += p) {
for (j = 0; j < 4; j++) {
t[j] = d[k * j] + d[k * (7 - j)];
t[7 - j] = d[k * j] - d[k * (7 - j)];
}
t[8] = t[0] + t[3];
t[9] = t[0] - t[3];
t[10] = t[1] + t[2];
t[11] = t[1] - t[2];
d[0] = (t[8] + t[10]) >> m;
d[4 * k] = (t[8] - t[10]) >> m;
t[8] = (short) (t[11] + t[9]) * r[10];
d[2 * k] = t[8] + (short) ((t[9] * r[9]) >> n);
d[6 * k] = t[8] + (short) ((t[11] * r[11]) >> n);
t[0] = (short) (t[4] + t[7]) * r[2];
t[1] = (short) (t[5] + t[6]) * r[0];
t[2] = t[4] + t[6];
t[3] = t[5] + t[7];
t[8] = (short) (t[2] + t[3]) * r[8];
t[2] = (short) t[2] * r[1] + t[8];
t[3] = (short) t[3] * r[3] + t[8];
d[7 * k] = (short) (t[4] * r[4] + t[0] + t[2]) >> n;
d[5 * k] = (short) (t[5] * r[6] + t[1] + t[3]) >> n;
d[3 * k] = (short) (t[6] * r[5] + t[1] + t[2]) >> n;
d[1 * k] = (short) (t[7] * r[7] + t[0] + t[3]) >> n;
}
}
}
int
main(void)
{
short a[200] = {0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000,
0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00,
0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200,
0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300,
0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000,
0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00,
0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200,
0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300,
0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000,
0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00,
0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200,
0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300,
0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000,
0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00,
0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200,
0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300,
0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000,
0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00,
0x0800, 0x0200, 0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200,
0xf800, 0xf300, 0x0400, 0x0000, 0x07ff, 0x0c00, 0x0800, 0x0200, 0xf800, 0xf300, 0x0400
};
short b[200] =
{0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60,
0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20,
0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600,
0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200,
0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60,
0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20,
0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600,
0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200,
0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60,
0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20,
0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600,
0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200,
0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60,
0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20,
0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600,
0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200,
0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60,
0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20,
0x0c00, 0xf600, 0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600,
0xf400, 0xf200, 0xf000, 0x0c60, 0x0c40, 0x0c20, 0x0c00, 0xf600, 0xf400, 0xf200, 0xf000
};
short c = 0x3;
long int output[200];
long int d = 0xAAAA;
int e[1] = {0xEEEE};
/*
* Declared as memory variable so it doesn't get optimized out
*/
vec_mpy1(a, b, c);
c = mac(a, b, (long int) c, (long int *) output);
fir(a, b, output);
fir_no_red_ld(a, b, output);
d = latsynth(a, b, N, d);
iir1(a, b, &output[100], output);
e[0] = codebook(d, 1, 17, e[0], d, a, c, 1);
jpegdct(a, b);
return 0;
}

156
test/src/expint.c Executable file
View File

@ -0,0 +1,156 @@
/* $Id: expint.c,v 1.2 2005/04/04 11:34:58 csg Exp $ */
/************************************************************************
* FROM:
* http://sron9907.sron.nl/manual/numrecip/c/expint.c
*
* FEATURE:
* One loop depends on a loop-invariant value to determine
* if it run or not.
*
***********************************************************************/
long int expint(int n, long int x);
void main(void)
{
expint(50,1);
// with expint(50,21) as argument, runs the short path
// in expint. expint(50,1) gives the longest execution time
}
long int foo(long int x)
{
return x*x+(8*x)<<4-x;
}
/* Function with same flow, different data types,
nonsensical calculations */
long int expint(int n, long int x)
{
int i,ii,nm1;
long int a,b,c,d,del,fact,h,psi,ans;
nm1=n-1; /* arg=50 --> 49 */
if(x>1) /* take this leg? */
{
b=x+n;
c=2e6;
d=3e7;
h=d;
for (i=1;i<=100;i++) /* MAXIT is 100 */
{
a = -i*(nm1+i);
b += 2;
d=10*(a*d+b);
c=b+a/c;
del=c*d;
h *= del;
if (del < 10000)
{
ans=h*-x;
return ans;
}
}
}
else /* or this leg? */
{
// For the current argument, will always take
// '2' path here:
ans = nm1 != 0 ? 2 : 1000;
fact=1;
for (i=1;i<=100;i++) /* MAXIT */
{
fact *= -x/i;
if (i != nm1) /* depends on parameter n */
del = -fact/(i-nm1);
else /* this fat piece only runs ONCE */
{ /* runs on iter 49 */
psi = 0x00FF;
for (ii=1;ii<=nm1;ii++) /* */
psi += ii + nm1;
del=psi+fact*foo(x);
}
ans += del;
/* conditional leave removed */
}
}
return ans;
}
/* #define MAXIT 100 */
/* #define EULER 0.5772156649 */
/* #define FPMIN 1.0e-30 */
/* #define EPS 1.0e-7 */
/* float expint(int n, float x) */
/* { */
/* void nrerror(char error_text[]); */
/* int i,ii,nm1; */
/* float a,b,c,d,del,fact,h,psi,ans; */
/* nm1=n-1; */
/* if (n < 0 || x < 0.0 || (x==0.0 && (n==0 || n==1))) */
/* nrerror("bad arguments in expint"); */
/* else { */
/* if (n == 0) */
/* ans=exp(-x)/x; */
/* else */
/* { */
/* if (x == 0.0) */
/* ans=1.0/nm1; */
/* else */
/* { */
/* if (x > 1.0) { */
/* b=x+n; */
/* c=1.0/FPMIN; */
/* d=1.0/b; */
/* h=d; */
/* for (i=1;i<=MAXIT;i++) */
/* { */
/* a = -i*(nm1+i); */
/* b += 2.0; */
/* d=1.0/(a*d+b); */
/* c=b+a/c; */
/* del=c*d; */
/* h *= del; */
/* if (fabs(del-1.0) < EPS) */
/* { */
/* ans=h*exp(-x); */
/* return ans; */
/* } */
/* } */
/* nrerror("continued fraction failed in expint");*/
/* } */
/* else */
/* { */
/* ans = (nm1!=0 ? 1.0/nm1 : -log(x)-EULER); */
/* fact=1.0; */
/* for (i=1;i<=MAXIT;i++) { */
/* fact *= -x/i; */
/* if (i != nm1) del = -fact/(i-nm1); */
/* else { */
/* psi = -EULER; */
/* for (ii=1;ii<=nm1;ii++) psi += 1.0/ii; */
/* del=fact*(-log(x)+psi); */
/* } */
/* ans += del; */
/* if (fabs(del) < fabs(ans)*EPS) return ans; */
/* } */
/* nrerror("series failed in expint"); */
/* } */
/* } */
/* } */
/* } */
/* return ans; */
/* } */

244
test/src/fdct.c Executable file
View File

@ -0,0 +1,244 @@
/* MDH WCET BENCHMARK SUITE. */
/* 2012/09/28, Jan Gustafsson <jan.gustafsson@mdh.se>
* Changes:
* - main() declared as int.
* - Unused variables removed.
*/
// *********************************************************************************************************
// * FDCT.C *
// * *
// * Forward Discrete Cosine Transform *
// * Used on 8x8 image blocks *
// * to reassemble blocks in order to ease quantization compressing image information on the more *
// * significant frequency components *
// * *
// * Expected Result -> short int block[64]= { 699,164,-51,-16, 31,-15,-19, 8, *
// * 71, 14,-61, -2,-11,-12, 7, 12, *
// * -58,-55, 13, 28,-20, -7, 14,-18, *
// * 29, 22, 3, 3,-11, 7, 11,-22, *
// * -1,-28,-27, 10, 0, -7, 11, 6, *
// * 7, 6, 21, 21,-10, -8, 2,-14, *
// * 1, -7,-15,-15,-10, 15, 16,-10, *
// * 0, -1, 0, 15, 4,-13, -5, 4 }; *
// * *
// * Exadecimal results: Block -> 02bb00a4 ffcdfff0 001ffff1 ffed0008 0047000e ffc3fffe 000bfff4 0007000c *
// * ffc6ffc9 000d001c ffecfff9 000effee 001d0016 00030003 fff50007 000bffea *
// * ffffffe4 ffe5000a 0000fff9 000b0006 00070006 00150015 fff6fff8 0002fff2 *
// * 0001fff9 fff1fff1 fff6000f 0010fff6 0000ffff 0000000f 0004fff3 fffb0004 *
// * *
// * Number of clock cycles (with these inputs) -> 2132 *
// *********************************************************************************************************
#ifdef IO
#include "libp.c"
#include "arith.c"
#include "string.c"
#endif
// Cosine Transform Coefficients
#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */
#define W2 2676 /* 2048*sqrt(2)*cos(2*pi/16) */
#define W3 2408 /* 2048*sqrt(2)*cos(3*pi/16) */
#define W5 1609 /* 2048*sqrt(2)*cos(5*pi/16) */
#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */
#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */
// Other FDCT Parameters
#define CONST_BITS 13
#define PASS1_BITS 2
int out;
// Image block to be transformed:
short int block[64]=
{ 99 ,104 ,109 ,113 ,115 ,115 , 55 , 55,
104 ,111 ,113 ,116 ,119 , 56 , 56 , 56,
110 ,115 ,120 ,119 ,118 , 56 , 56 , 56,
119 ,121 ,122 ,120 ,120 , 59 , 59 , 59,
119 ,120 ,121 ,122 ,122 , 55 , 55 , 55,
121 ,121 ,121 ,121 , 60 , 57 , 57 , 57,
122 ,122 , 61 , 63 , 62 , 57 , 57 , 57,
62 , 62 , 61 , 61 , 63 , 58 , 58 , 58,
};
/* Fast Discrete Cosine Transform */
void fdct(short int *blk, int lx)
{
int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
int tmp10, tmp11, tmp12, tmp13;
int z1, z2, z3, z4, z5;
int i;
short int *block;
int constant;
/* Pass 1: process rows. */
/* Note results are scaled up by sqrt(8) compared to a true DCT; */
/* furthermore, we scale the results by 2**PASS1_BITS. */
block=blk;
for (i=0; i<8; i++)
{
tmp0 = block[0] + block[7];
tmp7 = block[0] - block[7];
tmp1 = block[1] + block[6];
tmp6 = block[1] - block[6];
tmp2 = block[2] + block[5];
tmp5 = block[2] - block[5];
tmp3 = block[3] + block[4];
tmp4 = block[3] - block[4];
/* Even part per LL&M figure 1 --- note that published figure is faulty;
* rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
*/
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
block[0] = ((tmp10+tmp11) << PASS1_BITS);
block[4] = ((tmp10-tmp11) << PASS1_BITS);
constant= 4433;
z1 = (tmp12 + tmp13) * constant;
constant= 6270;
block[2] = (z1 + (tmp13 * constant)) >> (CONST_BITS-PASS1_BITS);
constant= -15137;
block[6] = (z1 + (tmp12 * constant)) >> (CONST_BITS-PASS1_BITS);
/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
* cK represents cos(K*pi/16).
* i0..i3 in the paper are tmp4..tmp7 here.
*/
z1 = tmp4 + tmp7;
z2 = tmp5 + tmp6;
z3 = tmp4 + tmp6;
z4 = tmp5 + tmp7;
constant= 9633;
z5 = ((z3 + z4) * constant); /* sqrt(2) * c3 */
constant= 2446;
tmp4 = (tmp4 * constant); /* sqrt(2) * (-c1+c3+c5-c7) */
constant= 16819;
tmp5 = (tmp5 * constant); /* sqrt(2) * ( c1+c3-c5+c7) */
constant= 25172;
tmp6 = (tmp6 * constant); /* sqrt(2) * ( c1+c3+c5-c7) */
constant= 12299;
tmp7 = (tmp7 * constant); /* sqrt(2) * ( c1+c3-c5-c7) */
constant= -7373;
z1 = (z1 * constant); /* sqrt(2) * (c7-c3) */
constant= -20995;
z2 = (z2 * constant); /* sqrt(2) * (-c1-c3) */
constant= -16069;
z3 = (z3 * constant); /* sqrt(2) * (-c3-c5) */
constant= -3196;
z4 = (z4 * constant); /* sqrt(2) * (c5-c3) */
z3 += z5;
z4 += z5;
block[7] = (tmp4 + z1 + z3) >> (CONST_BITS-PASS1_BITS);
block[5] = (tmp5 + z2 + z4) >> (CONST_BITS-PASS1_BITS);
block[3] = (tmp6 + z2 + z3) >> (CONST_BITS-PASS1_BITS);
block[1] = (tmp7 + z1 + z4) >> (CONST_BITS-PASS1_BITS);
/* advance to next row */
block += lx;
}
/* Pass 2: process columns. */
block=blk;
for (i = 0; i<8; i++)
{
tmp0 = block[0] + block[7*lx];
tmp7 = block[0] - block[7*lx];
tmp1 = block[lx] + block[6*lx];
tmp6 = block[lx]- block[6*lx];
tmp2 = block[2*lx] + block[5*lx];
tmp5 = block[2*lx] - block[5*lx];
tmp3 = block[3*lx] + block[4*lx];
tmp4 = block[3*lx] - block[4*lx];
/* Even part per LL&M figure 1 --- note that published figure is faulty;
* rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
*/
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
block[0] = (tmp10 + tmp11) >> (PASS1_BITS+3);
block[4*lx] = (tmp10 - tmp11) >> (PASS1_BITS+3);
constant = 4433;
z1 = ((tmp12 + tmp13) * constant);
constant= 6270;
block[2*lx] = (z1 + (tmp13 * constant)) >> (CONST_BITS+PASS1_BITS+3);
constant=-15137;
block[6*lx] = (z1 + (tmp12 * constant)) >> (CONST_BITS+PASS1_BITS+3);
/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
* cK represents cos(K*pi/16).
* i0..i3 in the paper are tmp4..tmp7 here.
*/
z1 = tmp4 + tmp7;
z2 = tmp5 + tmp6;
z3 = tmp4 + tmp6;
z4 = tmp5 + tmp7;
constant=9633;
z5 = ((z3 + z4) * constant); /* sqrt(2) * c3 */
constant=2446;
tmp4 = (tmp4 * constant); /* sqrt(2) * (-c1+c3+c5-c7) */
constant=16819;
tmp5 = (tmp5 * constant); /* sqrt(2) * ( c1+c3-c5+c7) */
constant=25172;
tmp6 = (tmp6 * constant); /* sqrt(2) * ( c1+c3+c5-c7) */
constant=12299;
tmp7 = (tmp7 * constant); /* sqrt(2) * ( c1+c3-c5-c7) */
constant=-7373;
z1 = (z1 * constant); /* sqrt(2) * (c7-c3) */
constant= -20995;
z2 = (z2 * constant); /* sqrt(2) * (-c1-c3) */
constant=-16069;
z3 = (z3 * constant); /* sqrt(2) * (-c3-c5) */
constant=-3196;
z4 = (z4 * constant); /* sqrt(2) * (c5-c3) */
z3 += z5;
z4 += z5;
block[7*lx] = (tmp4 + z1 + z3) >> (CONST_BITS+PASS1_BITS+3);
block[5*lx] = (tmp5 + z2 + z4) >> (CONST_BITS+PASS1_BITS+3);
block[3*lx] = (tmp6 + z2 + z3) >> (CONST_BITS+PASS1_BITS+3);
block[lx] = (tmp7 + z1 + z4) >> (CONST_BITS+PASS1_BITS+3);
/* advance to next column */
block++;
}
}
int main(void)
{
/* int i; */
fdct (block, 8); // 8x8 Blocks, DC precision value = 0, Quantization coefficient (mquant) = 64
#ifdef IO
for(i=0;i<64;i+=2) printf("block[%2d] -> %8d . block[%2d] -> %8d\n",i,block[i],i+1,block[i+1]);
#endif
return block[0];
}

218
test/src/fft1.c Executable file
View File

@ -0,0 +1,218 @@
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: fft1.c */
/* SOURCE : Turbo C Programming for Engineering by Hyun Soon Ahn */
/* */
/* DESCRIPTION : */
/* */
/* FFT using Cooly-Turkey algorithm. */
/* There are two inputs, ar[] and ai[]. ar[] is real number parts */
/* of input array and the ai[] is imaginary number parts of input. */
/* The function fft1 process FFT or inverse FFT according to the .*/
/* parameter flag. (FFT with flag=0, inverse FFT with flag=1). */
/* */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
#define PI 3.14159
#define M_PI 3.14159
double ar[8];
double ai[8] = {0., };
int fft1(int n, int flag);
static double fabs(double n)
{
double f;
if (n >= 0) f = n;
else f = -n;
return f;
}
static double log(double n)
{
return(4.5);
}
static double sin(rad)
double rad;
{
double app;
double diff;
int inc = 1;
while (rad > 2*PI)
rad -= 2*PI;
while (rad < -2*PI)
rad += 2*PI;
app = diff = rad;
diff = (diff * (-(rad*rad))) /
((2.0 * inc) * (2.0 * inc + 1.0));
app = app + diff;
inc++;
while(fabs(diff) >= 0.00001) {
diff = (diff * (-(rad*rad))) /
((2.0 * inc) * (2.0 * inc + 1.0));
app = app + diff;
inc++;
}
return(app);
}
static double cos(double rad)
{
double sin();
return (sin (PI / 2.0 - rad));
}
void main()
{
int i, n = 8, flag, chkerr;
/* ar */
for(i = 0; i < n; i++)
ar[i] = cos(2*M_PI*i/n);
/* forward fft */
flag = 0;
chkerr = fft1(n, flag);
/* inverse fft */
flag = 1;
chkerr = fft1(n, flag);
}
int fft1(int n, int flag)
{
int i, j, k, it, xp, xp2, j1, j2, iter;
double sign, w, wr, wi, dr1, dr2, di1, di2, tr, ti, arg;
if(n < 2) return(999);
iter = log((double)n)/log(2.0);
j = 1;
#ifdef DEBUG
printf("iter=%d\n",iter);
#endif
for(i = 0; i < iter; i++)
j *= 2;
if(fabs(n-j) > 1.0e-6)
return(1);
/* Main FFT Loops */
sign = ((flag == 1) ? 1.0 : -1.0);
xp2 = n;
for(it = 0; it < iter; it++)
{
xp = xp2;
xp2 /= 2;
w = PI / xp2;
#ifdef DEBUG
printf("xp2=%d\n",xp2);
#endif
for(k = 0; k < xp2; k++)
{
arg = k * w;
wr = cos(arg);
wi = sign * sin(arg);
i = k - xp;
for(j = xp; j <= n; j += xp)
{
j1 = j + i;
j2 = j1 + xp2;
dr1 = ar[j1];
dr2 = ar[j2];
di1 = ai[j1];
di2 = ai[j2];
tr = dr1 - dr2;
ti = di1 - di2;
ar[j1] = dr1 + dr2;
ai[j1] = di1 + di2;
ar[j2] = tr * wr - ti * wi;
ai[j2] = ti * wr + tr * wi;
}
}
}
/* Digit Reverse Counter */
j1 = n / 2;
j2 = n - 1;
j = 1;
#ifdef DEBUG
printf("j2=%d\n",j2);
#endif
for(i = 1; i <= j2; i++)
{
if(i < j)
{
tr = ar[j-1];
ti = ai[j-1];
ar[j-1] = ar[i-1];
ai[j-1] = ai[i-1];
ar[i-1] = tr;
ai[i-1] = ti;
}
k = j1;
while(k < j)
{
j -= k;
k /= 2;
}
j += k;
}
if(flag == 0) return(0);
w = n;
for(i = 0; i < n; i++)
{
ar[i] /= w;
ai[i] /= w;
}
return(0);
}

74
test/src/fibcall.c Executable file
View File

@ -0,0 +1,74 @@
/* $Id: fibcall.c,v 1.2 2005/04/04 11:34:58 csg Exp $ */
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: fibcall.c */
/* SOURCE : Public Domain Code */
/* */
/* DESCRIPTION : */
/* */
/* Summing the Fibonacci series. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
int fib(int n)
{
int i, Fnew, Fold, temp,ans;
Fnew = 1; Fold = 0;
for ( i = 2;
i <= 30 && i <= n; /* apsim_loop 1 0 */
i++ )
{
temp = Fnew;
Fnew = Fnew + Fold;
Fold = temp;
}
ans = Fnew;
return ans;
}
int main()
{
int a;
a = 30;
fib(a);
return a;
}

299
test/src/fir.c Executable file
View File

@ -0,0 +1,299 @@
/* MDH WCET BENCHMARK SUITE. */
/* 2012/09/28, Jan Gustafsson <jan.gustafsson@mdh.se>
* Changes:
* - Adam Betts wrote: I'm currently looking at the fir benchmark and noticed something
* peculiar. The "in_data" array has 701 elements (effectively 700 as the
* last elements acts as a sentinel value) and "fir_filter_int" requires
* the length of the input/output arrays (passed in the " in_len"
* argument). So I was expecting 700 to be passed as this parameter. Indeed it was,
* but it has since been changed. The code now contains the following 2
* lines:
*
* //  fir_filter_int(in_data,output,700,fir_int,35,285); Changed JG/Ebbe
* fir_filter_int(in_data,output,10,fir_int,35,285);
*
* Can you explain why the change?
*
***
*
* Jan G wrote: Since neither Ebbe nor I can explain the change, I propose to change it back.
* =>
* Action: Fixed.
*/
/* Execute the integer fir filter from "C Algorithms for DSP".
*
* Adapted for WCET benchmarking by IJAE May 2000.
*
* Features: nested variable-length loops.
* if-statement with branches taken a known number of times
*
* Added explicit sizes of the arrays to work-around a bug in the
* NIC-compiler. Christer Sandberg
*/
/* #define LOOPS 720 */
#define LOOPS 1
/*--------------------------------------------------
*---- INPUT DATA FOR TESTING
*--------------------------------------------------*/
long fir_int[36]={
0xfffffffe, 0x1, 0x4, 0x3, 0xfffffffe, 0xfffffffc, 0x2, 0x7, 0x0,
0xfffffff7, 0xfffffffc, 0xc, 0xb, 0xfffffff2, 0xffffffe6, 0xf, 0x59, 0x7f,
0x59, 0xf, 0xffffffe6, 0xfffffff2, 0xb, 0xc, 0xfffffffc, 0xfffffff7, 0x0,
0x7, 0x2, 0xfffffffc, 0xfffffffe, 0x3, 0x4, 0x1, 0xfffffffe, 0};
long in_data[701]={
0x0, 0x0, 0x0, 0x0, 0x7f, 0x79, 0x72, 0x79, 0xd, 0xd,
0x0, 0x3, 0x5, 0x2, 0x3, 0x7f, 0x7f, 0x2, 0x7e, 0x0,
0x1, 0x7e, 0x1, 0x1, 0x7f, 0x0, 0x7f, 0x0, 0x2, 0x1,
0x1, 0x3, 0x1, 0x7f, 0x1, 0x0, 0x1, 0x1, 0x7d, 0x7b,
0x73, 0x6a, 0x77, 0x10, 0xe, 0x1, 0x5, 0x5, 0x5, 0x5,
0x7d, 0x0, 0x2, 0x7d, 0x0, 0x0, 0x7e, 0x1, 0x7e, 0x7f,
0x3, 0x7c, 0x7e, 0x6, 0x0, 0x7e, 0x3, 0x2, 0x7f, 0x7e,
0x7f, 0x2, 0x1, 0x7f, 0x1, 0x1, 0x0, 0x3, 0x0, 0x7f,
0x2, 0x0, 0x7f, 0x3, 0x1, 0x0, 0x0, 0x7d, 0x0, 0x3,
0x0, 0x7e, 0x7f, 0x2, 0x1, 0x7e, 0x0, 0x3, 0x7f, 0x7d,
0x1, 0x1, 0x1, 0x7f, 0x0, 0x5, 0x0, 0x7f, 0x2, 0x7e,
0x7f, 0x2, 0x1, 0x0, 0x7e, 0x0, 0x5, 0x0, 0x7f, 0x0,
0x7e, 0x1, 0x0, 0x7d, 0x1, 0x3, 0x7f, 0x0, 0x0, 0x7e,
0x2, 0x3, 0x7e, 0x7d, 0x72, 0x68, 0x71, 0x5, 0xc, 0x7,
0x2, 0x6, 0xd, 0x5, 0x7d, 0x3, 0x2, 0x7f, 0x0, 0x79,
0x7a, 0x3, 0x7e, 0x7d, 0x0, 0x7d, 0x2, 0x1, 0x7d, 0x8,
0x3, 0x7c, 0x6, 0x0, 0x7a, 0x6, 0x2, 0x7c, 0x3, 0x7e,
0x79, 0x6, 0x5, 0x74, 0x7f, 0xd, 0x7a, 0x78, 0x6, 0x5,
0x1, 0x0, 0x7d, 0x1, 0x4, 0x7c, 0x7f, 0x3, 0x7f, 0x5,
0x3, 0x7a, 0x6, 0xa, 0x76, 0x7c, 0xa, 0x7c, 0x7f, 0x6,
0x79, 0x3, 0xc, 0x75, 0x78, 0xa, 0x0, 0x79, 0x3, 0x7e,
0x7c, 0x6, 0x0, 0x79, 0x2, 0x7e, 0x7f, 0x6, 0x76, 0x7f,
0xd, 0x79, 0x7f, 0x6, 0x79, 0x6, 0x3, 0x71, 0x6, 0xa,
0x73, 0x7f, 0xa, 0x0, 0x7f, 0x7a, 0x7c, 0xa, 0x0, 0x75,
0x7f, 0xc, 0xa, 0x7c, 0x79, 0x9, 0xd, 0x7d, 0x7a, 0x5,
0xb, 0xa, 0x79, 0x7c, 0x16, 0x3, 0x72, 0xd, 0x7, 0x79,
0xc, 0x7, 0x7a, 0xb, 0x7, 0x7a, 0xa, 0x7, 0x79, 0xa,
0x5, 0x75, 0x6, 0x5, 0x79, 0x5, 0x6, 0x1, 0x6, 0x0,
0x7a, 0x2, 0x7, 0x3, 0x7d, 0x1, 0xa, 0x7, 0x2, 0x7f,
0x7f, 0x9, 0x7, 0x79, 0x79, 0x6, 0x8, 0x7d, 0x7a, 0x6,
0xc, 0x6, 0x7d, 0x7f, 0xd, 0x7, 0x79, 0x1, 0x6, 0x7f,
0x7f, 0x2, 0x3, 0x1, 0x7e, 0x1, 0x1, 0x7d, 0x1, 0x0,
0x7d, 0x6, 0x3, 0x7d, 0x5, 0x7, 0x7f, 0x7c, 0x1, 0x6,
0x6, 0x7c, 0x7a, 0x7, 0xa, 0x0, 0x78, 0x1, 0x8, 0x0,
0x79, 0x7a, 0x4, 0xa, 0x0, 0x78, 0x1, 0x6, 0x7a, 0x75,
0x7a, 0x0, 0x0, 0x79, 0x76, 0x7f, 0x7, 0x0, 0x7a, 0x7d,
0x2, 0x4, 0x7c, 0x7a, 0x2, 0x5, 0x7c, 0x7a, 0x7d, 0x7f,
0x0, 0x78, 0x75, 0x7f, 0x0, 0x79, 0x78, 0x79, 0x1, 0x3,
0x79, 0x79, 0x0, 0x0, 0x7f, 0x7f, 0x79, 0x7f, 0x2, 0x7a,
0x7c, 0x7d, 0x7c, 0x7f, 0x7d, 0x79, 0x7d, 0x0, 0x79, 0x7a,
0x7c, 0x7d, 0x0, 0x7d, 0x7d, 0x0, 0x0, 0x0, 0x0, 0x7d,
0x7d, 0x0, 0x7d, 0x7e, 0x0, 0x7e, 0x3, 0x3, 0x7d, 0x1,
0x5, 0x0, 0x7e, 0x7d, 0x7f, 0x3, 0x7d, 0x79, 0x1, 0x2,
0x7d, 0x7f, 0x1, 0x0, 0x0, 0x7f, 0x7f, 0x7e, 0x7f, 0x0,
0x7f, 0x0, 0x7c, 0x7d, 0x0, 0x79, 0x78, 0x7c, 0x7c, 0x7b,
0x7b, 0x7d, 0x7f, 0x0, 0x0, 0x7f, 0x0, 0x1, 0x2, 0x0,
0x7f, 0x0, 0x0, 0x0, 0x7f, 0x7e, 0x0, 0x0, 0x7f, 0x0,
0x2, 0x1, 0x2, 0x6, 0x5, 0x3, 0x6, 0x8, 0x5, 0x2,
0x1, 0x1, 0x3, 0x0, 0x7d, 0x7f, 0x0, 0x7f, 0x7e, 0x0,
0x2, 0x3, 0x2, 0x1, 0x2, 0x3, 0x1, 0x7c, 0x7d, 0x0,
0x0, 0x7e, 0x7c, 0x7f, 0x1, 0x0, 0x7e, 0x7c, 0x7f, 0x1,
0x0, 0x7e, 0x7f, 0x2, 0x3, 0x1, 0x0, 0x4, 0x6, 0x5,
0x6, 0x7, 0xa, 0xa, 0x4, 0x2, 0x5, 0x8, 0x9, 0x8,
0x7, 0xc, 0x14, 0x14, 0x10, 0xe, 0x14, 0x15, 0xf, 0x9,
0x7, 0x4, 0x7e, 0x76, 0x64, 0x41, 0x48, 0x7d, 0x6c, 0x3d,
0x67, 0x10, 0x6, 0x7d, 0x75, 0x7, 0x1d, 0x0, 0x6c, 0x2,
0x7d, 0x78, 0x77, 0x6f, 0x77, 0x1, 0x0, 0x2, 0x7, 0xa,
0x1c, 0x1c, 0x17, 0x23, 0x2f, 0x41, 0x43, 0x4f, 0x55, 0x58,
0x7e, 0x2, 0x4c, 0x10, 0x69, 0x2c, 0xd, 0x74, 0x2a, 0x74,
0x63, 0x29, 0x7c, 0x5e, 0x21, 0x35, 0x46, 0x24, 0x67, 0x35,
0x3c, 0x3c, 0x26, 0x26, 0x2f, 0x47, 0x64, 0x4, 0x13, 0x18,
0x27, 0x2b, 0x30, 0x1b, 0x7f, 0x78, 0x72, 0x68, 0x5c, 0x5a,
0x68, 0x7c, 0x3, 0xd, 0x26, 0x41, 0x51, 0x5a, 0x6a, 0x6c,
0x54, 0x78, 0x9, 0x45, 0x79, 0x1f, 0xb, 0x2e, 0x60, 0xb,
0x66, 0x7f, 0x68, 0x77, 0x4e, 0x46, 0x4a, 0x3b, 0x12, 0x5b,
0x37, 0x31, 0x21, 0xb, 0x12, 0x2e, 0x57, 0x7e, 0x19, 0x22,
0x2b, 0x3f, 0x3a, 0x25, 0xb, 0x79, 0x71, 0x68, 0x61, 0x5c,
0x66, 0x72, 0x6, 0x16, 0x29, 0x41, 0x5e, 0x6d, 0x66, 0x60,
0x6e, 0x17, 0x48, 0x36, 0x12, 0x17, 0x2f, 0x63, 0x78, 0x5c,
0x77, 0x6c, 0x75, 0x41, 0x49, 0x4f, 0x3b, 0xb, 0x54, 0x37,
0 };
long out_data[720]={
0x3, 0xfffffffa, 0xfffffffd, 0x1d, 0x58, 0x89, 0x87, 0x56, 0x20, 0x7,
0x7, 0x4, 0xfffffff9, 0x0, 0x28, 0x5b, 0x6b, 0x4f, 0x2b, 0x21,
0x2d, 0x30, 0x27, 0x27, 0x37, 0x47, 0x42, 0x27, 0x8, 0xfffffff4,
0xfffffff5, 0xd, 0x2e, 0x3b, 0x25, 0x0, 0xfffffff8, 0x1d, 0x59, 0x83,
0x87, 0x6f, 0x4e, 0x2f, 0x12, 0xffffffff, 0xfffffffb, 0x4, 0x15, 0x23,
0x2d, 0x31, 0x2f, 0x29, 0x26, 0x2a, 0x36, 0x48, 0x58, 0x5f,
0x5a, 0x4f, 0x46, 0x41, 0x32, 0x1b, 0x17, 0x37, 0x69, 0x7b,
0x59, 0x2f, 0x24, 0x30, 0x2a, 0x8, 0xfffffff6, 0x7, 0x24, 0x31,
0x2f, 0x33, 0x32, 0x1e, 0x4, 0x7, 0x23, 0x33, 0x21, 0xe,
0x1e, 0x4a, 0x61, 0x4b, 0x21, 0xe, 0x22, 0x49, 0x5e, 0x4d,
0x25, 0xb, 0x18, 0x32, 0x33, 0x15, 0x5, 0x29, 0x64, 0x76,
0x4d, 0x16, 0x9, 0x26, 0x37, 0x23, 0xb, 0x15, 0x3c, 0x52,
0x40, 0x23, 0x1d, 0x2d, 0x36, 0x2d, 0x24, 0x29, 0x32, 0x2c,
0x21, 0x2b, 0x50, 0x7b, 0x8d, 0x73, 0x47, 0x22, 0xf, 0x7,
0xffffffff, 0x0, 0x13, 0x2d, 0x36, 0x2b, 0x23, 0x32, 0x4e, 0x5c,
0x55, 0x4f, 0x55, 0x5c, 0x50, 0x34, 0x20, 0x22, 0x32, 0x38,
0x2f, 0x25, 0x2a, 0x35, 0x32, 0x23, 0x1f, 0x36, 0x57, 0x60,
0x4c, 0x31, 0x2d, 0x40, 0x57, 0x67, 0x67, 0x4c, 0x21, 0x4,
0x8, 0x20, 0x30, 0x2c, 0x33, 0x4e, 0x61, 0x56, 0x39, 0x26,
0x26, 0x2b, 0x2e, 0x38, 0x4a, 0x57, 0x58, 0x5c, 0x5f, 0x50,
0x31, 0x1d, 0x31, 0x58, 0x5d, 0x37, 0x16, 0x23, 0x55, 0x71,
0x56, 0x28, 0x18, 0x30, 0x51, 0x60, 0x5c, 0x52, 0x4f, 0x54,
0x5e, 0x62, 0x57, 0x45, 0x3a, 0x35, 0x26, 0x17, 0x23, 0x47,
0x5d, 0x48, 0x27, 0x30, 0x61, 0x79, 0x5a, 0x31, 0x2d, 0x45,
0x4f, 0x41, 0x3e, 0x48, 0x48, 0x3a, 0x3d, 0x53, 0x55, 0x2f,
0xd, 0x1f, 0x55, 0x69, 0x47, 0x1e, 0x1c, 0x32, 0x3c, 0x31,
0x28, 0x2d, 0x34, 0x32, 0x2e, 0x2e, 0x2f, 0x2d, 0x2f, 0x32,
0x2f, 0x26, 0x23, 0x30, 0x3d, 0x2c, 0x3, 0xffffffef, 0xa, 0x34,
0x39, 0x18, 0xa, 0x28, 0x42, 0x28, 0xfffffffb, 0xfffffffe, 0x37, 0x61,
0x53, 0x32, 0x35, 0x4b, 0x4c, 0x36, 0x36, 0x4e, 0x56, 0x33,
0xe, 0x1b, 0x4e, 0x69, 0x51, 0x22, 0xd, 0x24, 0x4b, 0x5e,
0x4d, 0x2a, 0x12, 0x16, 0x29, 0x35, 0x33, 0x2a, 0x25, 0x26,
0x2f, 0x38, 0x31, 0x1d, 0x1d, 0x42, 0x68, 0x58, 0x1a, 0xffffffff,
0x2a, 0x63, 0x5f, 0x27, 0xa, 0x22, 0x34, 0x1e, 0xb, 0x27,
0x58, 0x5a, 0x2e, 0x10, 0x1b, 0x28, 0x23, 0x31, 0x60, 0x7c,
0x56, 0x1b, 0x1d, 0x5d, 0x81, 0x5c, 0x29, 0x2c, 0x4e, 0x51,
0x35, 0x33, 0x4d, 0x53, 0x32, 0x24, 0x50, 0x86, 0x85, 0x5a,
0x46, 0x5d, 0x6b, 0x5b, 0x4f, 0x63, 0x71, 0x54, 0x2a, 0x2c,
0x50, 0x56, 0x30, 0x1e, 0x4d, 0x8d, 0x90, 0x5b, 0x3a, 0x55,
0x80, 0x89, 0x78, 0x7b, 0x8a, 0x7d, 0x53, 0x3e, 0x5b, 0x83,
0x7f, 0x59, 0x4a, 0x5b, 0x5e, 0x2e, 0xfffffff4, 0xfffffff3, 0x2d, 0x5f,
0x61, 0x50, 0x54, 0x5e, 0x50, 0x30, 0x26, 0x34, 0x32, 0x18,
0x9, 0x27, 0x5b, 0x74, 0x6d, 0x5e, 0x52, 0x40, 0x2d, 0x34,
0x54, 0x5c, 0x31, 0x0, 0xa, 0x56, 0x9c, 0x96, 0x59, 0x2e,
0x38, 0x57, 0x5e, 0x4b, 0x46, 0x5e, 0x78, 0x7c, 0x77, 0x80,
0x8d, 0x7d, 0x4f, 0x2b, 0x2b, 0x33, 0x1e, 0x0, 0x6, 0x28,
0x37, 0x1d, 0x9, 0x24, 0x53, 0x5d, 0x3d, 0x1f, 0x21, 0x29,
0x18, 0xfffffffc, 0xfffffff5, 0x6, 0x12, 0x9, 0xfffffffd, 0x1, 0xf, 0xc,
0xfffffffa, 0xfffffff2, 0x9, 0x32, 0x4d, 0x56, 0x5c, 0x62, 0x53, 0x27,
0x0, 0xfffffffc, 0xc, 0x8, 0xfffffff0, 0xfffffff9, 0x36, 0x6a, 0x55, 0x1c,
0x1b, 0x60, 0x8e, 0x61, 0x15, 0x14, 0x5e, 0x8c, 0x61, 0x1d,
0x1a, 0x52, 0x6b, 0x3d, 0xfffffffb, 0xffffffe8, 0x1, 0x15, 0xc, 0xfffffffe,
0x0, 0xd, 0x11, 0x9, 0x1, 0x1, 0x7, 0xc, 0xb, 0x7,
0x6, 0xd, 0x16, 0x17, 0x10, 0xc, 0x13, 0x1c, 0x13, 0x0,
0x0, 0x26, 0x5f, 0x7b, 0x68, 0x48, 0x48, 0x68, 0x7d, 0x60,
0x2d, 0x19, 0x37, 0x5c, 0x5a, 0x31, 0xf, 0x13, 0x31, 0x4c,
0x5e, 0x71, 0x83, 0x7f, 0x58, 0x20, 0xfffffffd, 0xfffffff8, 0x9, 0x18,
0x19, 0x16, 0x19, 0x27, 0x37, 0x3d, 0x42, 0x4f, 0x62, 0x65,
0x4f, 0x33, 0x2c, 0x36, 0x3d, 0x38, 0x34, 0x40, 0x54, 0x5d,
0x5b, 0x58, 0x59, 0x53, 0x41, 0x32, 0x33, 0x3f, 0x4a, 0x4b,
0x43, 0x33, 0x25, 0x28, 0x3d, 0x4f, 0x44, 0x23, 0xe, 0x16,
0x29, 0x2c, 0x28, 0x39, 0x63, 0x84, 0x7d, 0x5f, 0x56, 0x69,
0x73, 0x56, 0x24, 0xc, 0x1e, 0x40, 0x56, 0x60, 0x69, 0x6e,
0x63, 0x4e, 0x42, 0x44, 0x47, 0x3b, 0x2a, 0x22, 0x2d, 0x45,
0x5d, 0x70, 0x77, 0x6d, 0x5b, 0x4a, 0x3f, 0x37, 0x32, 0x39,
0x43, 0x3d, 0x20, 0x5, 0x10, 0x3f, 0x64, 0x5a, 0x34, 0x21,
0x2e, 0x3e, 0x33, 0x22, 0x30, 0x59, 0x75, 0x71, 0x60, 0x61,
0x67, 0x55, 0x2d, 0x12, 0x1d, 0x43, 0x65, 0x71, 0x6c, 0x5f,
0x53, 0x47, 0x39, 0x29, 0x1c, 0x1e, 0x35, 0x56, 0x6f, 0x74,
0x6f, 0x6a, 0x66, 0x5c, 0x4b, 0x3a, 0x33, 0x36, 0x38, 0x2c,
0 };
// To match size of input
#define OUTSIZE 720
/*--------------------------------------------------
*--- Prototypes
*--------------------------------------------------*/
void fir_filter_int(long* in,long* out,long in_len,
long* coef,long coef_len,
long scale);
/*--------------------------------------------------
*--- Main Function
*--------------------------------------------------*/
int main()
{
long output[OUTSIZE];
fir_filter_int(in_data,output,700,fir_int,35,285);
// fir_filter_int(in_data,output,10,fir_int,35,285);Changed JG/Ebbe
/* Verify results */
/*for(i=0;i<700;i++)*/
/* if (output[i]!=out_data[i])*/
/*{ printf("Error: index %d, data %x != %x\n",*/
/* i, output[i], out_data[i]); */
/* break; */
/* }*/
return 0;
}
/**************************************************************************
fir_filter_int - Filters int data array based on passed int coefficients.
The length of the input and output arrays are equal
and are allocated by the calller.
The length of the coefficient array is passed.
An integer scale factor (passed) is used to divide the accumulation result.
void fir_filter_int(int *in,int *out,int in_len,
int *coef,int coef_len,int scale)
in integer pointer to input array
out integer pointer to output array
in_len length of input and output arrays
coef integer pointer to coefficient array
coef_len length of coeffient array
scale scale factor to divide after accumulation
No return value.
*************************************************************************/
void fir_filter_int(long* in,long* out,long in_len,
long* coef,long coef_len,
long scale)
{
long i,j,coef_len2,acc_length;
long acc;
long *in_ptr,*data_ptr,*coef_start,*coef_ptr,*in_end;
/* set up for coefficients */
coef_start = coef;
coef_len2 = (coef_len + 1) >> 1;
/* set up input data pointers */
in_end = in + in_len - 1;
in_ptr = in + coef_len2 - 1;
/* initial value of accumulation length for startup */
acc_length = coef_len2;
for(i = 0 ; i < in_len ; i++) {
/* set up pointer for accumulation */
data_ptr = in_ptr;
coef_ptr = coef_start;
/* do accumulation and write result with scale factor */
acc = (long)(*coef_ptr++) * (*data_ptr--);
for(j = 1 ; j < acc_length ; j++)
acc += (long)(*coef_ptr++) * (*data_ptr--);
*out++ = (int)(acc/scale);
/* check for end case */
if(in_ptr == in_end) {
acc_length--; /* one shorter each time */
coef_start++; /* next coefficient each time */
}
/* if not at end, then check for startup, add to input pointer */
else {
if(acc_length < coef_len) acc_length++;
in_ptr++;
}
}
}

91
test/src/insertsort.c Executable file
View File

@ -0,0 +1,91 @@
/* $Id: insertsort.c,v 1.2 2005/04/04 11:34:58 csg Exp $ */
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: insertsort.c */
/* SOURCE : Public Domain Code */
/* */
/* DESCRIPTION : */
/* */
/* Insertion sort for 10 integer numbers. */
/* The integer array a[] is initialized in main function. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
#ifdef DEBUG
int cnt1, cnt2;
#endif
unsigned int a[11];
int main()
{
int i,j, temp;
a[0] = 0; /* assume all data is positive */
a[1] = 11; a[2]=10;a[3]=9; a[4]=8; a[5]=7; a[6]=6; a[7]=5;
a[8] =4; a[9]=3; a[10]=2;
i = 2;
while(i <= 10){
#ifdef DEBUG
cnt1++;
#endif
j = i;
#ifdef DEBUG
cnt2=0;
#endif
while (a[j] < a[j-1])
{
#ifdef DEBUG
cnt2++;
#endif
temp = a[j];
a[j] = a[j-1];
a[j-1] = temp;
j--;
}
#ifdef DEBUG
printf("Inner Loop Counts: %d\n", cnt2);
#endif
i++;
}
#ifdef DEBUG
printf("Outer Loop : %d , Inner Loop : %d\n", cnt1, cnt2);
#endif
return 1;
}

63
test/src/janne_complex.c Executable file
View File

@ -0,0 +1,63 @@
/*----------------------------------------------------------------------
* WCET Benchmark created by Andreas Ermedahl, Uppsala university,
* May 2000.
*
* The purpose of this benchmark is to have two loop where the inner
* loops max number of iterations depends on the outer loops current
* iterations. The results corresponds to something Jannes flow-analysis
* should produce.
*
* The example appeard for the first time in:
*
* @InProceedings{Ermedahl:Annotations,
* author = "A. Ermedahl and J. Gustafsson",
* title = "Deriving Annotations for Tight Calculation of Execution Time",
* year = 1997,
* month = aug,
* booktitle = EUROPAR97,
* publisher = "Springer Verlag",
* pages = "1298-1307"
* }
*
* The result of Jannes tool is something like:
* outer loop: 1 2 3 4 5 6 7 8 9 10 11
* inner loop max: 5 9 8 7 4 2 1 1 1 1 1
*
*----------------------------------------------------------------------*/
int complex(int a, int b)
{
while(a < 30)
{
while(b < a)
{
if(b > 5)
b = b * 3;
else
b = b + 2;
if(b >= 10 && b <= 12)
a = a + 10;
else
a = a + 1;
}
a = a + 2;
b = b - 10;
}
return 1;
}
int main()
{
/* a = [1..30] b = [1..30] */
int a = 1, b = 1, answer = 0;
/* if(answer)
{a = 1; b = 1;}
else
{a = 30; b = 30;} */
answer = complex(a, b);
return answer;
}

374
test/src/jfdctint.c Executable file
View File

@ -0,0 +1,374 @@
/* $Id: jfdctint.c,v 1.2 2005/04/04 11:34:58 csg Exp $ */
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: jfdctint.c */
/* SOURCE : Thomas G. Lane, Public domain JPEG source code. */
/* Modified by Steven Li at Princeton University. */
/* */
/* DESCRIPTION : */
/* */
/* JPEG slow-but-accurate integer implementation of the forward */
/* DCT (Discrete Cosine Transform). */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
/**********************************************************************
Functions to be timed
***********************************************************************/
/* This definitions are added by Steven Li so as to bypass the header
files.
*/
#define DCT_ISLOW_SUPPORTED
#define DCTSIZE 8
#define BITS_IN_JSAMPLE 8
#define MULTIPLY16C16(var,const) ((var) * (const))
#define DCTELEM int
#define INT32 int
#define GLOBAL
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
#define ONE ((INT32) 1)
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
#define SHIFT_TEMPS
/*
* jfdctint.c
*
* Copyright (C) 1991-1994, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains a slow-but-accurate integer implementation of the
* forward DCT (Discrete Cosine Transform).
*
* A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
* on each column. Direct algorithms are also available, but they are
* much more complex and seem not to be any faster when reduced to code.
*
* This implementation is based on an algorithm described in
* C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
* Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
* Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
* The primary algorithm described there uses 11 multiplies and 29 adds.
* We use their alternate method with 12 multiplies and 32 adds.
* The advantage of this method is that no data path contains more than one
* multiplication; this allows a very simple and accurate implementation in
* scaled fixed-point arithmetic, with a minimal number of shifts.
*/
#define JPEG_INTERNALS
#ifdef DCT_ISLOW_SUPPORTED
/*
* This module is specialized to the case DCTSIZE = 8.
*/
#if DCTSIZE != 8
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
#endif
/*
* The poop on this scaling stuff is as follows:
*
* Each 1-D DCT step produces outputs which are a factor of sqrt(N)
* larger than the true DCT outputs. The final outputs are therefore
* a factor of N larger than desired; since N=8 this can be cured by
* a simple right shift at the end of the algorithm. The advantage of
* this arrangement is that we save two multiplications per 1-D DCT,
* because the y0 and y4 outputs need not be divided by sqrt(N).
* In the IJG code, this factor of 8 is removed by the quantization step
* (in jcdctmgr.c), NOT in this module.
*
* We have to do addition and subtraction of the integer inputs, which
* is no problem, and multiplication by fractional constants, which is
* a problem to do in integer arithmetic. We multiply all the constants
* by CONST_SCALE and convert them to integer constants (thus retaining
* CONST_BITS bits of precision in the constants). After doing a
* multiplication we have to divide the product by CONST_SCALE, with proper
* rounding, to produce the correct output. This division can be done
* cheaply as a right shift of CONST_BITS bits. We postpone shifting
* as long as possible so that partial sums can be added together with
* full fractional precision.
*
* The outputs of the first pass are scaled up by PASS1_BITS bits so that
* they are represented to better-than-integral precision. These outputs
* require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
* with the recommended scaling. (For 12-bit sample data, the intermediate
* array is INT32 anyway.)
*
* To avoid overflow of the 32-bit intermediate results in pass 2, we must
* have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
* shows that the values given below are the most effective.
*/
#if BITS_IN_JSAMPLE == 8
#define CONST_BITS 13
#define PASS1_BITS 2
#else
#define CONST_BITS 13
#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
#endif
/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
* causing a lot of useless floating-point operations at run time.
* To get around this we use the following pre-calculated constants.
* If you change CONST_BITS you may want to add appropriate values.
* (With a reasonable C compiler, you can just rely on the FIX() macro...)
*/
#if CONST_BITS == 13
#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */
#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */
#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */
#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */
#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */
#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */
#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */
#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */
#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */
#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */
#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */
#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */
#else
#define FIX_0_298631336 FIX(0.298631336)
#define FIX_0_390180644 FIX(0.390180644)
#define FIX_0_541196100 FIX(0.541196100)
#define FIX_0_765366865 FIX(0.765366865)
#define FIX_0_899976223 FIX(0.899976223)
#define FIX_1_175875602 FIX(1.175875602)
#define FIX_1_501321110 FIX(1.501321110)
#define FIX_1_847759065 FIX(1.847759065)
#define FIX_1_961570560 FIX(1.961570560)
#define FIX_2_053119869 FIX(2.053119869)
#define FIX_2_562915447 FIX(2.562915447)
#define FIX_3_072711026 FIX(3.072711026)
#endif
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
* For 8-bit samples with the recommended scaling, all the variable
* and constant values involved are no more than 16 bits wide, so a
* 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
* For 12-bit samples, a full 32-bit multiplication will be needed.
*/
#if BITS_IN_JSAMPLE == 8
#define MULTIPLY(var,const) MULTIPLY16C16(var,const)
#else
#define MULTIPLY(var,const) ((var) * (const))
#endif
DCTELEM data[64];
/*
* Perform the forward DCT on one block of samples.
*/
GLOBAL void
jpeg_fdct_islow ()
{
INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
INT32 tmp10, tmp11, tmp12, tmp13;
INT32 z1, z2, z3, z4, z5;
DCTELEM *dataptr;
int ctr;
SHIFT_TEMPS
/* Pass 1: process rows. */
/* Note results are scaled up by sqrt(8) compared to a true DCT; */
/* furthermore, we scale the results by 2**PASS1_BITS. */
dataptr = data;
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
tmp0 = dataptr[0] + dataptr[7];
tmp7 = dataptr[0] - dataptr[7];
tmp1 = dataptr[1] + dataptr[6];
tmp6 = dataptr[1] - dataptr[6];
tmp2 = dataptr[2] + dataptr[5];
tmp5 = dataptr[2] - dataptr[5];
tmp3 = dataptr[3] + dataptr[4];
tmp4 = dataptr[3] - dataptr[4];
/* Even part per LL&M figure 1 --- note that published figure is faulty;
* rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
*/
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS);
dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
CONST_BITS-PASS1_BITS);
dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
CONST_BITS-PASS1_BITS);
/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
* cK represents cos(K*pi/16).
* i0..i3 in the paper are tmp4..tmp7 here.
*/
z1 = tmp4 + tmp7;
z2 = tmp5 + tmp6;
z3 = tmp4 + tmp6;
z4 = tmp5 + tmp7;
z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
z3 += z5;
z4 += z5;
dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);
dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);
dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);
dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);
dataptr += DCTSIZE; /* advance pointer to next row */
}
/* Pass 2: process columns.
* We remove the PASS1_BITS scaling, but leave the results scaled up
* by an overall factor of 8.
*/
dataptr = data;
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
/* Even part per LL&M figure 1 --- note that published figure is faulty;
* rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
*/
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
CONST_BITS+PASS1_BITS);
dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
CONST_BITS+PASS1_BITS);
/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
* cK represents cos(K*pi/16).
* i0..i3 in the paper are tmp4..tmp7 here.
*/
z1 = tmp4 + tmp7;
z2 = tmp5 + tmp6;
z3 = tmp4 + tmp6;
z4 = tmp5 + tmp7;
z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
z3 += z5;
z4 += z5;
dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3,
CONST_BITS+PASS1_BITS);
dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4,
CONST_BITS+PASS1_BITS);
dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3,
CONST_BITS+PASS1_BITS);
dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4,
CONST_BITS+PASS1_BITS);
dataptr++; /* advance pointer to next column */
}
}
#endif /* DCT_ISLOW_SUPPORTED */
/* Main function
Time to function execution time using logic analyzer,
which measures the OFF time of a LED on board.
The switching latency, including the function call/return time,
is measured to be equal to 1.1us (22 clock cycles).
*/
void main(void)
{
int i, seed;
/* Worst case settings */
/* Set array to random values */
seed = 1;
for (i = 0; i < 64; i++) {
seed = ((seed * 133) + 81) % 65535;
data[i] = seed;
}
jpeg_fdct_islow();
}

71
test/src/lcdnum.c Executable file
View File

@ -0,0 +1,71 @@
/* MDH WCET BENCHMARK SUITE. */
/* 2012/09/28, Jan Gustafsson <jan.gustafsson@mdh.se>
* Changes:
* - The volatile variable n controls a loop, which is not correct. The loop will not terminate. Fixed.
*/
/***********************************************************************
* FILE: synthetic.c
*
* PURPOSE: demonstrate effect of flow facts for straight loops
*
* IDEA: reading from an in port mapped to a ten-item buffer,
* send first five characters to an LCD as numbers
*
***********************************************************************/
unsigned char num_to_lcd(unsigned char a)
{
/* -0- 1 01
* 1 2 2 4 02 04
* -3- i.e. 8 i.e. 08
* 4 5 16 32 10 20
* -6- 64 40
*
*/
switch(a)
{
case 0x00: return 0;
case 0x01: return 0x24;
case 0x02: return 1+4+8+16+64;
case 0x03: return 1+4+8+32+64;
case 0x04: return 2+4+8+32;
case 0x05: return 1+4+8+16+64;
case 0x06: return 1+2+8+16+32+64;
case 0x07: return 1+4+32;
case 0x08: return 0x7F; /* light all */
case 0x09: return 0x0F + 32 + 64;
case 0x0A: return 0x0F + 16 + 32;
case 0x0B: return 2+8+16+32+64;
case 0x0C: return 1+2+16+64;
case 0x0D: return 4+8+16+32+64;
case 0x0E: return 1+2+8+16+64;
case 0x0F: return 1+2+8+16;
}
return 0;
}
volatile unsigned char IN;
volatile unsigned char OUT;
int main(void)
{
int i;
unsigned char a;
/*volatile*/ int n; /* JG */
n = 10;
for(i=0; i< n; i++)
{
a = IN; /* scan port */
if(i<5)
{
a = a &0x0F;
OUT = num_to_lcd(a);
}
}
return 0;
}

271
test/src/lms.c Executable file
View File

@ -0,0 +1,271 @@
/* MDH WCET BENCHMARK SUITE. */
/* 2012/09/28, Jan Gustafsson <jan.gustafsson@mdh.se>
* Changes:
* - This program redefines the C standard functions log, fabs, sqrt, and sin. Therefore, these function has been renamed with prefix lms_.
* - Warning: explicitly assigning a variable of type 'float' to itself
* x =x;
* removed.
* - Unused variables removed.
*/
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: lms.c */
/* SOURCE : C Algorithms for Real-Time DSP by P. M. Embree */
/* */
/* DESCRIPTION : */
/* */
/* An LMS adaptive signal enhancement. The input signal is a sine */
/* wave with added white noise. */
/* The detailed description is in the program source code. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
#define RAND_MAX 32768
#define PI 3.14159265358979323846
/* function prototypes for fft and filter functions */
static float gaussian(void);
#define N 201
#define L 20 /* filter order, (length L+1) */
/* set convergence parameter */
float mu = 0.01;
int lms_rand()
{
static unsigned long next = 1;
next = next * 1103515245 + 12345;
return (unsigned int)(next/65536) % 32768;
}
static float lms_log(r)
float r;
{
return 4.5;
}
static float lms_fabs(float n)
{
float f;
if (n >= 0) f = n;
else f = -n;
return f;
}
static float lms_sqrt(val)
float val;
{
float x = val/10;
float dx;
double diff;
double min_tol = 0.00001;
int i, flag;
flag = 0;
if (val == 0 ) x = 0;
else {
for (i=1;i<20;i++)
{
if (!flag) {
dx = (val - (x*x)) / (2.0 * x);
x = x + dx;
diff = val - (x*x);
if (lms_fabs(diff) <= min_tol) flag = 1;
}
else { } /* JG */
/* x =x; */
}
}
return (x);
}
static float lms_sin(rad)
float rad;
{
float app;
float diff;
int inc = 1;
while (rad > 2*PI)
rad -= 2*PI;
while (rad < -2*PI)
rad += 2*PI;
app = diff = rad;
diff = (diff * (-(rad*rad))) /
((2.0 * inc) * (2.0 * inc + 1.0));
app = app + diff;
inc++;
while(lms_fabs(diff) >= 0.00001) {
diff = (diff * (-(rad*rad))) /
((2.0 * inc) * (2.0 * inc + 1.0));
app = app + diff;
inc++;
}
return(app);
}
static float gaussian()
{
static int ready = 0; /* flag to indicated stored value */
static float gstore; /* place to store other value */
static float rconst1 = (float)(2.0/RAND_MAX);
static float rconst2 = (float)(RAND_MAX/2.0);
float v1,v2,r,fac;
float gaus;
/* make two numbers if none stored */
if(ready == 0) {
v1 = (float)lms_rand() - rconst2;
v2 = (float)lms_rand() - rconst2;
v1 *= rconst1;
v2 *= rconst1;
r = v1*v1 + v2*v2;
while (r > 1.0f) {
v1 = (float)lms_rand() - rconst2;
v2 = (float)lms_rand() - rconst2;
v1 *= rconst1;
v2 *= rconst1;
r = v1*v1 + v2*v2;
} /* make radius less than 1 */
/* remap v1 and v2 to two Gaussian numbers */
fac = lms_sqrt(-2.0f*lms_log(r)/r);
gstore = v1*fac; /* store one */
gaus = v2*fac; /* return one */
ready = 1; /* set ready flag */
}
else {
ready = 0; /* reset ready flag for next pair */
gaus = gstore; /* return the stored one */
}
return(gaus);
}
int main()
{
float lms(float,float,float *,int,float,float);
static float d[N],b[21];
float signal_amp,noise_amp,arg,x/*,y*/; /* JG */
int k;
/* create signal plus noise */
signal_amp = lms_sqrt(2.0);
noise_amp = 0.2*lms_sqrt(12.0);
arg = 2.0*PI/20.0;
for(k = 0 ; k < N ; k++) {
d[k] = signal_amp*lms_sin(arg*k) + noise_amp*gaussian();
}
/* scale based on L */
mu = 2.0*mu/(L+1);
x = 0.0;
for(k = 0 ; k < N ; k++) {
lms(x,d[k],b,L,mu,0.01);
/* delay x one sample */
x = d[k];
}
return 0;
}
/*
function lms(x,d,b,l,mu,alpha)
Implements NLMS Algorithm b(k+1)=b(k)+2*mu*e*x(k)/((l+1)*sig)
x = input data
d = desired signal
b[0:l] = Adaptive coefficients of lth order fir filter
l = order of filter (> 1)
mu = Convergence parameter (0.0 to 1.0)
alpha = Forgetting factor sig(k)=alpha*(x(k)**2)+(1-alpha)*sig(k-1)
(>= 0.0 and < 1.0)
returns the filter output
*/
float lms(float x,float d,float *b,int l,
float mu,float alpha)
{
int ll;
float e,mu_e,/*lms_const,*/y; /* JG */
static float px[51]; /* max L = 50 */
static float sigma = 2.0; /* start at 2 and update internally */
px[0]=x;
/* calculate filter output */
y=b[0]*px[0];
#ifdef DEBUG
printf("l=%d\n",l);
#endif
for(ll = 1 ; ll <= l ; ll++)
y=y+b[ll]*px[ll];
/* error signal */
e=d-y;
/* update sigma */
sigma=alpha*(px[0]*px[0])+(1-alpha)*sigma;
mu_e=mu*e/sigma;
/* update coefficients */
for(ll = 0 ; ll <= l ; ll++)
b[ll]=b[ll]+mu_e*px[ll];
/* update history */
for(ll = l ; ll >= 1 ; ll--)
px[ll]=px[ll-1];
return(y);
}

149
test/src/ludcmp.c Executable file
View File

@ -0,0 +1,149 @@
/* MDH WCET BENCHMARK SUITE. File version $Id: ludcmp.c,v 1.2 2006/01/27 13:15:28 jgn Exp $ */
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: ludcmp.c */
/* SOURCE : Turbo C Programming for Engineering */
/* */
/* DESCRIPTION : */
/* */
/* Simultaneous linear equations by LU decomposition. */
/* The arrays a[][] and b[] are input and the array x[] is output */
/* row vector. */
/* The variable n is the number of equations. */
/* The input arrays are initialized in function main. */
/* */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
/* Changes:
* JG 2005/12/12: Indented program. Removed unused variable nmax.
*/
/*
** Benchmark Suite for Real-Time Applications, by Sung-Soo Lim
**
** III-4. ludcmp.c : Simultaneous Linear Equations by LU Decomposition
** (from the book C Programming for EEs by Hyun Soon Ahn)
*/
double a[50][50], b[50], x[50];
int ludcmp( /* int nmax, */ int n, double eps);
static double
fabs(double n)
{
double f;
if (n >= 0)
f = n;
else
f = -n;
return f;
}
int
main(void)
{
int i, j/*, nmax = 50*/, n = 5, chkerr;
double eps, w;
eps = 1.0e-6;
for (i = 0; i <= n; i++) {
w = 0.0;
for (j = 0; j <= n; j++) {
a[i][j] = (i + 1) + (j + 1);
if (i == j)
a[i][j] *= 10.0;
w += a[i][j];
}
b[i] = w;
}
chkerr = ludcmp( /* nmax, */ n, eps);
return 0;
}
int
ludcmp( /* int nmax, */ int n, double eps)
{
int i, j, k;
double w, y[100];
if (n > 99 || eps <= 0.0)
return (999);
for (i = 0; i < n; i++) {
if (fabs(a[i][i]) <= eps)
return (1);
for (j = i + 1; j <= n; j++) {
w = a[j][i];
if (i != 0)
for (k = 0; k < i; k++)
w -= a[j][k] * a[k][i];
a[j][i] = w / a[i][i];
}
for (j = i + 1; j <= n; j++) {
w = a[i + 1][j];
for (k = 0; k <= i; k++)
w -= a[i + 1][k] * a[k][j];
a[i + 1][j] = w;
}
}
y[0] = b[0];
for (i = 1; i <= n; i++) {
w = b[i];
for (j = 0; j < i; j++)
w -= a[i][j] * y[j];
y[i] = w;
}
x[n] = y[n] / a[n][n];
for (i = n - 1; i >= 0; i--) {
w = y[i];
for (j = i + 1; j <= n; j++)
w -= a[i][j] * x[j];
x[i] = w / a[i][i];
}
return (0);
}

162
test/src/matmult.c Executable file
View File

@ -0,0 +1,162 @@
/* $Id: matmult.c,v 1.2 2005/04/04 11:34:58 csg Exp $ */
/* matmult.c */
/* was mm.c! */
/*----------------------------------------------------------------------*
* To make this program compile under our assumed embedded environment,
* we had to make several changes:
* - Declare all functions in ANSI style, not K&R.
* this includes adding return types in all cases!
* - Declare function prototypes
* - Disable all output
* - Disable all UNIX-style includes
*
* This is a program that was developed from mm.c to matmult.c by
* Thomas Lundqvist at Chalmers.
*----------------------------------------------------------------------*/
#define UPPSALAWCET 1
/* ***UPPSALA WCET***:
disable stupid UNIX includes */
#ifndef UPPSALAWCET
#include <sys/types.h>
#include <sys/times.h>
#endif
/*
* MATRIX MULTIPLICATION BENCHMARK PROGRAM:
* This program multiplies 2 square matrices resulting in a 3rd
* matrix. It tests a compiler's speed in handling multidimensional
* arrays and simple arithmetic.
*/
#define UPPERLIMIT 20
typedef int matrix [UPPERLIMIT][UPPERLIMIT];
int Seed;
matrix ArrayA, ArrayB, ResultArray;
#ifdef UPPSALAWCET
/* Our picky compiler wants prototypes! */
void Multiply(matrix A, matrix B, matrix Res);
void InitSeed(void);
void Test(matrix A, matrix B, matrix Res);
void Initialize(matrix Array);
int RandomInteger(void);
#endif
void main()
{
InitSeed();
/* ***UPPSALA WCET***:
no printing please! */
#ifndef UPPSALAWCET
printf("\n *** MATRIX MULTIPLICATION BENCHMARK TEST ***\n\n");
printf("RESULTS OF THE TEST:\n");
#endif
Test(ArrayA, ArrayB, ResultArray);
}
void InitSeed(void)
/*
* Initializes the seed used in the random number generator.
*/
{
/* ***UPPSALA WCET***:
changed Thomas Ls code to something simpler.
Seed = KNOWN_VALUE - 1; */
Seed = 0;
}
void Test(matrix A, matrix B, matrix Res)
/*
* Runs a multiplication test on an array. Calculates and prints the
* time it takes to multiply the matrices.
*/
{
#ifndef UPPSALAWCET
long StartTime, StopTime;
float TotalTime;
#endif
Initialize(A);
Initialize(B);
/* ***UPPSALA WCET***: don't print or time */
#ifndef UPPSALAWCET
StartTime = ttime ();
#endif
Multiply(A, B, Res);
/* ***UPPSALA WCET***: don't print or time */
#ifndef UPPSALAWCET
StopTime = ttime();
TotalTime = (StopTime - StartTime) / 1000.0;
printf(" - Size of array is %d\n", UPPERLIMIT);
printf(" - Total multiplication time is %3.3f seconds\n\n", TotalTime);
#endif
}
void Initialize(matrix Array)
/*
* Intializes the given array with random integers.
*/
{
int OuterIndex, InnerIndex;
for (OuterIndex = 0; OuterIndex < UPPERLIMIT; OuterIndex++)
for (InnerIndex = 0; InnerIndex < UPPERLIMIT; InnerIndex++)
Array[OuterIndex][InnerIndex] = RandomInteger();
}
int RandomInteger(void)
/*
* Generates random integers between 0 and 8095
*/
{
Seed = ((Seed * 133) + 81) % 8095;
return (Seed);
}
#ifndef UPPSALAWCET
int ttime()
/*
* This function returns in milliseconds the amount of compiler time
* used prior to it being called.
*/
{
struct tms buffer;
int utime;
/* times(&buffer); times not implemented */
utime = (buffer.tms_utime / 60.0) * 1000.0;
return (utime);
}
#endif
void Multiply(matrix A, matrix B, matrix Res)
/*
* Multiplies arrays A and B and stores the result in ResultArray.
*/
{
register int Outer, Inner, Index;
for (Outer = 0; Outer < UPPERLIMIT; Outer++)
for (Inner = 0; Inner < UPPERLIMIT; Inner++)
{
Res [Outer][Inner] = 0;
for (Index = 0; Index < UPPERLIMIT; Index++)
Res[Outer][Inner] +=
A[Outer][Index] * B[Index][Inner];
}
}

213
test/src/minver.c Executable file
View File

@ -0,0 +1,213 @@
/* MDH WCET BENCHMARK SUITE */
/* 2012/09/28, Jan Gustafsson <jan.gustafsson@mdh.se>
* Changes:
* - Missing braces around initialization of subobject added
* - This program redefines the standard C function fabs. Therefore, the
* function has been renamed to minver_fabs.
*/
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: minver.c */
/* SOURCE : Turbo C Programming for Engineering by Hyun Soo Ahn */
/* */
/* DESCRIPTION : */
/* */
/* Matrix inversion for 3x3 floating point matrix. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
int minver(int row, int col, double eps);
int mmul(int row_a, int col_a, int row_b, int col_b);
static double a[3][3] = {
{3.0, -6.0, 7.0},
{9.0, 0.0, -5.0},
{5.0, -8.0, 6.0},
};
double b[3][3], c[3][3], aa[3][3], a_i[3][3], e[3][3], det;
double minver_fabs(double n)
{
double f;
if (n >= 0) f = n;
else f = -n;
return f;
}
int main()
{
int i, j;
double eps;
eps = 1.0e-6;
for(i = 0; i < 3; i++)
for(j = 0; j < 3; j++)
aa[i][j] = a[i][j];
minver(3, 3, eps);
for(i = 0; i < 3; i++)
for(j = 0; j < 3; j++)
a_i[i][j] = a[i][j];
mmul(3, 3, 3, 3);
return 0;
}
int mmul(int row_a, int col_a, int row_b, int col_b)
{
int i, j, k, row_c, col_c;
double w;
row_c = row_a;
col_c = col_b;
if(row_c < 1 || row_b < 1 || col_c < 1 || col_a != row_b) return(999);
for(i = 0; i < row_c; i++)
{
for(j = 0; j < col_c; j++)
{
w = 0.0;
for(k = 0; k < row_b; k++)
w += a[i][k] * b[k][j];
c[i][j] = w;
}
}
return(0);
}
int minver(int row, int col, double eps)
{
int work[500], i, j, k, r, iw, s, t, u, v;
double w, wmax, pivot, api, w1;
if(row < 2 || row > 500 || eps <= 0.0) return(999);
w1 = 1.0;
for(i = 0; i < row; i++)
work[i] = i;
for(k = 0; k < row; k++)
{
wmax = 0.0;
for(i = k; i < row; i++)
{
w = minver_fabs(a[i][k]);
if(w > wmax)
{
wmax = w;
r = i;
}
}
pivot = a[r][k];
api = minver_fabs(pivot);
if(api <= eps)
{
det = w1;
return(1);
}
w1 *= pivot;
u = k * col;
v = r * col;
if(r != k)
{
w1 = -w;
iw = work[k];
work[k] = work[r];
work[r] = iw;
for(j = 0; j < row; j++)
{
s = u + j;
t = v + j;
w = a[k][j];
a[k][j] = a[r][j];
a[r][j] = w;
}
}
for(i = 0; i < row; i++)
a[k][i] /= pivot;
for(i = 0; i < row; i++)
{
if(i != k)
{
v = i * col;
s = v + k;
w = a[i][k];
if(w != 0.0)
{
for(j = 0; j < row; j++)
if(j != k) a[i][j] -= w * a[k][j];
a[i][k] = -w / pivot;
}
}
}
a[k][k] = 1.0 / pivot;
}
for(i = 0; i < row; i++)
{
while(1)
{
k = work[i];
if(k == i) break;
iw = work[k];
work[k] = work[i];
work[i] = iw;
for(j = 0; j < row; j++)
{
u = j * col;
s = u + i;
t = u + k;
w = a[k][i];
a[k][i] = a[k][k];
a[k][k] = w;
}
}
}
det = w1;
return(0);
}

238
test/src/ndes.c Executable file
View File

@ -0,0 +1,238 @@
/* MDH WCET BENCHMARK SUITE. */
/* 2012/10/03, Jan Gustafsson <jan.gustafsson@mdh.se>
* Changes:
* - init of "is" fixed (added a lot of brackets)
* - warning: array subscript is of type 'char': fixed in three places
*/
/* #include <math.h> -- no include files in Uppsala tests, plz */
/* All output disabled for wcsim */
/* A read from this address will result in an known value of 1 */
/* #define KNOWN_VALUE (int)(*((char *)0x80200001)) Changed JG/Ebbe */
#define KNOWN_VALUE 1
/* A read from this address will result in an unknown value */
#define UNKNOWN_VALUE (int)(*((char *)0x80200003))
#define WORSTCASE 1
typedef struct IMMENSE { unsigned long l, r; } immense;
typedef struct GREAT { unsigned long l, c, r; } great;
unsigned long bit[33];
static immense icd;
static char ipc1[57]={0,57,49,41,33,25,17,9,1,58,50,
42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,
52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,
30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4};
static char ipc2[49]={0,14,17,11,24,1,5,3,28,15,6,21,
10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,
37,47,55,30,40,51,45,33,48,44,49,39,56,34,
53,46,42,50,36,29,32};
void des(immense inp, immense key, int * newkey, int isw, immense * out);
unsigned long getbit(immense source, int bitno, int nbits);
void ks(/*immense key, */int n, great * kn);
void cyfun(unsigned long ir, great k, unsigned long * iout);
void des(immense inp, immense key, int * newkey, int isw, immense * out) {
static char ip[65] =
{0,58,50,42,34,26,18,10,2,60,52,44,36,
28,20,12,4,62,54,46,38,30,22,14,6,64,56,48,40,
32,24,16,8,57,49,41,33,25,17,9,1,59,51,43,35,
27,19,11,3,61,53,45,37,29,21,13,5,63,55,47,39,
31,23,15,7};
static char ipm[65]=
{0,40,8,48,16,56,24,64,32,39,7,47,15,
55,23,63,31,38,6,46,14,54,22,62,30,37,5,45,13,
53,21,61,29,36,4,44,12,52,20,60,28,35,3,43,11,
51,19,59,27,34,2,42,10,50,18,58,26,33,1,41,9,
49,17,57,25};
static great kns[17];
#ifdef WORSTCASE
static int initflag=1;
#else
static int initflag=0;
#endif
int ii,i,j,k;
unsigned long ic,shifter,getbit();
immense itmp;
great pg;
if (initflag) {
initflag=0;
bit[1]=shifter=1L;
for(j=2;j<=32;j++) bit[j] = (shifter <<= 1);
}
if (*newkey) {
*newkey=0;
icd.r=icd.l=0L;
for (j=28,k=56;j>=1;j--,k--) {
icd.r = (icd.r <<= 1) | getbit(key,ipc1[j],32);
icd.l = (icd.l <<= 1) | getbit(key,ipc1[k],32);
}
for(i=1;i<=16;i++) {pg = kns[i]; ks(/* key,*/ i, &pg); kns[i] = pg;}
}
itmp.r=itmp.l=0L;
for (j=32,k=64;j>=1;j--,k--) {
itmp.r = (itmp.r <<= 1) | getbit(inp,ip[j],32);
itmp.l = (itmp.l <<= 1) | getbit(inp,ip[k],32);
}
for (i=1;i<=16;i++) {
ii = (isw == 1 ? 17-i : i);
cyfun(itmp.l, kns[ii], &ic);
ic ^= itmp.r;
itmp.r=itmp.l;
itmp.l=ic;
}
ic=itmp.r;
itmp.r=itmp.l;
itmp.l=ic;
(*out).r=(*out).l=0L;
for (j=32,k=64; j >= 1; j--, k--) {
(*out).r = ((*out).r <<= 1) | getbit(itmp,ipm[j],32);
(*out).l = ((*out).l <<= 1) | getbit(itmp,ipm[k],32);
}
}
unsigned long getbit(immense source, int bitno, int nbits) {
if (bitno <= nbits)
return bit[bitno] & source.r ? 1L : 0L;
else
return bit[bitno-nbits] & source.l ? 1L : 0L;
}
void ks(/*immense key, */int n, great * kn) {
int i,j,k,l;
if (n == 1 || n == 2 || n == 9 || n == 16) {
icd.r = (icd.r | ((icd.r & 1L) << 28)) >> 1;
icd.l = (icd.l | ((icd.l & 1L) << 28)) >> 1;
}
else
for (i=1;i<=2;i++) {
icd.r = (icd.r | ((icd.r & 1L) << 28)) >> 1;
icd.l = (icd.l | ((icd.l & 1L) << 28)) >> 1;
}
(*kn).r=(*kn).c=(*kn).l=0;
for (j=16,k=32,l=48; j>=1; j--,k--,l--) {
(*kn).r=((*kn).r <<= 1) | (unsigned short)
getbit(icd,ipc2[j],28);
(*kn).c=((*kn).c <<= 1) | (unsigned short)
getbit(icd,ipc2[k],28);
(*kn).l=((*kn).l <<= 1) | (unsigned short)
getbit(icd,ipc2[l],28);
}
}
void cyfun(unsigned long ir, great k, unsigned long * iout) {
static int iet[49]={0,32,1,2,3,4,5,4,5,6,7,8,9,8,9,
10,11,12,13,12,13,14,15,16,17,16,17,18,19,
20,21,20,21,22,23,24,25,24,25,26,27,28,29,
28,29,30,31,32,1};
static int ipp[33]={0,16,7,20,21,29,12,28,17,1,15,
23,26,5,18,31,10,2,8,24,14,32,27,3,9,19,13,
30,6,22,11,4,25};
static char is[16][4][9]={
{{0,14,15,10,7,2,12,4,13},{0,0,3,13,13,14,10,13,1},
{0,4,0,13,10,4,9,1,7},{0,15,13,1,3,11,4,6, 2}},
{{0,4,1,0,13,12,1,11,2},{0,15,13,7,8,11,15,0,15},
{0,1,14,6,6,2,14,4,11},{0,12,8,10,15,8,3,11,1}},
{{0,13,8,9,14,4,10,2,8},{0,7,4,0,11,2,4,11,13},
{0,14,7,4,9,1,15,11,4},{0,8,10,13,0,12,2,13,14}},
{{0,1,14,14,3,1,15,14,4},{0,4,7,9,5,12,2,7,8},
{0,8,11,9,0,11,5,13,1},{0,2,1,0,6,7,12,8,7}},
{{0,2,6,6,0,7,9,15,6},{0,14,15,3,6,4,7,4,10},
{0,13,10,8,12,10,2,12,9},{0,4,3,6,10,1,9,1,4}},
{{0,15,11,3,6,10,2,0,15},{0,2,2,4,15,7,12,9,3},
{0,6,4,15,11,13,8,3,12},{0,9,15,9,1,14,5,4,10}},
{{0,11,3,15,9,11,6,8,11},{0,13,8,6,0,13,9,1,7},
{0,2,13,3,7,7,12,7,14},{0,1,4,8,13,2,15,10,8}},
{{0,8,4,5,10,6,8,13,1},{0,1,14,10,3,1,5,10,4},
{0,11,1,0,13,8,3,14,2},{0,7,2,7,8,13,10,7,13}},
{{0,3,9,1,1,8,0,3,10},{0,10,12,2,4,5,6,14,12},
{0,15,5,11,15,15,7,10,0},{0,5,11,4,9,6,11,9,15}},
{{0,10,7,13,2,5,13,12,9},{0,6,0,8,7,0,1,3,5},
{0,12,8,1,1,9,0,15,6},{0,11,6,15,4,15,14,5,12}},
{{0,6,2,12,8,3,3,9,3},{0,12,1,5,2,15,13,5,6},
{0,9,12,2,3,12,4,6,10},{0,3,7,14,5,0,1,0,9}},
{{0,12,13,7,5,15,4,7,14},{0,11,10,14,12,10,14,12,11},
{0,7,6,12,14,5,10,8,13},{0,14,12,3,11,9,7,15,0}},
{{0,5,12,11,11,13,14,5,5},{0,9,6,12,1,3,0,2,0},
{0,3,9,5,5,6,1,0,15},{0,10,0,11,12,10,6,14,3}},
{{0,9,0,4,12,0,7,10,0},{0,5,9,11,10,9,11,15,14},
{0,10,3,10,2,3,13,5,3},{0,0,5,5,7,4,0,2,5}},
{{0,0,5,2,4,14,5,6,12},{0,3,11,15,14,8,3,8,9},
{0,5,2,14,8,0,11,9,5},{0,6,14,2,2,5,8,3,6}},
{{0,7,10,8,15,9,11,1,7},{0,8,5,1,9,6,8,6,2},
{0,0,15,7,4,14,6,2,8},{0,13,9,12,14,3,13,12,11}}};
static char ibin[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
great ie;
unsigned long itmp,ietmp1,ietmp2;
char iec[9];
int jj,irow,icol,iss,j,l,m;
unsigned long *p;
p = bit;
ie.r=ie.c=ie.l=0;
for (j=16,l=32,m=48;j>=1;j--,l--,m--) {
ie.r = (ie.r <<=1) | (p[iet[j]] & ir ? 1 : 0);
ie.c = (ie.c <<=1) | (p[iet[l]] & ir ? 1 : 0);
ie.l = (ie.l <<=1) | (p[iet[m]] & ir ? 1 : 0);
}
ie.r ^= k.r;
ie.c ^= k.c;
ie.l ^= k.l;
ietmp1=((unsigned long) ie.c << 16)+(unsigned long) ie.r;
ietmp2=((unsigned long) ie.l << 8)+((unsigned long) ie.c >> 8);
for (j=1,m=5;j<=4;j++,m++) {
iec[j]=ietmp1 & 0x3fL;
iec[m]=ietmp2 & 0x3fL;
ietmp1 >>= 6;
ietmp2 >>= 6;
}
itmp=0L;
for (jj=8;jj>=1;jj--) {
j =iec[jj];
irow=((j & 0x1) << 1)+((j & 0x20) >> 5);
icol=((j & 0x2) << 2)+(j & 0x4)
+((j & 0x8) >> 2)+((j & 0x10) >> 4);
iss=is[icol][irow][jj];
itmp = (itmp <<= 4) | ibin[iss];
}
*iout=0L;
p = bit;
for (j=32;j>=1;j--)
*iout = (*iout <<= 1) | (p[ipp[j]] & itmp ? 1 : 0);
}
#ifdef WORSTCASE
int value = 1;
#else
int value = 0;
#endif
int main(void)
{
immense inp, key, out;
int newkey, isw;
inp.l = KNOWN_VALUE * 35;
inp.r = KNOWN_VALUE * 26;
key.l = KNOWN_VALUE * 2;
key.r = KNOWN_VALUE * 16;
newkey = value;
isw = value;
des(inp, key, &newkey, isw, &out);
/* printf("%u %u\n", out.l, out.r);*/
return 0;
}

531
test/src/ns.c Executable file
View File

@ -0,0 +1,531 @@
/* $Id: ns.c,v 1.2 2005/04/04 11:34:58 csg Exp $ */
/* Test of deeply nested loops and non-local exits */
/*-------------------------------------------------- *
* LOG:
* $Log: ns.c,v $
* Revision 1.2 2005/04/04 11:34:58 csg
* again
*
* Revision 1.1 2005/03/29 11:28:43 jgn
* New file.
*
* Revision 1.8 2001/05/07 10:05:37 ijae
* no message
*
* Revision 1.7 2001/04/25 12:48:15 ijae
* Corrected trace names.
*
* Revision 1.6 2001/04/25 12:17:47 ijae
* no message
*
* Revision 1.5 2001/04/25 12:11:31 ijae
* Compilable for V850
*
* Revision 1.4 2001/04/25 12:09:55 ijae
* Now in target mode.
*
* Revision 1.3 2001/04/25 12:06:36 ijae
* Now 4D array. Compiles & runs on PC
*
* Revision 1.2 2001/04/25 11:59:38 ijae
* A bit more comments.
*
*-------------------------------------------------- */
/* -------------------------------------------------- *
* Define TEST to check the # iterations in inner loop,
* and that the right value is found and returned
* -------------------------------------------------- */
//#define TEST
/* --------------------------------------------------
* Array of keys and values, 4-dimensional just
* for the fun of it.
* -------------------------------------------------- */
int keys[5][5][5][5] =
{
// [0]
{
// [0][0]
{
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
// [0][1]
{
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
// [0][2]
{
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
// [0][3]
{
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
// [0][4]
{
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
}
},
// [1]
{
// [1][0]
{
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1}
},
// [1][1]
{
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1}
},
// [1][2]
{
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1}
},
// [1][3]
{
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1}
},
// [1][4]
{
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1}
}
},
// [2]
{
// [2][0]
{
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2}
},
// [2][1]
{
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2}
},
// [2][2]
{
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2}
},
// [2][3]
{
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2}
},
// [2][4]
{
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2},
{2,2,2,2,2}
}
},
// [3]
{
// [3][0]
{
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3}
},
// [3][1]
{
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3}
},
// [3][2]
{
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3}
},
// [3][3]
{
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3}
},
// [3][4]
{
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3},
{3,3,3,3,3}
}
},
// [4]
{
// [4][0]
{
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4}
},
// [4][1]
{
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4}
},
// [4][2]
{
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4}
},
// [4][3]
{
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4}
},
// [4][4]
{
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,4},
{4,4,4,4,
#ifdef FIND_TARGET
400
#else
401 /* not searched for */
#endif
}
}
}
};
int answer[5][5][5][5] =
{
// [0]
{
// [0][0]
{
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123}
},
// [0][1]
{
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123}
},
// [0][2]
{
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123}
},
// [0][3]
{
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123}
},
// [0][4]
{
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123},
{123,123,123,123,123}
}
},
// [1]
{
// [1][0]
{
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234}
},
// [1][1]
{
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234}
},
// [1][2]
{
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234}
},
// [1][3]
{
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234}
},
// [1][4]
{
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234},
{234,234,234,234,234}
}
},
// [2]
{
// [2][0]
{
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345}
},
// [2][1]
{
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345}
},
// [2][2]
{
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345}
},
// [2][3]
{
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345}
},
// [2][4]
{
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345},
{345,345,345,345}
}
},
// [3]
{
// [3][0]
{
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456}
},
// [3][1]
{
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456}
},
// [3][2]
{
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456}
},
// [3][3]
{
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456}
},
// [3][4]
{
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456},
{456,456,456,456,456}
}
},
// [4]
{
// [4][0]
{
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567}
},
// [4][1]
{
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567}
},
// [4][2]
{
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567}
},
// [4][3]
{
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567}
},
// [4][4]
{
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,567},
{567,567,567,567,1111}
}
}
};
int foo(int x)
{
#ifdef TEST
int c = 0; /* counter for innerloop */
#endif
int i,j,k,l;
for(i=0; i<5; i++)
for(j=0 ; j<5 ; j++)
for(k=0 ; k<5 ; k++)
for(l=0 ; l<5 ; l++)
{
#ifdef TEST
c++;
#endif
if( keys[i][j][k][l] == x )
{
#ifdef TEST
printf(" %d\n",c);
#endif
return answer[i][j][k][l] + keys[i][j][k][l];
}
}
return -1;
}
void main(void)
{
#ifdef TEST
printf("result=%d\n",foo(400));
#else
foo(400);
#endif
}

4253
test/src/nsichneu.c Executable file

File diff suppressed because it is too large Load Diff

46
test/src/prime.c Executable file
View File

@ -0,0 +1,46 @@
/* MDH WCET BENCHMARK SUITE. */
/* Changes:
* JG 2005/12/08: Prototypes added, and changed exit to return in main.
*/
typedef unsigned char bool;
typedef unsigned int uint;
bool divides (uint n, uint m);
bool even (uint n);
bool prime (uint n);
void swap (uint* a, uint* b);
bool divides (uint n, uint m) {
return (m % n == 0);
}
bool even (uint n) {
return (divides (2, n));
}
bool prime (uint n) {
uint i;
if (even (n))
return (n == 2);
for (i = 3; i * i <= n; i += 2) {
if (divides (i, n)) /* ai: loop here min 0 max 357 end; */
return 0;
}
return (n > 1);
}
void swap (uint* a, uint* b) {
uint tmp = *a;
*a = *b;
*b = tmp;
}
int main () {
uint x = 21649;
uint y = 513239;
swap (&x, &y);
return (!(prime(x) && prime(y)));
}

119
test/src/qsort-exam.c Executable file
View File

@ -0,0 +1,119 @@
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: qsort-exam.c */
/* SOURCE : Numerical Recipes in C - The Second Edition */
/* */
/* DESCRIPTION : */
/* */
/* Non-recursive version of quick sort algorithm. */
/* This example sorts 20 floating point numbers, arr[]. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
#define SWAP(a,b) temp=(a);(a)=(b);(b)=temp;
#define M 7
#define NSTACK 50
float arr[20] = {
5, 4, 10.3, 1.1, 5.7, 100, 231, 111, 49.5, 99,
10, 150, 222.22, 101, 77, 44, 35, 20.54, 99.99, 88.88
};
int istack[100];
void sort(unsigned long n)
{
unsigned long i,ir=n,j,k,l=1;
int jstack=0;
int flag;
float a,temp;
flag = 0;
for (;;) {
if (ir-l < M) {
for (j=l+1;j<=ir;j++) {
a=arr[j];
for (i=j-1;i>=l;i--) {
if (arr[i] <= a) break;
arr[i+1]=arr[i];
}
arr[i+1]=a;
}
if (jstack == 0) break;
ir=istack[jstack--];
l=istack[jstack--];
} else {
k=(l+ir) >> 1;
SWAP(arr[k],arr[l+1])
if (arr[l] > arr[ir]) {
SWAP(arr[l],arr[ir])
}
if (arr[l+1] > arr[ir]) {
SWAP(arr[l+1],arr[ir])
}
if (arr[l] > arr[l+1]) {
SWAP(arr[l],arr[l+1])
}
i=l+1;
j=ir;
a=arr[l+1];
for (;;) {
i++; while (arr[i] < a) i++;
j--; while (arr[j] > a) j--;
if (j < i) break;
SWAP(arr[i],arr[j]);
}
arr[l+1]=arr[j];
arr[j]=a;
jstack += 2;
if (ir-i+1 >= j-l) {
istack[jstack]=ir;
istack[jstack-1]=i;
ir=j-1;
} else {
istack[jstack]=j-1;
istack[jstack-1]=l;
l=i;
}
}
}
}
main()
{
sort(20);
}

173
test/src/qurt.c Executable file
View File

@ -0,0 +1,173 @@
/* MDH WCET BENCHMARK SUITE. */
/* 2012/09/28, Jan Gustafsson <jan.gustafsson@mdh.se>
* Changes:
* - This program redefines the C standard function fabs and sqrt. Therefore, these functions has been renamed with prefix qurt_.
* - qurt.c:95:6: warning: explicitly assigning a variable of type 'double' to itself: fixed
* - qurt.c:105:6: warning: unused variable 'flag' [-Wunused-variable]: fixed
*/
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: qurt.c */
/* SOURCE : Turbo C Programming for Engineering by Hyun Soo Ahn */
/* */
/* DESCRIPTION : */
/* */
/* Root computation of quadratic equations. */
/* The real and imaginary parts of the solution are stored in the */
/* array x1[] and x2[]. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
/*
** Benchmark Suite for Real-Time Applications, by Sung-Soo Lim
**
** III-7. qurt.c : the root computation of a quadratic equation
** (from the book C Programming for EEs by Hyun Soon Ahn)
*/
double a[3], x1[2], x2[2];
int flag;
int qurt();
double qurt_fabs(double n)
{
double f;
if (n >= 0) f = n;
else f = -n;
return f;
}
double qurt_sqrt(val)
double val;
{
double x = val/10;
double dx;
double diff;
double min_tol = 0.00001;
int i, flag;
flag = 0;
if (val == 0 ) x = 0;
else {
for (i=1;i<20;i++)
{
if (!flag) {
dx = (val - (x*x)) / (2.0 * x);
x = x + dx;
diff = val - (x*x);
if (qurt_fabs(diff) <= min_tol) flag = 1;
}
else {} /* JG */
/* x =x; */
}
}
return (x);
}
int main()
{
/* int flag; */ /* JG */
a[0] = 1.0;
a[1] = -3.0;
a[2] = 2.0;
qurt();
a[0] = 1.0;
a[1] = -2.0;
a[2] = 1.0;
qurt();
a[0] = 1.0;
a[1] = -4.0;
a[2] = 8.0;
qurt();
return 0;
}
int qurt()
{
double d, w1, w2;
if(a[0] == 0.0) return(999);
d = a[1]*a[1] - 4 * a[0] * a[2];
w1 = 2.0 * a[0];
w2 = qurt_sqrt(qurt_fabs(d));
if(d > 0.0)
{
flag = 1;
x1[0] = (-a[1] + w2) / w1;
x1[1] = 0.0;
x2[0] = (-a[1] - w2) / w1;
x2[1] = 0.0;
return(0);
}
else if(d == 0.0)
{
flag = 0;
x1[0] = -a[1] / w1;
x1[1] = 0.0;
x2[0] = x1[0];
x2[1] = 0.0;
return(0);
}
else
{
flag = -1;
w2 /= w1;
x1[0] = -a[1] / w1;
x1[1] = w2;
x2[0] = x1[0];
x2[1] = -w2;
return(0);
}
}

40
test/src/recursion.c Executable file
View File

@ -0,0 +1,40 @@
/* $Id: recursion.c,v 1.2 2005/04/04 11:34:58 csg Exp $ */
/* Generate an example of recursive code, to see *
* how it can be modeled in the scope graph. */
/* self-recursion */
int fib(int i)
{
if(i==0)
return 1;
if(i==1)
return 1;
return fib(i-1) + fib(i-2);
}
/* mutual recursion */
int anka(int);
int kalle(int i)
{
if(i<=0)
return 0;
else
return anka(i-1);
}
int anka(int i)
{
if(i<=0)
return 1;
else
return kalle(i-1);
}
extern volatile int In;
void main(void)
{
In = fib(10);
}

112
test/src/select.c Executable file
View File

@ -0,0 +1,112 @@
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: select.c */
/* SOURCE : Numerical Recipes in C - The Second Edition */
/* */
/* DESCRIPTION : */
/* */
/* A function to select the Nth largest number in the floating poi- */
/* nt array arr[]. */
/* The parameters to function select are k and n. Then the function */
/* selects k-th largest number out of n original numbers. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
#define SWAP(a,b) temp=(a);(a)=(b);(b)=temp;
float arr[20] = {
5, 4, 10.3, 1.1, 5.7, 100, 231, 111, 49.5, 99,
10, 150, 222.22, 101, 77, 44, 35, 20.54, 99.99, 888.88
};
float select(unsigned long k, unsigned long n)
{
unsigned long i,ir,j,l,mid;
float a,temp;
int flag, flag2;
l=1;
ir=n;
flag = flag2 = 0;
while (!flag) {
if (ir <= l+1) {
if (ir == l+1)
if (arr[ir] < arr[l]) {
SWAP(arr[l],arr[ir])
}
flag = 1;
} else if (!flag) {
mid=(l+ir) >> 1;
SWAP(arr[mid],arr[l+1])
if (arr[l+1] > arr[ir]) {
SWAP(arr[l+1],arr[ir])
}
if (arr[l] > arr[ir]) {
SWAP(arr[l],arr[ir])
}
if (arr[l+1]> arr[l]) {
SWAP(arr[l+1],arr[l])
}
i=l+1;
j=ir;
a=arr[l];
while (!flag2) {
i++;
while (arr[i] < a) i++;
j--;
while (arr[j] > a) j--;
if (j < i) flag2 = 1;
if (!flag2) SWAP(arr[i],arr[j]);
}
arr[l]=arr[j];
arr[j]=a;
if (j >= k) ir=j-1;
if (j <= k) l=i;
}
}
return arr[k];
}
main()
{
select(10, 20);
}

90
test/src/sqrt.c Executable file
View File

@ -0,0 +1,90 @@
/* MDH WCET BENCHMARK SUITE. */
/* 2012/09/28, Jan Gustafsson <jan.gustafsson@mdh.se>
* Changes:
* - This program redefines the C standard function sqrt. Therefore, this function has been renamed to sqrtfcn.
* - qrt.c:79:15: warning: explicitly assigning a variable of type 'float' to itself: fixed
*/
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: sqrt.c */
/* SOURCE : Public Domain Code */
/* */
/* DESCRIPTION : */
/* */
/* Square root function implemented by Taylor series. */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
float fabs(float x)
{
if (x < 0)
return -x;
else
return x;
}
float sqrtfcn(float val)
{
float x = val/10;
float dx;
double diff;
double min_tol = 0.00001;
int i, flag;
flag = 0;
if (val == 0 )
x = 0;
else {
for (i=1;i<20;i++)
{
if (!flag) {
dx = (val - (x*x)) / (2.0 * x);
x = x + dx;
diff = val - (x*x);
if (fabs(diff) <= min_tol)
flag = 1;
}
else {} /* JG */
/* x =x; */
}
}
return (x);
}

1273
test/src/statemate.c Executable file

File diff suppressed because it is too large Load Diff

161
test/src/ud.c Executable file
View File

@ -0,0 +1,161 @@
/* MDH WCET BENCHMARK SUITE. File version $Id: ud.c,v 1.4 2005/11/11 10:32:53 ael01 Exp $ */
/*************************************************************************/
/* */
/* SNU-RT Benchmark Suite for Worst Case Timing Analysis */
/* ===================================================== */
/* Collected and Modified by S.-S. Lim */
/* sslim@archi.snu.ac.kr */
/* Real-Time Research Group */
/* Seoul National University */
/* */
/* */
/* < Features > - restrictions for our experimental environment */
/* */
/* 1. Completely structured. */
/* - There are no unconditional jumps. */
/* - There are no exit from loop bodies. */
/* (There are no 'break' or 'return' in loop bodies) */
/* 2. No 'switch' statements. */
/* 3. No 'do..while' statements. */
/* 4. Expressions are restricted. */
/* - There are no multiple expressions joined by 'or', */
/* 'and' operations. */
/* 5. No library calls. */
/* - All the functions needed are implemented in the */
/* source file. */
/* */
/* */
/*************************************************************************/
/* */
/* FILE: ludcmp.c */
/* SOURCE : Turbo C Programming for Engineering */
/* */
/* DESCRIPTION : */
/* */
/* Simultaneous linear equations by LU decomposition. */
/* The arrays a[][] and b[] are input and the array x[] is output */
/* row vector. */
/* The variable n is the number of equations. */
/* The input arrays are initialized in function main. */
/* */
/* */
/* REMARK : */
/* */
/* EXECUTION TIME : */
/* */
/* */
/*************************************************************************/
/*************************************************************************
* This file:
*
* - Name changed to "ud.c"
* - Modified for use with Uppsala/Paderborn tool
* : doubles changed to int
* : some tests removed
* - Program is much more linear, all loops will run to end
* - Purpose: test the effect of conditional flows
*
*************************************************************************/
/*
** Benchmark Suite for Real-Time Applications, by Sung-Soo Lim
**
** III-4. ludcmp.c : Simultaneous Linear Equations by LU Decomposition
** (from the book C Programming for EEs by Hyun Soon Ahn)
*/
long int a[50][50], b[50], x[50];
int ludcmp(int nmax, int n);
/* static double fabs(double n) */
/* { */
/* double f; */
/* if (n >= 0) f = n; */
/* else f = -n; */
/* return f; */
/* } */
void main()
{
int i, j, nmax = 50, n = 5, chkerr;
long int /* eps, */ w;
/* eps = 1.0e-6; */
/* Init loop */
for(i = 0; i <= n; i++)
{
w = 0.0; /* data to fill in cells */
for(j = 0; j <= n; j++)
{
a[i][j] = (i + 1) + (j + 1);
if(i == j) /* only once per loop pass */
a[i][j] *= 2.0;
w += a[i][j];
}
b[i] = w;
}
/* chkerr = ludcmp(nmax, n, eps); */
chkerr = ludcmp(nmax,n);
}
int ludcmp(int nmax, int n)
{
int i, j, k;
long w, y[100];
/* if(n > 99 || eps <= 0.0) return(999); */
for(i = 0; i < n; i++)
{
/* if(fabs(a[i][i]) <= eps) return(1); */
for(j = i+1; j <= n; j++) /* triangular loop vs. i */
{
w = a[j][i];
if(i != 0) /* sub-loop is conditional, done
all iterations except first of the
OUTER loop */
for(k = 0; k < i; k++)
w -= a[j][k] * a[k][i];
a[j][i] = w / a[i][i];
}
for(j = i+1; j <= n; j++) /* triangular loop vs. i */
{
w = a[i+1][j];
for(k = 0; k <= i; k++) /* triangular loop vs. i */
w -= a[i+1][k] * a[k][j];
a[i+1][j] = w;
}
}
y[0] = b[0];
for(i = 1; i <= n; i++) /* iterates n times */
{
w = b[i];
for(j = 0; j < i; j++) /* triangular sub loop */
w -= a[i][j] * y[j];
y[i] = w;
}
x[n] = y[n] / a[n][n];
for(i = n-1; i >= 0; i--) /* iterates n times */
{
w = y[i];
for(j = i+1; j <= n; j++) /* triangular sub loop */
w -= a[i][j] * x[j];
x[i] = w / a[i][i] ;
}
return(0);
}

230
test/src/whet.c Executable file
View File

@ -0,0 +1,230 @@
/*
* Whetstone benchmark in C. This program is a translation of the
* original Algol version in "A Synthetic Benchmark" by H.J. Curnow
* and B.A. Wichman in Computer Journal, Vol 19 #1, February 1976.
*
* Used to test compiler optimization and floating point performance.
*
* Compile by: cc -O -s -o whet whet.c
* or: cc -O -DPOUT -s -o whet whet.c
* if output is desired.
*/
#define ITERATIONS 10 /* 1 Million Whetstone instructions */
#include "math.h"
double x1, x2, x3, x4, x, y, z, t, t1, t2;
double e1[4];
int i, j, k, l, n1, n2, n3, n4, n6, n7, n8, n9, n10, n11;
main()
{
/* initialize constants */
t = 0.499975;
t1 = 0.50025;
t2 = 2.0;
/* set values of module weights */
n1 = 0 * ITERATIONS;
n2 = 12 * ITERATIONS;
n3 = 14 * ITERATIONS;
n4 = 345 * ITERATIONS;
n6 = 210 * ITERATIONS;
n7 = 32 * ITERATIONS;
n8 = 899 * ITERATIONS;
n9 = 616 * ITERATIONS;
n10 = 0 * ITERATIONS;
n11 = 93 * ITERATIONS;
/* MODULE 1: simple identifiers */
x1 = 1.0;
x2 = x3 = x4 = -1.0;
for(i = 1; i <= n1; i += 1) {
x1 = ( x1 + x2 + x3 - x4 ) * t;
x2 = ( x1 + x2 - x3 - x4 ) * t;
x3 = ( x1 - x2 + x3 + x4 ) * t;
x4 = (-x1 + x2 + x3 + x4 ) * t;
}
#ifdef POUT
pout(n1, n1, n1, x1, x2, x3, x4);
#endif
/* MODULE 2: array elements */
e1[0] = 1.0;
e1[1] = e1[2] = e1[3] = -1.0;
for (i = 1; i <= n2; i +=1) {
e1[0] = ( e1[0] + e1[1] + e1[2] - e1[3] ) * t;
e1[1] = ( e1[0] + e1[1] - e1[2] + e1[3] ) * t;
e1[2] = ( e1[0] - e1[1] + e1[2] + e1[3] ) * t;
e1[3] = (-e1[0] + e1[1] + e1[2] + e1[3] ) * t;
}
#ifdef POUT
pout(n2, n3, n2, e1[0], e1[1], e1[2], e1[3]);
#endif
/* MODULE 3: array as parameter */
for (i = 1; i <= n3; i += 1)
pa(e1);
#ifdef POUT
pout(n3, n2, n2, e1[0], e1[1], e1[2], e1[3]);
#endif
/* MODULE 4: conditional jumps */
j = 1;
for (i = 1; i <= n4; i += 1) {
if (j == 1)
j = 2;
else
j = 3;
if (j > 2)
j = 0;
else
j = 1;
if (j < 1 )
j = 1;
else
j = 0;
}
#ifdef POUT
pout(n4, j, j, x1, x2, x3, x4);
#endif
/* MODULE 5: omitted */
/* MODULE 6: integer arithmetic */
j = 1;
k = 2;
l = 3;
for (i = 1; i <= n6; i += 1) {
j = j * (k - j) * (l -k);
k = l * k - (l - j) * k;
l = (l - k) * (k + j);
e1[l - 2] = j + k + l; /* C arrays are zero based */
e1[k - 2] = j * k * l;
}
#ifdef POUT
pout(n6, j, k, e1[0], e1[1], e1[2], e1[3]);
#endif
/* MODULE 7: trig. functions */
x = y = 0.5;
for(i = 1; i <= n7; i +=1) {
x = t * atan(t2*sin(x)*cos(x)/(cos(x+y)+cos(x-y)-1.0));
y = t * atan(t2*sin(y)*cos(y)/(cos(x+y)+cos(x-y)-1.0));
}
#ifdef POUT
pout(n7, j, k, x, x, y, y);
#endif
/* MODULE 8: procedure calls */
x = y = z = 1.0;
for (i = 1; i <= n8; i +=1)
p3(x, y, &z);
#ifdef POUT
pout(n8, j, k, x, y, z, z);
#endif
/* MODULE9: array references */
j = 1;
k = 2;
l = 3;
e1[0] = 1.0;
e1[1] = 2.0;
e1[2] = 3.0;
for(i = 1; i <= n9; i += 1)
p0();
#ifdef POUT
pout(n9, j, k, e1[0], e1[1], e1[2], e1[3]);
#endif
/* MODULE10: integer arithmetic */
j = 2;
k = 3;
for(i = 1; i <= n10; i +=1) {
j = j + k;
k = j + k;
j = k - j;
k = k - j - j;
}
#ifdef POUT
pout(n10, j, k, x1, x2, x3, x4);
#endif
/* MODULE11: standard functions */
x = 0.75;
for(i = 1; i <= n11; i +=1)
x = sqrt( exp( log(x) / t1));
#ifdef POUT
pout(n11, j, k, x, x, x, x);
#endif
}
pa(e)
double e[4];
{
register int j;
j = 0;
lab:
e[0] = ( e[0] + e[1] + e[2] - e[3] ) * t;
e[1] = ( e[0] + e[1] - e[2] + e[3] ) * t;
e[2] = ( e[0] - e[1] + e[2] + e[3] ) * t;
e[3] = ( -e[0] + e[1] + e[2] + e[3] ) / t2;
j += 1;
if (j < 6)
goto lab;
}
p3(x, y, z)
double x, y, *z;
{
x = t * (x + y);
y = t * (x + y);
*z = (x + y) /t2;
}
p0()
{
e1[j] = e1[k];
e1[k] = e1[l];
e1[l] = e1[j];
}
#ifdef POUT
pout(n, j, k, x1, x2, x3, x4)
int n, j, k;
double x1, x2, x3, x4;
{
printf("%6d%6d%6d %5e %5e %5e %5e\n",
n, j, k, x1, x2, x3, x4);
}
#endif

1702
test/statemate.ll Normal file

File diff suppressed because it is too large Load Diff

253
test/ud.ll Normal file
View File

@ -0,0 +1,253 @@
; ModuleID = 'ud.c'
source_filename = "ud.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@a = dso_local local_unnamed_addr global [50 x [50 x i64]] zeroinitializer, align 16
@b = dso_local local_unnamed_addr global [50 x i64] zeroinitializer, align 16
@x = dso_local local_unnamed_addr global [50 x i64] zeroinitializer, align 16
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local void @main() local_unnamed_addr #0 {
br label %1
1: ; preds = %0, %16
%2 = phi i64 [ 0, %0 ], [ %3, %16 ]
%3 = add nuw nsw i64 %2, 1
br label %4
4: ; preds = %1, %4
%5 = phi i64 [ 0, %1 ], [ %7, %4 ]
%6 = phi i64 [ 0, %1 ], [ %14, %4 ]
%7 = add nuw nsw i64 %5, 1
%8 = add nuw nsw i64 %3, %7
%9 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %2, i64 %5
%10 = icmp eq i64 %2, %5
%11 = shl nuw i64 %8, 1
%12 = and i64 %11, 8589934590
%13 = select i1 %10, i64 %12, i64 %8
store i64 %13, i64* %9, align 8, !tbaa !5
%14 = add nuw nsw i64 %13, %6
%15 = icmp eq i64 %7, 6
br i1 %15, label %16, label %4, !llvm.loop !9
16: ; preds = %4
%17 = getelementptr inbounds [50 x i64], [50 x i64]* @b, i64 0, i64 %2
store i64 %14, i64* %17, align 8, !tbaa !5
%18 = icmp eq i64 %3, 6
br i1 %18, label %19, label %1, !llvm.loop !12
19: ; preds = %16
%20 = call i32 @ludcmp(i32 undef, i32 5)
ret void
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
; Function Attrs: nofree nosync nounwind sspstrong uwtable
define dso_local i32 @ludcmp(i32 %0, i32 %1) local_unnamed_addr #0 {
%3 = alloca [100 x i64], align 16
%4 = bitcast [100 x i64]* %3 to i8*
call void @llvm.lifetime.start.p0i8(i64 800, i8* nonnull %4) #2
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %59
6: ; preds = %2
%7 = add i32 %1, 1
%8 = zext i32 %1 to i64
%9 = zext i32 %7 to i64
%10 = zext i32 %7 to i64
br label %14
11: ; preds = %56
%12 = add nuw nsw i64 %16, 1
%13 = icmp eq i64 %17, %8
br i1 %13, label %59, label %14, !llvm.loop !13
14: ; preds = %6, %11
%15 = phi i64 [ 0, %6 ], [ %17, %11 ]
%16 = phi i64 [ 1, %6 ], [ %12, %11 ]
%17 = add nuw nsw i64 %15, 1
%18 = icmp eq i64 %15, 0
%19 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %15, i64 %15
br label %20
20: ; preds = %14, %35
%21 = phi i64 [ %16, %14 ], [ %39, %35 ]
%22 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %21, i64 %15
%23 = load i64, i64* %22, align 8, !tbaa !5
br i1 %18, label %35, label %24
24: ; preds = %20, %24
%25 = phi i64 [ %33, %24 ], [ 0, %20 ]
%26 = phi i64 [ %32, %24 ], [ %23, %20 ]
%27 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %21, i64 %25
%28 = load i64, i64* %27, align 8, !tbaa !5
%29 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %25, i64 %15
%30 = load i64, i64* %29, align 8, !tbaa !5
%31 = mul nsw i64 %30, %28
%32 = sub nsw i64 %26, %31
%33 = add nuw nsw i64 %25, 1
%34 = icmp eq i64 %33, %15
br i1 %34, label %35, label %24, !llvm.loop !14
35: ; preds = %24, %20
%36 = phi i64 [ %23, %20 ], [ %32, %24 ]
%37 = load i64, i64* %19, align 8, !tbaa !5
%38 = sdiv i64 %36, %37
store i64 %38, i64* %22, align 8, !tbaa !5
%39 = add nuw nsw i64 %21, 1
%40 = icmp eq i64 %39, %9
br i1 %40, label %41, label %20, !llvm.loop !15
41: ; preds = %35, %56
%42 = phi i64 [ %57, %56 ], [ %16, %35 ]
%43 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %17, i64 %42
%44 = load i64, i64* %43, align 8, !tbaa !5
br label %45
45: ; preds = %41, %45
%46 = phi i64 [ 0, %41 ], [ %54, %45 ]
%47 = phi i64 [ %44, %41 ], [ %53, %45 ]
%48 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %17, i64 %46
%49 = load i64, i64* %48, align 8, !tbaa !5
%50 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %46, i64 %42
%51 = load i64, i64* %50, align 8, !tbaa !5
%52 = mul nsw i64 %51, %49
%53 = sub nsw i64 %47, %52
%54 = add nuw nsw i64 %46, 1
%55 = icmp eq i64 %54, %16
br i1 %55, label %56, label %45, !llvm.loop !16
56: ; preds = %45
store i64 %53, i64* %43, align 8, !tbaa !5
%57 = add nuw nsw i64 %42, 1
%58 = icmp eq i64 %57, %10
br i1 %58, label %11, label %41, !llvm.loop !17
59: ; preds = %11, %2
%60 = load i64, i64* getelementptr inbounds ([50 x i64], [50 x i64]* @b, i64 0, i64 0), align 16, !tbaa !5
%61 = getelementptr inbounds [100 x i64], [100 x i64]* %3, i64 0, i64 0
store i64 %60, i64* %61, align 16, !tbaa !5
%62 = icmp slt i32 %1, 1
br i1 %62, label %85, label %63
63: ; preds = %59
%64 = add i32 %1, 1
%65 = zext i32 %64 to i64
br label %66
66: ; preds = %63, %81
%67 = phi i64 [ 1, %63 ], [ %83, %81 ]
%68 = getelementptr inbounds [50 x i64], [50 x i64]* @b, i64 0, i64 %67
%69 = load i64, i64* %68, align 8, !tbaa !5
br label %70
70: ; preds = %66, %70
%71 = phi i64 [ 0, %66 ], [ %79, %70 ]
%72 = phi i64 [ %69, %66 ], [ %78, %70 ]
%73 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %67, i64 %71
%74 = load i64, i64* %73, align 8, !tbaa !5
%75 = getelementptr inbounds [100 x i64], [100 x i64]* %3, i64 0, i64 %71
%76 = load i64, i64* %75, align 8, !tbaa !5
%77 = mul nsw i64 %76, %74
%78 = sub nsw i64 %72, %77
%79 = add nuw nsw i64 %71, 1
%80 = icmp eq i64 %79, %67
br i1 %80, label %81, label %70, !llvm.loop !18
81: ; preds = %70
%82 = getelementptr inbounds [100 x i64], [100 x i64]* %3, i64 0, i64 %67
store i64 %78, i64* %82, align 8, !tbaa !5
%83 = add nuw nsw i64 %67, 1
%84 = icmp eq i64 %83, %65
br i1 %84, label %85, label %66, !llvm.loop !19
85: ; preds = %81, %59
%86 = sext i32 %1 to i64
%87 = getelementptr inbounds [100 x i64], [100 x i64]* %3, i64 0, i64 %86
%88 = load i64, i64* %87, align 8, !tbaa !5
%89 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %86, i64 %86
%90 = load i64, i64* %89, align 8, !tbaa !5
%91 = sdiv i64 %88, %90
%92 = getelementptr inbounds [50 x i64], [50 x i64]* @x, i64 0, i64 %86
store i64 %91, i64* %92, align 8, !tbaa !5
%93 = icmp sgt i32 %1, 0
br i1 %93, label %94, label %123
94: ; preds = %85
%95 = sext i32 %1 to i64
%96 = add i32 %1, 1
%97 = sext i32 %1 to i64
br label %98
98: ; preds = %94, %116
%99 = phi i64 [ %95, %94 ], [ %100, %116 ]
%100 = add nsw i64 %99, -1
%101 = getelementptr inbounds [100 x i64], [100 x i64]* %3, i64 0, i64 %100
%102 = load i64, i64* %101, align 8, !tbaa !5
%103 = icmp sgt i64 %99, %97
br i1 %103, label %116, label %104
104: ; preds = %98, %104
%105 = phi i64 [ %113, %104 ], [ %99, %98 ]
%106 = phi i64 [ %112, %104 ], [ %102, %98 ]
%107 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %100, i64 %105
%108 = load i64, i64* %107, align 8, !tbaa !5
%109 = getelementptr inbounds [50 x i64], [50 x i64]* @x, i64 0, i64 %105
%110 = load i64, i64* %109, align 8, !tbaa !5
%111 = mul nsw i64 %110, %108
%112 = sub nsw i64 %106, %111
%113 = add nsw i64 %105, 1
%114 = trunc i64 %113 to i32
%115 = icmp eq i32 %96, %114
br i1 %115, label %116, label %104, !llvm.loop !20
116: ; preds = %104, %98
%117 = phi i64 [ %102, %98 ], [ %112, %104 ]
%118 = getelementptr inbounds [50 x [50 x i64]], [50 x [50 x i64]]* @a, i64 0, i64 %100, i64 %100
%119 = load i64, i64* %118, align 8, !tbaa !5
%120 = sdiv i64 %117, %119
%121 = getelementptr inbounds [50 x i64], [50 x i64]* @x, i64 0, i64 %100
store i64 %120, i64* %121, align 8, !tbaa !5
%122 = icmp sgt i64 %99, 1
br i1 %122, label %98, label %123, !llvm.loop !21
123: ; preds = %116, %85
call void @llvm.lifetime.end.p0i8(i64 800, i8* nonnull %4) #2
ret i32 0
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
attributes #0 = { nofree nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }
attributes #2 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unroll.disable"}
!12 = distinct !{!12, !10, !11}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10, !11}
!15 = distinct !{!15, !10, !11}
!16 = distinct !{!16, !10, !11}
!17 = distinct !{!17, !10, !11}
!18 = distinct !{!18, !10, !11}
!19 = distinct !{!19, !10, !11}
!20 = distinct !{!20, !10, !11}
!21 = distinct !{!21, !10, !11}

452
test/whet.ll Normal file
View File

@ -0,0 +1,452 @@
; ModuleID = 'whet.c'
source_filename = "whet.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@t = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@t1 = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@t2 = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@n1 = dso_local local_unnamed_addr global i32 0, align 4
@n2 = dso_local local_unnamed_addr global i32 0, align 4
@n3 = dso_local local_unnamed_addr global i32 0, align 4
@n4 = dso_local local_unnamed_addr global i32 0, align 4
@n6 = dso_local local_unnamed_addr global i32 0, align 4
@n7 = dso_local local_unnamed_addr global i32 0, align 4
@n8 = dso_local local_unnamed_addr global i32 0, align 4
@n9 = dso_local local_unnamed_addr global i32 0, align 4
@n10 = dso_local local_unnamed_addr global i32 0, align 4
@n11 = dso_local local_unnamed_addr global i32 0, align 4
@x1 = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@x4 = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@x3 = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@x2 = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@i = dso_local local_unnamed_addr global i32 0, align 4
@e1 = dso_local local_unnamed_addr global [4 x double] zeroinitializer, align 16
@j = dso_local local_unnamed_addr global i32 0, align 4
@k = dso_local local_unnamed_addr global i32 0, align 4
@l = dso_local local_unnamed_addr global i32 0, align 4
@y = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@x = dso_local local_unnamed_addr global double 0.000000e+00, align 8
@z = dso_local local_unnamed_addr global double 0.000000e+00, align 8
; Function Attrs: nofree nounwind sspstrong uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
store double 4.999750e-01, double* @t, align 8, !tbaa !5
store double 5.002500e-01, double* @t1, align 8, !tbaa !5
store double 2.000000e+00, double* @t2, align 8, !tbaa !5
store i32 0, i32* @n1, align 4, !tbaa !9
store i32 120, i32* @n2, align 4, !tbaa !9
store i32 140, i32* @n3, align 4, !tbaa !9
store i32 3450, i32* @n4, align 4, !tbaa !9
store i32 2100, i32* @n6, align 4, !tbaa !9
store i32 320, i32* @n7, align 4, !tbaa !9
store i32 8990, i32* @n8, align 4, !tbaa !9
store i32 6160, i32* @n9, align 4, !tbaa !9
store i32 0, i32* @n10, align 4, !tbaa !9
store i32 930, i32* @n11, align 4, !tbaa !9
store double 1.000000e+00, double* @x1, align 8, !tbaa !5
store double -1.000000e+00, double* @x4, align 8, !tbaa !5
store double -1.000000e+00, double* @x3, align 8, !tbaa !5
store double -1.000000e+00, double* @x2, align 8, !tbaa !5
store i32 1, i32* @i, align 4, !tbaa !9
store double 1.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 0), align 16, !tbaa !5
store double -1.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 3), align 8, !tbaa !5
store double -1.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 2), align 16, !tbaa !5
store double -1.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 1), align 8, !tbaa !5
br label %2
1: ; preds = %2
store i32 121, i32* @i, align 4, !tbaa !9
store double %11, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 0), align 16, !tbaa !5
store double %15, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 1), align 8, !tbaa !5
store double %19, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 2), align 16, !tbaa !5
store double %23, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 3), align 8, !tbaa !5
br label %26
2: ; preds = %0, %2
%3 = phi i32 [ 1, %0 ], [ %24, %2 ]
%4 = phi double [ 1.000000e+00, %0 ], [ %11, %2 ]
%5 = phi double [ -1.000000e+00, %0 ], [ %15, %2 ]
%6 = phi double [ -1.000000e+00, %0 ], [ %19, %2 ]
%7 = phi double [ -1.000000e+00, %0 ], [ %23, %2 ]
%8 = fadd double %4, %5
%9 = fadd double %8, %6
%10 = fsub double %9, %7
%11 = fmul double %10, 4.999750e-01
%12 = fadd double %5, %11
%13 = fsub double %12, %6
%14 = fadd double %7, %13
%15 = fmul double %14, 4.999750e-01
%16 = fsub double %11, %15
%17 = fadd double %6, %16
%18 = fadd double %7, %17
%19 = fmul double %18, 4.999750e-01
%20 = fsub double %15, %11
%21 = fadd double %20, %19
%22 = fadd double %7, %21
%23 = fmul double %22, 4.999750e-01
%24 = add nuw nsw i32 %3, 1
%25 = icmp eq i32 %24, 121
br i1 %25, label %1, label %2, !llvm.loop !11
26: ; preds = %1, %56
%27 = phi i32 [ 1, %1 ], [ %57, %56 ]
%28 = phi double [ %15, %1 ], [ %45, %56 ]
%29 = phi double [ %19, %1 ], [ %49, %56 ]
%30 = phi double [ %23, %1 ], [ %53, %56 ]
%31 = phi double [ %11, %1 ], [ %41, %56 ]
br label %32
32: ; preds = %32, %26
%33 = phi double [ %31, %26 ], [ %41, %32 ]
%34 = phi double [ %30, %26 ], [ %53, %32 ]
%35 = phi double [ %29, %26 ], [ %49, %32 ]
%36 = phi double [ %28, %26 ], [ %45, %32 ]
%37 = phi i32 [ 0, %26 ], [ %54, %32 ]
%38 = fadd double %36, %33
%39 = fadd double %35, %38
%40 = fsub double %39, %34
%41 = fmul double %40, 4.999750e-01
%42 = fadd double %36, %41
%43 = fsub double %42, %35
%44 = fadd double %34, %43
%45 = fmul double %44, 4.999750e-01
%46 = fsub double %41, %45
%47 = fadd double %35, %46
%48 = fadd double %34, %47
%49 = fmul double %48, 4.999750e-01
%50 = fsub double %45, %41
%51 = fadd double %50, %49
%52 = fadd double %34, %51
%53 = fmul double %52, 5.000000e-01
%54 = add nuw nsw i32 %37, 1
%55 = icmp eq i32 %54, 6
br i1 %55, label %56, label %32
56: ; preds = %32
%57 = add nuw nsw i32 %27, 1
%58 = icmp eq i32 %57, 141
br i1 %58, label %59, label %26, !llvm.loop !14
59: ; preds = %56
store i32 141, i32* @i, align 4, !tbaa !9
store double %45, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 1), align 8, !tbaa !5
store double %49, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 2), align 16, !tbaa !5
store double %53, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 3), align 8, !tbaa !5
store double %41, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 0), align 16, !tbaa !5
store i32 1, i32* @j, align 4, !tbaa !9
store i32 3451, i32* @i, align 4, !tbaa !9
store i32 1, i32* @j, align 4, !tbaa !9
store i32 2, i32* @k, align 4, !tbaa !9
store i32 3, i32* @l, align 4, !tbaa !9
store double 6.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 1), align 8, !tbaa !5
store double 6.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 0), align 16, !tbaa !5
br label %60
60: ; preds = %59, %60
%61 = phi i32 [ 1, %59 ], [ %62, %60 ]
%62 = add nuw nsw i32 %61, 1
%63 = icmp eq i32 %62, 2101
br i1 %63, label %64, label %60, !llvm.loop !15
64: ; preds = %60
store i32 2101, i32* @i, align 4, !tbaa !9
store i32 1, i32* @j, align 4, !tbaa !9
store i32 2, i32* @k, align 4, !tbaa !9
store i32 3, i32* @l, align 4, !tbaa !9
store double 5.000000e-01, double* @y, align 8, !tbaa !5
store double 5.000000e-01, double* @x, align 8, !tbaa !5
store i32 1, i32* @i, align 4, !tbaa !9
%65 = load i32, i32* @n7, align 4, !tbaa !9
%66 = icmp slt i32 %65, 1
br i1 %66, label %114, label %67
67: ; preds = %64, %67
%68 = load double, double* @t, align 8, !tbaa !5
%69 = load double, double* @t2, align 8, !tbaa !5
%70 = load double, double* @x, align 8, !tbaa !5
%71 = call double @sin(double %70) #4
%72 = fmul double %69, %71
%73 = load double, double* @x, align 8, !tbaa !5
%74 = call double @cos(double %73) #4
%75 = fmul double %72, %74
%76 = load double, double* @x, align 8, !tbaa !5
%77 = load double, double* @y, align 8, !tbaa !5
%78 = fadd double %76, %77
%79 = call double @cos(double %78) #4
%80 = load double, double* @x, align 8, !tbaa !5
%81 = load double, double* @y, align 8, !tbaa !5
%82 = fsub double %80, %81
%83 = call double @cos(double %82) #4
%84 = fadd double %79, %83
%85 = fadd double %84, -1.000000e+00
%86 = fdiv double %75, %85
%87 = call double @atan(double %86) #4
%88 = fmul double %68, %87
store double %88, double* @x, align 8, !tbaa !5
%89 = load double, double* @t, align 8, !tbaa !5
%90 = load double, double* @t2, align 8, !tbaa !5
%91 = load double, double* @y, align 8, !tbaa !5
%92 = call double @sin(double %91) #4
%93 = fmul double %90, %92
%94 = load double, double* @y, align 8, !tbaa !5
%95 = call double @cos(double %94) #4
%96 = fmul double %93, %95
%97 = load double, double* @x, align 8, !tbaa !5
%98 = load double, double* @y, align 8, !tbaa !5
%99 = fadd double %97, %98
%100 = call double @cos(double %99) #4
%101 = load double, double* @x, align 8, !tbaa !5
%102 = load double, double* @y, align 8, !tbaa !5
%103 = fsub double %101, %102
%104 = call double @cos(double %103) #4
%105 = fadd double %100, %104
%106 = fadd double %105, -1.000000e+00
%107 = fdiv double %96, %106
%108 = call double @atan(double %107) #4
%109 = fmul double %89, %108
store double %109, double* @y, align 8, !tbaa !5
%110 = load i32, i32* @i, align 4, !tbaa !9
%111 = add nsw i32 %110, 1
store i32 %111, i32* @i, align 4, !tbaa !9
%112 = load i32, i32* @n7, align 4, !tbaa !9
%113 = icmp slt i32 %110, %112
br i1 %113, label %67, label %114, !llvm.loop !16
114: ; preds = %67, %64
store double 1.000000e+00, double* @z, align 8, !tbaa !5
store double 1.000000e+00, double* @y, align 8, !tbaa !5
store double 1.000000e+00, double* @x, align 8, !tbaa !5
%115 = load i32, i32* @n8, align 4, !tbaa !9
%116 = load double, double* @t, align 8
%117 = fmul double %116, 2.000000e+00
%118 = icmp slt i32 %115, 1
br i1 %118, label %126, label %119
119: ; preds = %114
%120 = fadd double %117, 1.000000e+00
%121 = fmul double %116, %120
%122 = fadd double %117, %121
%123 = load double, double* @t2, align 8
%124 = fdiv double %122, %123
store double %124, double* @z, align 8, !tbaa !5
%125 = add i32 %115, 1
br label %126
126: ; preds = %119, %114
%127 = phi i32 [ 1, %114 ], [ %125, %119 ]
store i32 %127, i32* @i, align 4, !tbaa !9
store i32 1, i32* @j, align 4, !tbaa !9
store i32 2, i32* @k, align 4, !tbaa !9
store i32 3, i32* @l, align 4, !tbaa !9
store double 1.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 0), align 16, !tbaa !5
store double 2.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 1), align 8, !tbaa !5
store double 3.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 2), align 16, !tbaa !5
%128 = load i32, i32* @n9, align 4, !tbaa !9
%129 = icmp slt i32 %128, 1
br i1 %129, label %141, label %130
130: ; preds = %126
%131 = load double, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 2), align 16, !tbaa !5
%132 = load double, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 3), align 8, !tbaa !5
%133 = add i32 %128, 1
br label %134
134: ; preds = %130, %134
%135 = phi double [ %132, %130 ], [ %136, %134 ]
%136 = phi double [ %131, %130 ], [ %135, %134 ]
%137 = phi i32 [ 1, %130 ], [ %138, %134 ]
%138 = add nuw i32 %137, 1
%139 = icmp eq i32 %137, %128
br i1 %139, label %140, label %134, !llvm.loop !17
140: ; preds = %134
store double %135, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 2), align 16, !tbaa !5
store double %136, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 1), align 8, !tbaa !5
store double %136, double* getelementptr inbounds ([4 x double], [4 x double]* @e1, i64 0, i64 3), align 8, !tbaa !5
br label %141
141: ; preds = %140, %126
%142 = phi i32 [ %133, %140 ], [ 1, %126 ]
store i32 %142, i32* @i, align 4, !tbaa !9
store i32 2, i32* @j, align 4, !tbaa !9
store i32 3, i32* @k, align 4, !tbaa !9
%143 = load i32, i32* @n10, align 4, !tbaa !9
%144 = icmp slt i32 %143, 1
br i1 %144, label %156, label %145
145: ; preds = %141
%146 = load i32, i32* @j, align 4, !tbaa !9
%147 = load i32, i32* @k, align 4, !tbaa !9
%148 = add i32 %143, 1
br label %149
149: ; preds = %145, %149
%150 = phi i32 [ %147, %145 ], [ %151, %149 ]
%151 = phi i32 [ %146, %145 ], [ %150, %149 ]
%152 = phi i32 [ 1, %145 ], [ %153, %149 ]
%153 = add nuw i32 %152, 1
%154 = icmp eq i32 %152, %143
br i1 %154, label %155, label %149, !llvm.loop !18
155: ; preds = %149
store i32 %150, i32* @j, align 4, !tbaa !9
store i32 %151, i32* @k, align 4, !tbaa !9
br label %156
156: ; preds = %155, %141
%157 = phi i32 [ %148, %155 ], [ 1, %141 ]
store i32 %157, i32* @i, align 4, !tbaa !9
store double 7.500000e-01, double* @x, align 8, !tbaa !5
store i32 1, i32* @i, align 4, !tbaa !9
%158 = load i32, i32* @n11, align 4, !tbaa !9
%159 = icmp slt i32 %158, 1
br i1 %159, label %171, label %160
160: ; preds = %156, %160
%161 = load double, double* @x, align 8, !tbaa !5
%162 = call double @log(double %161) #4
%163 = load double, double* @t1, align 8, !tbaa !5
%164 = fdiv double %162, %163
%165 = call double @exp(double %164) #4
%166 = call double @sqrt(double %165) #4
store double %166, double* @x, align 8, !tbaa !5
%167 = load i32, i32* @i, align 4, !tbaa !9
%168 = add nsw i32 %167, 1
store i32 %168, i32* @i, align 4, !tbaa !9
%169 = load i32, i32* @n11, align 4, !tbaa !9
%170 = icmp slt i32 %167, %169
br i1 %170, label %160, label %171, !llvm.loop !19
171: ; preds = %160, %156
ret i32 0
}
; Function Attrs: mustprogress nofree nounwind willreturn
declare double @atan(double) local_unnamed_addr #1
; Function Attrs: mustprogress nofree nounwind willreturn
declare double @sin(double) local_unnamed_addr #1
; Function Attrs: mustprogress nofree nounwind willreturn
declare double @cos(double) local_unnamed_addr #1
; Function Attrs: mustprogress nofree nounwind willreturn
declare double @sqrt(double) local_unnamed_addr #1
; Function Attrs: mustprogress nofree nounwind willreturn
declare double @exp(double) local_unnamed_addr #1
; Function Attrs: mustprogress nofree nounwind willreturn
declare double @log(double) local_unnamed_addr #1
; Function Attrs: nofree norecurse nosync nounwind sspstrong uwtable
define dso_local i32 @pa(double* nocapture %0) local_unnamed_addr #2 {
%2 = getelementptr inbounds double, double* %0, i64 1
%3 = getelementptr inbounds double, double* %0, i64 2
%4 = getelementptr inbounds double, double* %0, i64 3
%5 = load double, double* %2, align 8, !tbaa !5
%6 = load double, double* %3, align 8, !tbaa !5
%7 = load double, double* %4, align 8, !tbaa !5
br label %8
8: ; preds = %8, %1
%9 = phi double [ %7, %1 ], [ %32, %8 ]
%10 = phi double [ %6, %1 ], [ %27, %8 ]
%11 = phi double [ %5, %1 ], [ %23, %8 ]
%12 = phi i32 [ 0, %1 ], [ %33, %8 ]
%13 = load double, double* %0, align 8, !tbaa !5
%14 = fadd double %13, %11
%15 = fadd double %14, %10
%16 = fsub double %15, %9
%17 = load double, double* @t, align 8, !tbaa !5
%18 = fmul double %16, %17
store double %18, double* %0, align 8, !tbaa !5
%19 = fadd double %11, %18
%20 = fsub double %19, %10
%21 = fadd double %9, %20
%22 = load double, double* @t, align 8, !tbaa !5
%23 = fmul double %22, %21
%24 = fsub double %18, %23
%25 = fadd double %10, %24
%26 = fadd double %9, %25
%27 = fmul double %22, %26
%28 = fsub double %23, %18
%29 = fadd double %28, %27
%30 = fadd double %9, %29
%31 = load double, double* @t2, align 8, !tbaa !5
%32 = fdiv double %30, %31
%33 = add nuw nsw i32 %12, 1
%34 = icmp eq i32 %33, 6
br i1 %34, label %35, label %8
35: ; preds = %8
store double %23, double* %2, align 8, !tbaa !5
store double %27, double* %3, align 8, !tbaa !5
store double %32, double* %4, align 8, !tbaa !5
ret i32 undef
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn
define dso_local i32 @p3(double %0, double %1, double* nocapture %2) local_unnamed_addr #3 {
%4 = load double, double* @t, align 8, !tbaa !5
%5 = fadd double %0, %1
%6 = fmul double %5, %4
%7 = fadd double %6, %1
%8 = fmul double %4, %7
%9 = fadd double %6, %8
%10 = load double, double* @t2, align 8, !tbaa !5
%11 = fdiv double %9, %10
store double %11, double* %2, align 8, !tbaa !5
ret i32 undef
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn
define dso_local i32 @p0() local_unnamed_addr #3 {
%1 = load i32, i32* @k, align 4, !tbaa !9
%2 = sext i32 %1 to i64
%3 = getelementptr inbounds [4 x double], [4 x double]* @e1, i64 0, i64 %2
%4 = load double, double* %3, align 8, !tbaa !5
%5 = load i32, i32* @j, align 4, !tbaa !9
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [4 x double], [4 x double]* @e1, i64 0, i64 %6
store double %4, double* %7, align 8, !tbaa !5
%8 = load i32, i32* @l, align 4, !tbaa !9
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [4 x double], [4 x double]* @e1, i64 0, i64 %9
%11 = load double, double* %10, align 8, !tbaa !5
store double %11, double* %3, align 8, !tbaa !5
%12 = load double, double* %7, align 8, !tbaa !5
store double %12, double* %10, align 8, !tbaa !5
ret i32 undef
}
attributes #0 = { nofree nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree norecurse nosync nounwind sspstrong uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree norecurse nosync nounwind sspstrong uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 1}
!4 = !{!"clang version 13.0.1"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12, !13}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.unroll.disable"}
!14 = distinct !{!14, !12, !13}
!15 = distinct !{!15, !12, !13}
!16 = distinct !{!16, !12, !13}
!17 = distinct !{!17, !12, !13}
!18 = distinct !{!18, !12, !13}
!19 = distinct !{!19, !12, !13}