Re: [llvm-dev] Replication -O3 optimizations manually

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Replication -O3 optimizations manually

David Jones via llvm-dev

Hi,

 

I’m having a very similar question to this thread, about replicating the O3 optimization processing manually using opt.

 

This is my setup:

 

Process A:

  1. clang -O1 -S -emit-llvm main.c -o main.ll
  2. opt -O3 main.ll -o main-opt1.ll
  3. clang -O1 main-opt1.ll -o main-opt1

 

Process B:

  1. clang -O1 -S -emit-llvm main.c -o main.ll
2.  opt [opt flags given by command ‘opt -O3 -disable-output -debug-pass=Arguments main.ll’] main.ll -o main-opt2.ll
  1. clang -O1 main-opt2.ll -o main-opt2

 

I tried this with a set of programs and I noticed the execution time of main-opt2 is often much slower than main-opt1. While ‘main.ll’ is the same, ‘main-opt1.ll’ is different to ‘main-opt2.ll’. May I get some suggestions what I should put for opt (to replace the command in the brackets), so that the two process would have identical effects? Any help would be much appreciated.

 

Thanks,

Han

 

 

 


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Replication -O3 optimizations manually

David Jones via llvm-dev
Hi,

it is not possible (or at least difficult) to entirely get the same
behavior. This is because the pass manager builder for the
optimization levels add the passes with additional options. See
PassManagerBuilder.cpp. For instance, the Loop Unroll pass takes the
following options:

LoopUnroll(int OptLevel = 2, Optional<unsigned> Threshold = None,
             Optional<unsigned> Count = None,
             Optional<bool> AllowPartial = None, Optional<bool> Runtime = None,
             Optional<bool> UpperBound = None,
             Optional<bool> AllowPeeling = None)

It is added twice in the typical pipeline: Once to only unroll loops
completely, and another time to allow more general unrolling. What
adding it to the pass pipeline using opt -loop-unroll, it is added
with the default options.
Most passes have command line options to control this behaviour as
well (such as -unroll-runtime), but this would apply to both instances
of the pass. You would have to invoke opt multiple times with
different options for each instance, but this would also split the
module/function/loop pass hierarchy and different preserved analysis
passes (such as alias analysis which have to be re-added again).

Michael



Am Fr., 19. Okt. 2018 um 14:18 Uhr schrieb Han Cui via llvm-dev
<[hidden email]>:

>
> Hi,
>
>
>
> I’m having a very similar question to this thread, about replicating the O3 optimization processing manually using opt.
>
>
>
> This is my setup:
>
>
>
> Process A:
>
> clang -O1 -S -emit-llvm main.c -o main.ll
> opt -O3 main.ll -o main-opt1.ll
> clang -O1 main-opt1.ll -o main-opt1
>
>
>
> Process B:
>
> clang -O1 -S -emit-llvm main.c -o main.ll
>
> 2.  opt [opt flags given by command ‘opt -O3 -disable-output -debug-pass=Arguments main.ll’] main.ll -o main-opt2.ll
>
> clang -O1 main-opt2.ll -o main-opt2
>
>
>
> I tried this with a set of programs and I noticed the execution time of main-opt2 is often much slower than main-opt1. While ‘main.ll’ is the same, ‘main-opt1.ll’ is different to ‘main-opt2.ll’. May I get some suggestions what I should put for opt (to replace the command in the brackets), so that the two process would have identical effects? Any help would be much appreciated.
>
>
>
> Thanks,
>
> Han
>
>
>
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Replication -O3 optimizations manually

David Jones via llvm-dev
In reply to this post by David Jones via llvm-dev
Hi Han,

What is your ultimate goal here?

Cheers,
Philip

On Fri, Oct 19, 2018 at 9:17 PM Han Cui via llvm-dev <[hidden email]> wrote:

Hi,

 

I’m having a very similar question to this thread, about replicating the O3 optimization processing manually using opt.

 

This is my setup:

 

Process A:

  1. clang -O1 -S -emit-llvm main.c -o main.ll
  2. opt -O3 main.ll -o main-opt1.ll
  3. clang -O1 main-opt1.ll -o main-opt1

 

Process B:

  1. clang -O1 -S -emit-llvm main.c -o main.ll
2.  opt [opt flags given by command ‘opt -O3 -disable-output -debug-pass=Arguments main.ll’] main.ll -o main-opt2.ll
  1. clang -O1 main-opt2.ll -o main-opt2

 

I tried this with a set of programs and I noticed the execution time of main-opt2 is often much slower than main-opt1. While ‘main.ll’ is the same, ‘main-opt1.ll’ is different to ‘main-opt2.ll’. May I get some suggestions what I should put for opt (to replace the command in the brackets), so that the two process would have identical effects? Any help would be much appreciated.

 

Thanks,

Han

 

 

 

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Replication -O3 optimizations manually

David Jones via llvm-dev

Hi Philip,


I would like to try different pass sequences with opt and see how they affect program optimization, and I was thinking replicating the O3 sequence would be a start point. 


Thanks,

Han


From: Philip Pfaffe <[hidden email]>
Sent: 21 October 2018 11:36:07
To: Han Cui
Cc: llvm-dev
Subject: Re: [llvm-dev] Replication -O3 optimizations manually
 
Hi Han,

What is your ultimate goal here?

Cheers,
Philip

On Fri, Oct 19, 2018 at 9:17 PM Han Cui via llvm-dev <[hidden email]> wrote:

Hi,

 

I’m having a very similar question to this thread, about replicating the O3 optimization processing manually using opt.

 

This is my setup:

 

Process A:

  1. clang -O1 -S -emit-llvm main.c -o main.ll
  2. opt -O3 main.ll -o main-opt1.ll
  3. clang -O1 main-opt1.ll -o main-opt1

 

Process B:

  1. clang -O1 -S -emit-llvm main.c -o main.ll
2.  opt [opt flags given by command ‘opt -O3 -disable-output -debug-pass=Arguments main.ll’] main.ll -o main-opt2.ll
  1. clang -O1 main-opt2.ll -o main-opt2

 

I tried this with a set of programs and I noticed the execution time of main-opt2 is often much slower than main-opt1. While ‘main.ll’ is the same, ‘main-opt1.ll’ is different to ‘main-opt2.ll’. May I get some suggestions what I should put for opt (to replace the command in the brackets), so that the two process would have identical effects? Any help would be much appreciated.

 

Thanks,

Han

 

 

 

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev