AVX: fix alignment when changing masked load to regular load.
Also added some debugging/tracing stuff (commented out). Commented out iffy assert that was hitting for avx stuff.
This commit is contained in:
15
opt.cpp
15
opt.cpp
@@ -55,6 +55,7 @@
|
|||||||
#include <llvm/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
#include <llvm/Intrinsics.h>
|
#include <llvm/Intrinsics.h>
|
||||||
#include <llvm/Constants.h>
|
#include <llvm/Constants.h>
|
||||||
|
#include <llvm/Analysis/ConstantFolding.h>
|
||||||
#ifndef LLVM_2_8
|
#ifndef LLVM_2_8
|
||||||
#include <llvm/Target/TargetLibraryInfo.h>
|
#include <llvm/Target/TargetLibraryInfo.h>
|
||||||
#ifdef LLVM_2_9
|
#ifdef LLVM_2_9
|
||||||
@@ -69,6 +70,7 @@
|
|||||||
#include <llvm/Transforms/Utils/BasicBlockUtils.h>
|
#include <llvm/Transforms/Utils/BasicBlockUtils.h>
|
||||||
#include <llvm/Target/TargetOptions.h>
|
#include <llvm/Target/TargetOptions.h>
|
||||||
#include <llvm/Target/TargetData.h>
|
#include <llvm/Target/TargetData.h>
|
||||||
|
#include <llvm/Target/TargetMachine.h>
|
||||||
#include <llvm/Analysis/Verifier.h>
|
#include <llvm/Analysis/Verifier.h>
|
||||||
#include <llvm/Support/raw_ostream.h>
|
#include <llvm/Support/raw_ostream.h>
|
||||||
#ifndef LLVM_2_8
|
#ifndef LLVM_2_8
|
||||||
@@ -469,8 +471,18 @@ lGetMask(llvm::Value *factor) {
|
|||||||
else if (llvm::isa<llvm::ConstantAggregateZero>(factor))
|
else if (llvm::isa<llvm::ConstantAggregateZero>(factor))
|
||||||
return 0;
|
return 0;
|
||||||
else {
|
else {
|
||||||
|
#if 0
|
||||||
|
llvm::ConstantExpr *ce = llvm::dyn_cast<llvm::ConstantExpr>(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...
|
// else we should be able to handle it above...
|
||||||
assert(!llvm::isa<llvm::Constant>(factor));
|
assert(!llvm::isa<llvm::Constant>(factor));
|
||||||
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -608,9 +620,10 @@ IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
|
|||||||
llvm::PointerType::get(returnType, 0),
|
llvm::PointerType::get(returnType, 0),
|
||||||
"ptr2vec", callInst);
|
"ptr2vec", callInst);
|
||||||
lCopyMetadata(castPtr, callInst);
|
lCopyMetadata(castPtr, callInst);
|
||||||
|
int align = callInst->getCalledFunction() == avxMaskedLoad32 ? 4 : 8;
|
||||||
llvm::Instruction *loadInst =
|
llvm::Instruction *loadInst =
|
||||||
new llvm::LoadInst(castPtr, "load", false /* not volatile */,
|
new llvm::LoadInst(castPtr, "load", false /* not volatile */,
|
||||||
0 /* align */, (llvm::Instruction *)NULL);
|
align, (llvm::Instruction *)NULL);
|
||||||
lCopyMetadata(loadInst, callInst);
|
lCopyMetadata(loadInst, callInst);
|
||||||
llvm::ReplaceInstWithInst(callInst, loadInst);
|
llvm::ReplaceInstWithInst(callInst, loadInst);
|
||||||
modifiedAny = true;
|
modifiedAny = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user