Chromium Code Reviews| Index: src/IceTargetLoweringX86BaseImpl.h |
| diff --git a/src/IceTargetLoweringX86BaseImpl.h b/src/IceTargetLoweringX86BaseImpl.h |
| index 435332bbef78b3c474ec461a2d94a0472f73e45d..5b54964d5080e212c8c0278ae911a24f2777d1e6 100644 |
| --- a/src/IceTargetLoweringX86BaseImpl.h |
| +++ b/src/IceTargetLoweringX86BaseImpl.h |
| @@ -2183,11 +2183,41 @@ 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: { |
| + bool ConvertedToLea = false; |
| + if (getFlags().getAggressiveLea() && Func->getOptLevel() == Opt_2 && |
|
Jim Stichnoth
2016/07/19 21:29:08
Do you really need OptLevel=2? or is getAggressiv
manasijm
2016/07/28 18:01:39
Done.
|
| + (Ty == IceType_i32 || (Ty == IceType_i64 && Traits::Is64Bit))) { |
| + Constant *Const = llvm::dyn_cast<Constant>(Instr->getSrc(1)); |
| + if (Const != nullptr && (llvm::isa<ConstantInteger32>(Const) || |
| + llvm::isa<ConstantRelocatable>(Const))) { |
| + auto Var = legalize(Src0, Legal_Reg); |
|
Jim Stichnoth
2016/07/19 21:29:08
auto *
Also, in this case you can use legalizeToR
manasijm
2016/07/28 18:01:39
Done.
|
| + 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); |
| + |
| + ConvertedToLea = true; |
| + } /*else { // Both are Variables |
|
Jim Stichnoth
2016/07/19 21:29:09
Why is the rest of this commented out?
manasijm
2016/07/19 21:54:59
Enabling that increases code size.
And doesn't see
Jim Stichnoth
2016/07/19 22:30:29
OK. Either remove the code, or leave it in but di
manasijm
2016/07/28 18:01:39
Done.
|
| + auto Var0 = legalize(Src0, Legal_Reg); |
| + auto Var1 = legalize(Src1, Legal_Reg); |
| + auto Mem = Traits::X86OperandMem::create( |
| + Func, IceType_void, llvm::cast<Variable>(Var0), nullptr, |
|
Jim Stichnoth
2016/07/19 21:29:08
If you use legalizeToReg() as above, you won't nee
manasijm
2016/07/28 18:01:39
Done.
|
| + llvm::cast<Variable>(Var1)); |
| + |
| + T = makeReg(Ty); |
| + _lea(T, _sandbox_mem_reference(Mem)); |
| + _mov(Dest, T); |
| + |
| + ConvertedToLea = true; |
| + }*/ |
| + } |
| + if (!ConvertedToLea) { |
| + _mov(T, Src0); |
| + _add(T, Src1); |
| + _mov(Dest, T); |
| + } |
| + } break; |
| case InstArithmetic::And: |
| _mov(T, Src0); |
| _and(T, Src1); |