Jlm
Functions
LlvmPhiConversionTests.cpp File Reference
#include <gtest/gtest.h>
#include <jlm/llvm/frontend/LlvmModuleConversion.hpp>
#include <jlm/llvm/ir/operators/call.hpp>
#include <jlm/llvm/ir/operators/IntegerOperations.hpp>
#include <jlm/llvm/ir/operators/operators.hpp>
#include <jlm/llvm/ir/print.hpp>
#include <jlm/rvsdg/bitstring/constant.hpp>
#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IRReader/IRReader.h>
#include <string>
Include dependency graph for LlvmPhiConversionTests.cpp:

Go to the source code of this file.

Functions

 TEST (LlvmPhiConversionTests, TestPhiConversion)
 
 TEST (LlvmPhiConversionTests, TestPhiOperandElision)
 

Function Documentation

◆ TEST() [1/2]

TEST ( LlvmPhiConversionTests  ,
TestPhiConversion   
)

Tests converting instances of llvm::PHINode. Some of the operands have constant values, and some are results from the predecessors. One of the phi node has its own result as one of its operands.

The function corresponds to the C code uint64_t popcount(uint64_t x) { uint64_t popcnt = 0;

while(true) { // 2 phi nodes with 3 possible predecessors here // one for x, and one for popcnt

if (x == 0) break; uint64_t rem = x % 2 == 1; x >>= 1; if (rem) { popcnt++; continue; } else { continue; } } return popcnt; }

Definition at line 49 of file LlvmPhiConversionTests.cpp.

◆ TEST() [2/2]

TEST ( LlvmPhiConversionTests  ,
TestPhiOperandElision   
)

Tests converting instances of llvm::PHINode where some of the predecessors are "dead". A dead predecessor is a basic block that is not reachable from the function's entry. This test has one phi node with 4 operands, where two of them are dead.

Definition at line 158 of file LlvmPhiConversionTests.cpp.