[PATCH] D12013: [InstCombineCasts] Add cost model to decide which truncates are worth removing
Igor Laevsky via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 07:21:46 PDT 2015
igor-laevsky marked an inline comment as done.
================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:457
@@ +456,3 @@
+ // This is not a recognized instruction, but we can always truncate it by
+ // adding additional explicit trunc.
+ Cost += 1;
----------------
hfinkel wrote:
> This does not seem right. Arbitrary instructions don't commute with truncation, by which I mean trunc(arbitrary(x, y)) != arbitrary(trunc(x), trunc(y)) in general. Also, for many instructions you'd hit the llvm_unreachable in the default case in EvaluateInDifferentType.
>
>
Thanks for taking a look.
You are right, but I am not relying on trunc's associativity. When we visit unknown instruction, we will stop looking deeper into expression tree and truncate it right before problematic instruction. For example say we have something like this:
`add i64 (i64 bad_inst1(a, b), i64 bad_inst2(c, d))`
EstimateCostForTruncatedEvaluation we will return true for this expression, and EvaluateInDifferentType will do the following transform:
`add i32 (trunc (i64 bad_inst1(a, b)), trunc (i64 bad_inst2(c, d)))`
Regarding your second question. Sorry, I should have better emphasise that this revision is based on http://reviews.llvm.org/D12012 which extends default case in EvaluateInDifferentType to allow it to insert truncates.
Repository:
rL LLVM
http://reviews.llvm.org/D12013
More information about the llvm-commits
mailing list