[PATCH] Allow InstCombiner to eliminate truncates even if it will require inserting additional instructions
igor at azulsystems.com
Fri Jun 19 07:53:25 PDT 2015
Hi reames, sanjoy, majnemer,
Currently InstCombiner can eliminate truncate when entire expression tree can be evaluated in a narrower type without adding additional instructions.
However there are some cases when it is profitable to evaluate expression in a narrower type, even if it will require adding additional instructions. (See test case in the patch)
In this patch I split "CanEvaluateTruncated" function into two: "EstimateCostForTruncatedEvaluation" and "IsProfitableToEvaluateTruncated". First one is basically an old "CanEvaluateTruncated", but it also calculates cost for truncating expression tree. Second function basically just calls "EstimateCostForTruncatedEvaluation" and compares cost of the truncation with some threshold.
Currently cost model is very simple - we want to truncate expression tree only if we will remove more instructions than we will add. Probably it can be somehow adjusted in the future.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 11111 bytes
Desc: not available
More information about the llvm-commits