[PATCH] D70975: [SDAG] remove use restriction in isNegatibleForFree() when called from getNegatedExpression()

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 11:48:01 PST 2019


spatel created this revision.
spatel added reviewers: dstuttard, lebedev.ri, craig.topper, arsenm.
Herald added subscribers: hiraditya, wdng, mcrosier.
Herald added a project: LLVM.

This is an alternate fix for the bug discussed in D70595 <https://reviews.llvm.org/D70595>. This also includes minimal tests for other in-tree targets to show the problem more generally.

We check the number of uses as a predicate for whether some value is free to negate, but that use count can change as we rewrite the expression in getNegatedExpression(). So something that was marked free to negate during the cost evaluation phase becomes not free to negate during the rewrite phase (or the inverse - something that was not free becomes free). This can lead to a crash/assert because we expect that everything in an expression that is negatible to be handled in the corresponding code within getNegatedExpression().

This patch skips the use check during the rewrite phase. So we determine that some expression isNegatibleForFree (identically to without this patch), but during the rewrite, don't rely on use counts to decide how to create the optimal expression.


https://reviews.llvm.org/D70975

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/test/CodeGen/AArch64/arm64-fmadd.ll
  llvm/test/CodeGen/X86/fma-fneg-combine-2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70975.231952.patch
Type: text/x-patch
Size: 11482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191203/2946d56b/attachment.bin>


More information about the llvm-commits mailing list