[PATCH] D28871: [CodeGenPrep]No negative cost in the ExtLd promotion

Jun Bum Lim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 12:21:48 PST 2017


junbuml added a comment.

Hi Quentin,

I believe the test case I added shows the case where TotalCreatedInstsCost becomes negative :

- In the very first call of extLdPromotion(), CreatedInstsCost is 0, ExtCost is 1 for  the sext (%r), and NewCreatedInstsCost after promotion is 0 because the cost of sext becomes free after moving it up before %shl2.
- Therefore, TotalCreatedInstsCost -= ExtCost becomes negative.

I think propagating the negative value of TotalCreatedInstsCost is also possible, but I think ceiling it to 0 is simple and conservative enough to handle this corner case.

This patch is a small particle from https://reviews.llvm.org/D27853, which should be rebased based on this.

Thanks,
Jun


https://reviews.llvm.org/D28871





More information about the llvm-commits mailing list