[PATCH] [PATCH]Select wide immediate offset into [Base+XReg] addressing mode

Chad Rosier mcrosier at codeaurora.org
Mon Oct 13 06:46:30 PDT 2014


================
Comment at: lib/Target/AArch64/AArch64ISelDAGToDAG.cpp:789
@@ -788,3 +803,1 @@
 
-  // We don't want to match immediate adds here, because they are better lowered
-  // to the register-immediate addressing modes.
----------------
HaoLiu wrote:
> mcrosier wrote:
> > Thanks for the update, Hao.  I'm still particularly concerned that this bit of logic is being removed entirely.  Can you please elaborate on why this is being removed?
> Sure.
> 
> Firstly, only RHS can be constant. There is no situation that both LHS and RHS are constants (Such ADD will be optimized). Also, when there is only one constant operand in ADD, it will always adjust the constant to the RHS operand  (See the test in my patch @t9). So my patch, only checks whether RHS is a constant node.
> 
> Then, the original logic checks and returns when the operand is constant. My patch improves this logic. When the constant is too wide to be encoded in [Register+Immdediate] addressing mode or in ADD/SUB, it will be selected in [Register+Register] addressing mode. Otherwise, it will still return false as original logic.
> 
> Thanks,
> -Hao
Now I understand; the old logic was misleading.  If the constant is always canonicalized to the RHS, then this LGTM.

================
Comment at: test/CodeGen/AArch64/arm64-addrmode.ll:97
@@ +96,3 @@
+; CHECK-NEXT: ldr xzr, [x0, [[REG]]]
+  %1 = add i64 -305463297, %a   ;-305463297 is 0xffffffffedcaffff
+  %2 = inttoptr i64 %1 to i64*
----------------
Ok, constant always canonicalized to RHS.

http://reviews.llvm.org/D5477






More information about the llvm-commits mailing list