summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-09-26 14:01:53 +0000
committerHans Wennborg <hans@hanshq.net>2012-09-26 14:01:53 +0000
commitcd3a11f72576b88578f5615ab3d24919b6e60aae (patch)
tree15078b040090cc4ef4057419dfe2a85719a1dfb3 /llvm/lib/Transforms/Utils
parent3f6a5c1b2dff14f4b6e3a0df8badd0714d46481e (diff)
downloadbcm5719-llvm-cd3a11f72576b88578f5615ab3d24919b6e60aae.tar.gz
bcm5719-llvm-cd3a11f72576b88578f5615ab3d24919b6e60aae.zip
Address Duncan's comments on r164684:
- Put statistics in alphabetical order - Don't use getZextValue when building TableInt, just use APInts - Introduce Create{Z,S}ExtOrTrunc in IRBuilder. llvm-svn: 164696
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index d7468a18908..299c0596da3 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -58,10 +58,10 @@ static cl::opt<bool>
SinkCommon("simplifycfg-sink-common", cl::Hidden, cl::init(true),
cl::desc("Sink common instructions down to the end block"));
-STATISTIC(NumSpeculations, "Number of speculative executed instructions");
-STATISTIC(NumLookupTables, "Number of switch instructions turned into lookup tables");
STATISTIC(NumBitMaps, "Number of switch instructions turned into bitmaps");
+STATISTIC(NumLookupTables, "Number of switch instructions turned into lookup tables");
STATISTIC(NumSinkCommons, "Number of common instructions sunk down to the end block");
+STATISTIC(NumSpeculations, "Number of speculative executed instructions");
namespace {
/// ValueEqualityComparisonCase - Represents a case of a switch.
@@ -3347,7 +3347,8 @@ SwitchLookupTable::SwitchLookupTable(Module &M,
APInt TableInt(TableSize * IT->getBitWidth(), 0);
for (uint64_t I = TableSize; I > 0; --I) {
TableInt <<= IT->getBitWidth();
- TableInt |= cast<ConstantInt>(TableContents[I - 1])->getZExtValue();
+ ConstantInt *Val = cast<ConstantInt>(TableContents[I - 1]);
+ TableInt |= Val->getValue().zext(TableInt.getBitWidth());
}
BitMap = ConstantInt::get(M.getContext(), TableInt);
BitMapElementTy = IT;
@@ -3379,12 +3380,7 @@ Value *SwitchLookupTable::BuildLookup(Value *Index, IRBuilder<> &Builder) {
// Cast Index to the same type as the bitmap.
// Note: The Index is <= the number of elements in the table, so
// truncating it to the width of the bitmask is safe.
- Value *ShiftAmt = Index;
- IntegerType *IndexTy = cast<IntegerType>(Index->getType());
- if (IndexTy->getBitWidth() < MapTy->getBitWidth())
- ShiftAmt = Builder.CreateZExt(ShiftAmt, MapTy, "switch.zext");
- else if (IndexTy->getBitWidth() > MapTy->getBitWidth())
- ShiftAmt = Builder.CreateTrunc(ShiftAmt, MapTy, "switch.trunc");
+ Value *ShiftAmt = Builder.CreateZExtOrTrunc(Index, MapTy, "switch.cast");
// Multiply the shift amount by the element width.
ShiftAmt = Builder.CreateMul(ShiftAmt,
OpenPOWER on IntegriCloud