[LLVMdev] AArch64AddressTypePromotion does nothing (was Re: Contributing the Apple ARM64 compiler backend)

Quentin Colombet qcolombet at apple.com
Tue Jul 1 00:40:42 PDT 2014


> On Jun 30, 2014, at 4:19 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
> 
>> On 2014-Jun-27, at 16:30, Jim Grosbach <grosbach at apple.com> wrote:
>> 
>> AArch64AddressTypePromotion.cpp does a fair bit of work to help make these things work out well. It could probably be generalized for non-AArch64 targets as per the comment in the file header.
> 
> I spent some time today generalizing AArch64AddressTypePromotion (I'll
> send the patches when they're ready), but in the process discovered
> that this pass does nothing (!) right now.

I am not surprised as this pass has been superseded by the refactoring of the handling of addressing mode in CodeGenPrepare (r200947).
If you disable CGP, you will see this pass doing something :).

In fact, evaluating if this pass is still useful is in our todo list: <rdar://problem/16005447>.

Cheers,
-Quentin

>  I assume this bug was
> introduced when we changed the semantics of `Use` (IIRC, ARM64 was
> still private at the time).
> 
> After the tiny patch inline below, the code looks even better:
> 
> --- old.s	2014-06-30 16:12:52.000000000 -0700
> +++ new.s	2014-06-30 16:13:24.000000000 -0700
> @@ -5,12 +5,10 @@
> _foo:                                   ; @foo
> 	.cfi_startproc
> ; BB#0:                                 ; %entry
> -	add	w8, w1, #1              ; =1
> -	add	w9, w1, #2              ; =2
> -	ldr	w8, [x0, w8, sxtw #2]
> -	ldr	w9, [x0, w9, sxtw #2]
> -	add	 w8, w9, w8
> -	str	w8, [x0, w1, sxtw #2]
> +	add	x8, x0, w1, sxtw #2
> +	ldp	w9, w10, [x8, #4]
> +	add	 w9, w10, w9
> +	str	 w9, [x8]
> 	ret
> 	.cfi_endproc
> 
> I'll commit the fix once I've written up a testcase.
> 
> diff --git a/lib/Target/AArch64/AArch64AddressTypePromotion.cpp b/lib/Target/AArch64/AArch64AddressTypePromotion.cpp
> index 04906f6..bcce295 100644
> --- a/lib/Target/AArch64/AArch64AddressTypePromotion.cpp
> +++ b/lib/Target/AArch64/AArch64AddressTypePromotion.cpp
> @@ -212,12 +212,12 @@ static bool shouldSExtOperand(const Instruction *Inst, int OpIdx) {
> bool
> AArch64AddressTypePromotion::shouldConsiderSExt(const Instruction *SExt) const {
>   if (SExt->getType() != ConsideredSExtType)
>     return false;
> 
> -  for (const Use &U : SExt->uses()) {
> -    if (isa<GetElementPtrInst>(*U))
> +  for (const User *U : SExt->users()) {
> +    if (isa<GetElementPtrInst>(U))
>       return true;
>   }
> 
>   return false;
> }
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list