Chromium Code Reviews| Index: src/IceTargetLoweringX86BaseImpl.h |
| diff --git a/src/IceTargetLoweringX86BaseImpl.h b/src/IceTargetLoweringX86BaseImpl.h |
| index 2acd3312d9b9b74c6a30853cc7cabcab2d2ff59d..e2c96f8b9e6b5c72a75a13b5d95b0b6acbb29c95 100644 |
| --- a/src/IceTargetLoweringX86BaseImpl.h |
| +++ b/src/IceTargetLoweringX86BaseImpl.h |
| @@ -2183,11 +2183,28 @@ 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() && |
|
Jim Stichnoth
2016/07/29 14:27:26
I wonder if this conditional would be clearer as s
manasijm
2016/08/01 19:36:21
Done.
|
| + (Ty == IceType_i32 || (Ty == IceType_i64 && Traits::Is64Bit))) { |
| + Constant *Const = llvm::dyn_cast<Constant>(Instr->getSrc(1)); |
|
Jim Stichnoth
2016/07/29 14:27:26
auto *Const
manasijm
2016/08/01 19:36:21
Done.
|
| + if (Const != nullptr && (llvm::isa<ConstantInteger32>(Const) || |
| + llvm::isa<ConstantRelocatable>(Const))) { |
| + auto *Var = legalizeToReg(Src0); |
| + auto *Mem = |
| + Traits::X86OperandMem::create(Func, IceType_void, Var, Const); |
| + T = makeReg(Ty); |
| + _lea(T, _sandbox_mem_reference(Mem)); |
| + _mov(Dest, T); |
| + ConvertedToLea = true; |
|
Jim Stichnoth
2016/07/29 14:27:26
I would just put a "break;" here, and remove Conve
manasijm
2016/08/01 19:36:21
Done.
|
| + } |
| + } |
| + if (!ConvertedToLea) { |
| + _mov(T, Src0); |
| + _add(T, Src1); |
| + _mov(Dest, T); |
| + } |
| + } break; |
| case InstArithmetic::And: |
| _mov(T, Src0); |
| _and(T, Src1); |