[all-commits] [llvm/llvm-project] 36b123: [SDAG] remove use restriction in isNegatibleForFre...

RotateRight via All-commits all-commits at lists.llvm.org
Tue Dec 17 10:47:28 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 36b1232ec5f370ab9fe8fcff0458d2fca5ca9b7f
      https://github.com/llvm/llvm-project/commit/36b1232ec5f370ab9fe8fcff0458d2fca5ca9b7f
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2019-12-17 (Tue, 17 Dec 2019)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
    M llvm/test/CodeGen/AArch64/arm64-fmadd.ll
    M llvm/test/CodeGen/X86/fma-fneg-combine-2.ll

  Log Message:
  -----------
  [SDAG] remove use restriction in isNegatibleForFree() when called from getNegatedExpression()

This is an alternate fix for the bug discussed in 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 adds a hack to work-around the case where we probably no longer detect
that either multiply operand of an FMA isNegatibleForFree which is assumed to be
true when we started rewriting the expression.

Differential Revision: https://reviews.llvm.org/D70975




More information about the All-commits mailing list