Index: src/IceTargetLoweringX86BaseImpl.h |
diff --git a/src/IceTargetLoweringX86BaseImpl.h b/src/IceTargetLoweringX86BaseImpl.h |
index a9dc7a7e75496b3d28fb654c2188c7b6cc2ed0da..4909f9df8406d7681da3966acacbf25a49cfbf38 100644 |
--- a/src/IceTargetLoweringX86BaseImpl.h |
+++ b/src/IceTargetLoweringX86BaseImpl.h |
@@ -2184,11 +2184,24 @@ void TargetX86Base<TraitsType>::lowerArithmetic(const InstArithmetic *Instr) { |
case InstArithmetic::_num: |
llvm_unreachable("Unknown arithmetic operator"); |
break; |
- case InstArithmetic::Add: |
- _mov(T, Src0); |
- _add(T, Src1); |
- _mov(Dest, T); |
- break; |
+ case InstArithmetic::Add: { |
John
2016/07/11 21:28:43
LEA are pretty powerful. You can use it as a gener
|
+ Constant *Const = llvm::dyn_cast<Constant>(Instr->getSrc(1)); |
+ if (getFlags().getAggressiveLea() && Func->getOptLevel() == Opt_2 && |
+ Const != nullptr && (llvm::isa<ConstantInteger32>(Const) || |
+ llvm::isa<ConstantRelocatable>(Const)) && |
+ (Ty == IceType_i32 || Ty == IceType_i64)) { |
+ auto Var = legalize(Src0, Legal_Reg); |
+ auto Mem = Traits::X86OperandMem::create( |
+ Func, IceType_void, llvm::cast<Variable>(Var), Const); |
+ T = makeReg(Ty); |
+ _lea(T, _sandbox_mem_reference(Mem)); |
+ _mov(Dest, T); |
+ } else { |
+ _mov(T, Src0); |
+ _add(T, Src1); |
+ _mov(Dest, T); |
+ } |
+ } break; |
case InstArithmetic::And: |
_mov(T, Src0); |
_and(T, Src1); |