[PATCH] D109368: [LV] Don't vectorize if we can prove RT + vector cost >= scalar cost.

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 27 02:49:57 PDT 2021


dmgreen added a comment.

> Can you point me at the test where that happens?

Hmm I don't know if there is a test. This should hopefully show it: https://godbolt.org/z/6Th4o1s5K

If you print the costs for the runtime checks, you can see they are unsimplified, with the umul being the largest part of the cost:

  Cost of 0 for RTCheck   %4 = trunc i64 %0 to i32                                              
  Cost of 10 for RTCheck   %mul31 = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 1, i32 %4)
  Cost of 0 for RTCheck   %mul.result = extractvalue { i32, i1 } %mul31, 0                      
  Cost of 0 for RTCheck   %mul.overflow = extractvalue { i32, i1 } %mul31, 1                    
  Cost of 1 for RTCheck   %5 = add i32 %2, %mul.result                                          
  Cost of 1 for RTCheck   %6 = sub i32 %2, %mul.result                                          
  Cost of 1 for RTCheck   %7 = icmp ugt i32 %6, %2                                              
  Cost of 1 for RTCheck   %8 = icmp ult i32 %5, %2                                              
  Cost of 1 for RTCheck   %9 = select i1 false, i1 %7, i1 %8                                    
  Cost of 1 for RTCheck   %10 = icmp ugt i64 %0, 4294967295                                     
  Cost of 1 for RTCheck   %11 = or i1 %9, %10                                                   
  Cost of 1 for RTCheck   %12 = or i1 %11, %mul.overflow                                        
  Cost of 1 for RTCheck   %13 = or i1 false, %12                                                
  LV: Minimum required TC for runtime checks to be profitable:28                                

I'm not sure if they should be simplified by the builder during construction, simplified prior to costing or the code to create them needs to be more precise.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109368/new/

https://reviews.llvm.org/D109368



More information about the llvm-commits mailing list