[LLVMdev] alias set collapse and LICM

Caldarale, Charles R Chuck.Caldarale at unisys.com
Mon Apr 27 15:27:28 PDT 2015


> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] 
> On Behalf Of Sanjoy Das
> Subject: [LLVMdev] alias set collapse and LICM

> declare i32 @only_reads() readonly
> declare void @escape(i32*, i32*, i32*)
> define void @f(i32 %count) {
>  entry:
>   %a = alloca i32
>   %b = alloca i32
>   %c = alloca i32
>   call void @escape(i32* %a, i32* %b, i32* %c)
>   %enter = icmp sle i32 0, %count
>   br i1 %enter, label %loop, label %exit
>  loop:
>   %idx = phi i32 [ 0, %entry ], [ %idx.inc, %loop ]
>   %idx.inc = add i32 %idx, 1
>   %take.be = icmp slt i32 %idx, %count
>   %a.load = load i32, i32* %a
>   store i32 %a.load, i32* %b
>   %v = call i32 @only_reads()
>   store i32 %v, i32* %c
>   br i1 %take.be, label %loop, label %exit
>  exit:
>   ret void
> }

> BasicAA knows that %a, %b and %c are all pairwise NoAlias, and given
> that, LICM should be able to hoist `%a.load` out of the loop.  That
> does not happen because the read only call to `@only_reads` collapses
> the alias sets for %a, %b and %c into one

Can you explain why the alias sets are collapsed into one here?  Can that collapsing simply be avoided for read-only calls without creating a second alias set?

 - Chuck

 




More information about the llvm-dev mailing list