Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: src/IceTargetLoweringX8632.cpp

Issue 459133002: Subzero: address mode opt: Transform *(reg+const) into [reg+const]. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Address comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/address-mode-opt.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringX8632.cpp
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 26d11b9208d84dde23ce57816bb0986be1c6a69d..de033a5265c4d5c42b5feca790f01356dc847de5 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -3388,6 +3388,33 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift,
}
}
+ // Base is Base=Var+Const || Base is Base=Const+Var ==>
+ // set Base=Var, Offset+=Const
+ // Base is Base=Var-Const ==>
+ // set Base=Var, Offset-=Const
+ const InstArithmetic *ArithInst =
+ llvm::dyn_cast_or_null<const InstArithmetic>(BaseInst);
+ if (ArithInst && (ArithInst->getOp() == InstArithmetic::Add ||
+ ArithInst->getOp() == InstArithmetic::Sub)) {
+ bool IsAdd = ArithInst->getOp() == InstArithmetic::Add;
+ Variable *Var = NULL;
+ ConstantInteger *Const = NULL;
+ if (Variable *VariableOperand =
+ llvm::dyn_cast<Variable>(ArithInst->getSrc(0))) {
+ Var = VariableOperand;
+ Const = llvm::dyn_cast<ConstantInteger>(ArithInst->getSrc(1));
+ } else if (IsAdd) {
+ Const = llvm::dyn_cast<ConstantInteger>(ArithInst->getSrc(0));
+ Var = llvm::dyn_cast<Variable>(ArithInst->getSrc(1));
+ }
+ if (!(Const && Var)) {
+ break;
+ }
+ Base = Var;
+ Offset += IsAdd ? Const->getValue() : -Const->getValue();
+ continue;
+ }
+
// Index is Index=Var<<Const && Const+Shift<=3 ==>
// Index=Var, Shift+=Const
@@ -3398,15 +3425,6 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift,
// swap(Index,Base)
// Similar for Base=Const*Var and Base=Var<<Const
- // Base is Base=Var+Const ==>
- // set Base=Var, Offset+=Const
-
- // Base is Base=Const+Var ==>
- // set Base=Var, Offset+=Const
-
- // Base is Base=Var-Const ==>
- // set Base=Var, Offset-=Const
-
// Index is Index=Var+Const ==>
// set Index=Var, Offset+=(Const<<Shift)
@@ -4039,7 +4057,7 @@ void TargetX8632::postLower() {
template <> void ConstantInteger::emit(GlobalContext *Ctx) const {
Ostream &Str = Ctx->getStrEmit();
- Str << getValue();
+ Str << (int64_t) getValue();
}
template <> void ConstantFloat::emit(GlobalContext *Ctx) const {
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/address-mode-opt.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698