Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
Revert some fastcomp changes
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Sep 7, 2016
1 parent 5d4025c commit 8d07d6d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 70 deletions.
4 changes: 2 additions & 2 deletions lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,10 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
GV.hasAvailableExternallyLinkage(),
"Global is marked as dllimport, but not external", &GV);

//if (!GV.hasInitializer()) { // XXX EMSCRIPTEN - do not do extra verification below, 40x slower linking on some big projects
if (!GV.hasInitializer()) {
visitGlobalValue(GV);
return;
//}
}

// Walk any aggregate initializers looking for bitcasts between address spaces
visitConstantExprsRecursively(GV.getInitializer());
Expand Down
58 changes: 1 addition & 57 deletions lib/Transforms/IPO/GlobalOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,61 +1547,6 @@ static bool optimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
return false;
}

/// TryToAddRangeMetadata - At this point, we have learned that the only
/// two values ever stored into GV are its initializer and OtherVal. See if we
/// can annotate loads from it with range metadata describing this.
/// This exposes the values to other scalar optimizations.
static bool TryToAddRangeMetadata(GlobalVariable *GV, Constant *OtherVal) {
Type *GVElType = GV->getType()->getElementType();

// If GVElType is already i1, it already has a minimal range. If the type of
// the GV is an FP value, pointer or vector, don't do this optimization
// because range metadata is currently only supported on scalar integers.
if (GVElType == Type::getInt1Ty(GV->getContext()) ||
GVElType->isFloatingPointTy() ||
GVElType->isPointerTy() || GVElType->isVectorTy())
return false;

// Walk the use list of the global seeing if all the uses are load or store.
// If there is anything else, bail out.
for (User *U : GV->users())
if (!isa<LoadInst>(U) && !isa<StoreInst>(U))
return false;

Constant *InitVal = GV->getInitializer();
assert(InitVal->getType() != Type::getInt1Ty(GV->getContext()) &&
"No reason to add range metadata!");

// The MD_range metadata only supports absolute integer constants.
if (!isa<ConstantInt>(InitVal) || !isa<ConstantInt>(OtherVal))
return false;

DEBUG(dbgs() << " *** ADDING RANGE METADATA: " << *GV);

for (Value::user_iterator I = GV->user_begin(), E = GV->user_end(); I != E; ++I){
Instruction *UI = cast<Instruction>(*I);
if (LoadInst *LI = dyn_cast<LoadInst>(UI)) {
// If we already have a range, don't add a new one, so that GlobalOpt
// terminates. In theory, we could merge the two ranges.
if (LI->getMetadata(LLVMContext::MD_range))
return false;
// Add range metadata to the load. We have two possible values, and we
// need to create a half-open range. The range can wrap, so we can use
// either signed or unsigned; we pick signed because it might be prettier
// in common cases.
Constant *Cmp = ConstantExpr::getICmp(ICmpInst::ICMP_SLT, InitVal, OtherVal);
Constant *One = ConstantInt::get(LI->getType(), 1);
SmallVector<Metadata *, 2> NewOps;
NewOps.push_back(ConstantAsMetadata::get(ConstantExpr::getSelect(Cmp, InitVal, OtherVal)));
NewOps.push_back(ConstantAsMetadata::get(ConstantExpr::getAdd(ConstantExpr::getSelect(Cmp, OtherVal, InitVal), One)));
MDNode *MD = MDNode::get(LI->getContext(), NewOps);
LI->setMetadata(LLVMContext::MD_range, MD);
}
}

return true;
}

/// At this point, we have learned that the only two values ever stored into GV
/// are its initializer and OtherVal. See if we can shrink the global into a
/// boolean and select between the two values whenever it is used. This exposes
Expand Down Expand Up @@ -1981,10 +1926,9 @@ static bool processInternalGlobal(

// Otherwise, if the global was not a boolean, we can shrink it to be a
// boolean.
// XXX EMSCRIPTEN - add range metadata instead
if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue)) {
if (GS.Ordering == AtomicOrdering::NotAtomic) {
if (TryToAddRangeMetadata(GV, SOVConstant)) { // XXX EMSCRIPTEN
if (TryToShrinkGlobalToBoolean(GV, SOVConstant)) {
++NumShrunkToBool;
return true;
}
Expand Down
12 changes: 1 addition & 11 deletions lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,17 +1249,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {

// If the result mask is equal to one of the original shuffle masks,
// or is a splat, do the replacement.
//
// XXX EMSCRIPTEN: Add '|| true' so that we always do the replacement.
// We're targetting SIMD.js, so there's less of an expectation that a
// particular shuffle mask will always map onto a particular instruction on
// a particular ISA because we aren't targetting a particular ISA (what the
// JS engine does is another story). We may wish to re-evaluate this choice
// as we move on to higher-element-count vectors, but especially for now this
// is quite desirable.
if (isSplat || newMask == LHSMask || newMask == RHSMask || newMask == Mask ||
true)
{
if (isSplat || newMask == LHSMask || newMask == RHSMask || newMask == Mask) {
SmallVector<Constant*, 16> Elts;
for (unsigned i = 0, e = newMask.size(); i != e; ++i) {
if (newMask[i] < 0) {
Expand Down

0 comments on commit 8d07d6d

Please sign in to comment.