[PATCH] Add ExtractValue instruction to SimplifyCFG's ComputeSpeculationCost

Louis Gerbarg lgg at apple.com
Mon Apr 28 14:23:42 PDT 2014


The attached patch deals with some missed opportunities in SimplifyCFG that are preventing optimizations further down the pipeline. In particular having saturating math operations end up as a select in the same block instead of multiple blocks makes it possible to generate better code on architectures with conditional selects.

For example on ARM64:

unsigned f(unsigned a, unsigned b) {
  unsigned c = a + b;
  if (c < a)
    return 0;
  
  return c;
}

currently compiles to:

        movz    w8, #0                                                          
        adds    w9, w0, w1                                                      
        csinc   w10, wzr, wzr, cc                                               
        tst     x10, #0x1                                                       
        csel    w0, w8, w9, ne                                                  
        ret   

with the attached patch it compiles to:

        adds    w8, w0, w1                                                      
        csel    w0, wzr, w8, cs                                                 
        ret

ARMv7 should also see similar improvements once I add support for a few missing intrinsics that clang generates when compiling the above code.

Louis

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-ExtractValue-instruction-to-SimplifyCFG-s-Comput.patch
Type: application/octet-stream
Size: 2243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140428/094c7081/attachment.obj>


More information about the llvm-commits mailing list