diff --git a/opt.cpp b/opt.cpp index e8a04b3e..135eb35d 100644 --- a/opt.cpp +++ b/opt.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #ifndef LLVM_2_8 #include #ifdef LLVM_2_9 @@ -69,6 +70,7 @@ #include #include #include +#include #include #include #ifndef LLVM_2_8 @@ -469,8 +471,18 @@ lGetMask(llvm::Value *factor) { else if (llvm::isa(factor)) return 0; else { +#if 0 + llvm::ConstantExpr *ce = llvm::dyn_cast(factor); + if (ce != NULL) { + llvm::TargetMachine *targetMachine = g->target.GetTargetMachine(); + const llvm::TargetData *td = targetMachine->getTargetData(); + llvm::Constant *c = llvm::ConstantFoldConstantExpression(ce, td); + c->dump(); + factor = c; + } // else we should be able to handle it above... assert(!llvm::isa(factor)); +#endif return -1; } } @@ -608,9 +620,10 @@ IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) { llvm::PointerType::get(returnType, 0), "ptr2vec", callInst); lCopyMetadata(castPtr, callInst); + int align = callInst->getCalledFunction() == avxMaskedLoad32 ? 4 : 8; llvm::Instruction *loadInst = new llvm::LoadInst(castPtr, "load", false /* not volatile */, - 0 /* align */, (llvm::Instruction *)NULL); + align, (llvm::Instruction *)NULL); lCopyMetadata(loadInst, callInst); llvm::ReplaceInstWithInst(callInst, loadInst); modifiedAny = true;