llvm/test/Transforms/InstSimplify
Hal Finkel f0f98417ca Revert "r216914 - Revert: [APFloat] Fixed a bug in method 'fusedMultiplyAdd'"
Reapply r216913, a fix for PR20832 by Andrea Di Biagio. The commit was reverted
because of buildbot failures, and credit goes to Ulrich Weigand for isolating
the underlying issue (which can be confirmed by Valgrind, which does helpfully
light up like the fourth of July). Uli explained the problem with the original
patch as:

  It seems the problem is calling multiplySignificand with an addend of category
  fcZero; that is not expected by this routine.  Note that for fcZero, the
  significand parts are simply uninitialized, but the code in (or rather, called
  from) multiplySignificand will unconditionally access them -- in effect using
  uninitialized contents.

This version avoids using a category == fcZero addend within
multiplySignificand, which avoids this problem (the Valgrind output is also now
clean).

Original commit message:

[APFloat] Fixed a bug in method 'fusedMultiplyAdd'.

When folding a fused multiply-add builtin call, make sure that we propagate the
correct result in the case where the addend is zero, and the two other operands
are finite non-zero.

Example:
  define double @test() {
    %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0.0)
    ret double %1
  }

Before this patch, the instruction simplifier wrongly folded the builtin call
in function @test to constant 'double 7.0'.
With this patch, method 'fusedMultiplyAdd' correctly evaluates the multiply and
propagates the expected result (i.e. 56.0).

Added test fold-builtin-fma.ll with the reproducible from PR20832 plus extra
test cases to verify the behavior of method 'fusedMultiplyAdd' in the presence
of NaN/Inf operands.

This fixes PR20832.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219708 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-14 19:23:07 +00:00
..
2010-12-20-Boolean.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
2011-01-14-Thread.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
2011-02-01-Vector.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
2011-09-05-InsertExtractValue.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
2011-10-27-BinOpCrash.ll Reapply commit 143028 with a fix: the problem was casting a ConstantExpr Mul 2011-10-27 19:16:21 +00:00
2011-11-23-MaskedBitsCrash.ll Fix a crash in which a multiplication was being reported as being both negative 2011-11-23 16:26:47 +00:00
2013-04-19-ConstantFoldingCrash.ll ConstantFolding: ComputeMaskedBits wants the scalar size for vectors. 2013-04-19 16:56:24 +00:00
AndOrXor.ll InstSimplify: Simplify trivial and/or of icmps 2014-09-15 08:15:28 +00:00
apint-or.ll Move optimization of some cases of (A & C1)|(B & C2) from instcombine to instsimplify. Patch by Rahul Jain, plus some last minute changes by me -- you can blame me for any bugs. 2014-06-19 03:51:46 +00:00
ashr-nop.ll Move ashr optimization from InstCombineShift to InstSimplify. 2014-07-17 06:28:15 +00:00
assume.ll Add @llvm.assume, lowering, and some basic properties 2014-07-25 21:13:35 +00:00
call-callconv.ll [SimplifyLibCalls] Library call simplification doen't work if the call site 2013-02-08 18:00:14 +00:00
call.ll Verify that we don't optimize null return checks to the nothrow_t version of operator new. 2013-09-24 18:37:49 +00:00
compare.ll InstSimplify: Move a transform from InstCombine to InstSimplify 2014-08-28 03:34:28 +00:00
dead-code-removal.ll RecursivelyDeleteTriviallyDeadInstructions() could remove 2014-04-26 05:58:11 +00:00
exact-nsw-nuw.ll InstCombine, InstSimplify: (%X /s C1) /s C2 isn't always 0 when C1 * C2 overflow 2014-10-11 10:20:01 +00:00
fast-math.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
fdiv.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
floating-point-arithmetic.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
fold-builtin-fma.ll Revert "r216914 - Revert: [APFloat] Fixed a bug in method 'fusedMultiplyAdd'" 2014-10-14 19:23:07 +00:00
gep.ll InstSimplify: Don't simplify gep X, (Y-X) to Y if types differ 2014-08-27 20:08:34 +00:00
maxmin.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
past-the-end.ll Add a testcase for some past-the-end address subtleties. 2013-02-01 19:37:52 +00:00
phi.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
ptr_diff.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
reassociate.ll Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. 2013-07-14 01:42:54 +00:00
rem.ll InstSimplify: Don't allow (x srem y) urem y -> x srem y 2014-09-17 04:16:35 +00:00
undef.ll InstSimplify: Make shift, select and GEP simplifications vector-aware. 2014-01-24 17:09:53 +00:00
vector_gep.ll InstSimplify: Make shift, select and GEP simplifications vector-aware. 2014-01-24 17:09:53 +00:00