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

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 11:04:24 PST 2017


qcolombet added a comment.

Hi,

I didn't look at the test case you're adding, but I guess it exposes the problem. Could you describe how the cost becomes negative?

I have a hard time picturing that and I want to be sure we are not missing something.
Indeed, at the beginning TotalCreatedInstsCost is CreatedInstsCost + NewCreatedInstsCost. Both operands are unsigned values.
Thus TotalCreatedInstsCost > 0.
Then TotalCreatedInstsCost -= ExtCost with ExtCost being either 0 or 1.
Thus, TotalCreatedInstsCost will get < 0 if it was TotalCreatedInstsCost == 0 before that operation and ExtCost is 1. Given TotalCreatedInstsCost == 0, the created instructions are all free.

First, I am not saying that's impossible, I want to be sure this is what we want.
Second, TotalCreatedInstsCost becomes a benefit and I wonder if we want to keep propagating it instead of ceiling it at 0.

Thanks,
-Quentin


https://reviews.llvm.org/D28871





More information about the llvm-commits mailing list