[PATCH] D76439: [SDAG] fix crash in getNegatedExpression() from altered number of uses

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 23 13:06:38 PDT 2020


spatel added a comment.

In D76439#1935992 <https://reviews.llvm.org/D76439#1935992>, @steven.zhang wrote:

> We need to update the cost as they are pair. For now, it returns the first operand immediately if it is not expensive. But it could be neutral. And we will have problems if the cost of second operand is cheap. Because we should return cheap, but now, it is neutral. Does it make sense ?


Sorry, but I'm not understanding. With this patch we have fneg (fmul/fdiv X, Y):

1. CostX == cheaper == 2; CostY == cheaper == 2 --> negate X
2. CostX == cheaper == 2; CostY == neutral == 1 --> negate X
3. CostX == neutral == 1; CostY == cheaper ==2 --> negate Y
4. CostX == neutral == 1; CostY == neutral == 1 --> negate X

But I have an alternate idea to avoid the crash that is probably a better fix given the current logic:
D76638 <https://reviews.llvm.org/D76638>


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

https://reviews.llvm.org/D76439





More information about the llvm-commits mailing list