[PATCH] Add another run of ARM Thumb2SizeReduction pass with -Oz

Pete Cooper peter_cooper at apple.com
Thu Mar 12 11:52:05 PDT 2015


Hi Renato
> On Mar 12, 2015, at 4:07 AM, Renato Golin <renato.golin at linaro.org> wrote:
> 
> On 11 March 2015 at 23:00, Pete Cooper <peter_cooper at apple.com> wrote:
>> This patch schedules another pass of Thumb2SizeReduction before the PostRA
>> scheduler.  This pass is only for functions with minsize set on them.  It
>> results in the mov being converted to Thumb2 before the PostRA scheduler and
>> so the code now becomes
> 
> Hi Pete,
> 
> +  if (getOptLevel() != CodeGenOpt::None && !getARMSubtarget().isThumb1Only())
You’re right.  I’ve changed it to effectively be (getOptLevel() != CodeGenOpt::None && T2).  Then we have to run the pass over the functions and identify those functions which are -Oz.  Looks like -Oz is independent of -O0, but we probably still don’t want to even shrink the code if -O0 is set.
> 
> This doesn't guarantee (Oz && T2). Wouldn't you have to be specific at
> least regarding CodeGenOpt?
> 
> Also, the same pass has already been added in some cases on the code
> above, you don't want to add two identical passes, even if they have
> different parameters. Maybe create a boolean OnlyMinSize from opt+t2
> flags, and pass it to the already existing addPass()?
Agreed.  I’ve changed that snippet to be:

    bool RestrictIT = getARMSubtarget().restrictIT();
    if (RestrictIT || getARMSubtarget().isThumb2()) {
      // In v8, IfConversion depends on Thumb instruction widths.
      // We also want to aggressively form Thumb2 instructions on functions
      // with minsize (-Oz).
      bool OnlyMinSize = !RestrictIT;
      addPass(createThumb2SizeReductionPass(OnlyMinSize));
    }

I know I could have only one bool here, not 2, but I felt like this was easier to understand.  If you prefer I can make it a little shorter.
> 
> The tests are good and the rest looks good to me. Thanks!
Thanks!  I appreciate the review.

Pete


> 
> cheers,
> --renato

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150312/ebb8b8c9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reduce.diff
Type: application/octet-stream
Size: 4754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150312/ebb8b8c9/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150312/ebb8b8c9/attachment-0001.html>


More information about the llvm-commits mailing list