From ae3a0be92e33bc716722aa600983fc1535acb122 Mon Sep 17 00:00:00 2001
From: Dan Gohman
Date: Thu, 4 Jun 2009 22:49:04 +0000
Subject: [PATCH] Split the Add, Sub, and Mul instruction opcodes into separate
integer and floating-point opcodes, introducing FAdd, FSub, and FMul.
For now, the AsmParser, BitcodeReader, and IRBuilder all preserve
backwards compatability, and the Core LLVM APIs preserve backwards
compatibility for IR producers. Most front-ends won't need to change
immediately.
This implements the first step of the plan outlined here:
http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72897 91177308-0d34-0410-b5e6-96231b3b80d8
---
docs/LangRef.html | 135 +-
include/llvm/Constants.h | 4 +
include/llvm/InstrTypes.h | 13 +-
include/llvm/Instruction.def | 113 +-
include/llvm/Support/ConstantFolder.h | 12 +
include/llvm/Support/IRBuilder.h | 18 +
include/llvm/Support/NoFolder.h | 9 +
include/llvm/Support/PatternMatch.h | 47 +
include/llvm/Support/TargetFolder.h | 12 +
lib/Analysis/ValueTracking.cpp | 2 +-
lib/AsmParser/LLLexer.cpp | 4 +-
lib/AsmParser/LLParser.cpp | 12 +-
lib/AsmParser/LLToken.h | 3 +-
lib/Bitcode/Reader/BitcodeReader.cpp | 9 +-
lib/Bitcode/Writer/BitcodeWriter.cpp | 9 +-
lib/CodeGen/SelectionDAG/FastISel.cpp | 24 +-
.../SelectionDAG/SelectionDAGBuild.cpp | 46 +-
lib/CodeGen/SelectionDAG/SelectionDAGBuild.h | 9 +-
lib/ExecutionEngine/ExecutionEngine.cpp | 21 +-
lib/ExecutionEngine/Interpreter/Execution.cpp | 56 +-
lib/ExecutionEngine/JIT/JITEmitter.cpp | 3 +
lib/Target/CBackend/CBackend.cpp | 35 +-
lib/Target/CppBackend/CPPBackend.cpp | 9 +
lib/Target/MSIL/MSILWriter.cpp | 8 +-
lib/Transforms/Scalar/GVN.cpp | 6 +-
lib/Transforms/Scalar/GVNPRE.cpp | 9 +-
lib/Transforms/Scalar/IndVarSimplify.cpp | 2 +-
.../Scalar/InstructionCombining.cpp | 216 +++-
lib/Transforms/Scalar/LoopStrengthReduce.cpp | 3 +-
lib/Transforms/Scalar/SimplifyLibCalls.cpp | 2 +-
lib/Transforms/Utils/SimplifyCFG.cpp | 8 +-
lib/VMCore/ConstantFold.cpp | 23 +-
lib/VMCore/Constants.cpp | 49 +-
lib/VMCore/Instruction.cpp | 19 +-
lib/VMCore/Instructions.cpp | 70 +-
test/Analysis/ScalarEvolution/sext-iv-0.ll | 2 +-
test/Analysis/ScalarEvolution/sext-iv-1.ll | 8 +-
test/Analysis/ScalarEvolution/trip-count4.ll | 2 +-
.../Assembler/2002-04-07-HexFloatConstants.ll | 2 +-
test/Assembler/2002-04-07-InfConstant.ll | 2 +-
test/CodeGen/ARM/2007-01-19-InfiniteLoop.ll | 8 +-
test/CodeGen/ARM/2009-02-27-SpillerBug.ll | 280 ++--
test/CodeGen/ARM/2009-03-07-SpillerBug.ll | 56 +-
test/CodeGen/ARM/2009-04-08-FloatUndef.ll | 4 +-
test/CodeGen/ARM/cse-libcalls.ll | 2 +-
test/CodeGen/ARM/fixunsdfdi.ll | 2 +-
test/CodeGen/ARM/fnmul.ll | 4 +-
test/CodeGen/ARM/fparith.ll | 16 +-
test/CodeGen/ARM/fpmem.ll | 4 +-
test/CodeGen/ARM/illegal-vector-bitcast.ll | 2 +-
test/CodeGen/ARM/vfp.ll | 8 +-
.../CBackend/2006-12-11-Float-Bitcast.ll | 4 +-
.../2008-10-21-PPCLongDoubleConstant.ll | 2 +-
test/CodeGen/CBackend/vectors.ll | 2 +-
test/CodeGen/CellSPU/dp_farith.ll | 48 +-
test/CodeGen/CellSPU/fneg-fabs.ll | 8 +-
test/CodeGen/CellSPU/sp_farith.ll | 44 +-
test/CodeGen/Generic/2006-07-03-schedulers.ll | 14 +-
.../Generic/2007-05-15-InfiniteRecursion.ll | 6 +-
.../Generic/2008-02-04-ExtractSubvector.ll | 2 +-
test/CodeGen/Generic/2008-02-25-NegateZero.ll | 4 +-
.../Generic/2008-02-26-NegatableCrash.ll | 8 +-
test/CodeGen/Generic/fneg-fabs.ll | 4 +-
test/CodeGen/Generic/print-arith-fp.ll | 6 +-
test/CodeGen/Generic/select.ll | 8 +-
test/CodeGen/Generic/storetrunc-fp.ll | 2 +-
test/CodeGen/Generic/v-split.ll | 2 +-
test/CodeGen/Generic/vector.ll | 20 +-
test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll | 2 +-
test/CodeGen/Mips/2008-07-06-fadd64.ll | 2 +-
test/CodeGen/Mips/2008-07-22-Cstpool.ll | 4 +-
test/CodeGen/Mips/2008-07-23-fpcmp.ll | 2 +-
test/CodeGen/Mips/2008-08-03-fabs64.ll | 2 +-
test/CodeGen/Mips/2008-11-10-xint_to_fp.ll | 8 +-
.../PowerPC/2006-01-11-darwin-fp-argument.ll | 2 +-
.../2006-10-11-combiner-aa-regression.ll | 6 +-
.../PowerPC/2007-03-30-SpillerCrash.ll | 88 +-
.../PowerPC/2007-11-19-VectorSplitting.ll | 4 +-
test/CodeGen/PowerPC/2008-07-15-Fabs.ll | 8 +-
test/CodeGen/PowerPC/2008-07-17-Fneg.ll | 2 +-
.../PowerPC/2008-09-12-CoalescerBug.ll | 40 +-
.../PowerPC/2008-10-28-UnprocessedNode.ll | 6 +-
test/CodeGen/PowerPC/2008-10-28-f128-i32.ll | 6 +-
test/CodeGen/PowerPC/buildvec_canonicalize.ll | 2 +-
test/CodeGen/PowerPC/fma.ll | 40 +-
test/CodeGen/PowerPC/fnabs.ll | 2 +-
test/CodeGen/PowerPC/fneg.ll | 8 +-
test/CodeGen/PowerPC/int-fp-conv-1.ll | 2 +-
test/CodeGen/PowerPC/itofp128.ll | 2 +-
test/CodeGen/PowerPC/mem-rr-addr-mode.ll | 4 +-
.../CodeGen/PowerPC/multiple-return-values.ll | 2 +-
test/CodeGen/PowerPC/ppcf128-1-opt.ll | 6 +-
test/CodeGen/PowerPC/ppcf128-1.ll | 6 +-
test/CodeGen/PowerPC/ppcf128-2.ll | 2 +-
test/CodeGen/PowerPC/ppcf128-4.ll | 4 +-
test/CodeGen/PowerPC/return-val-i128.ll | 2 +-
test/CodeGen/PowerPC/unsafe-math.ll | 4 +-
test/CodeGen/PowerPC/vec_fneg.ll | 2 +-
test/CodeGen/PowerPC/vec_splat.ll | 2 +-
test/CodeGen/PowerPC/vec_zero.ll | 2 +-
test/CodeGen/PowerPC/vector.ll | 20 +-
.../SPARC/2006-01-22-BitConvertLegalize.ll | 4 +-
.../CodeGen/X86/2005-05-08-FPStackifierPHI.ll | 8 +-
test/CodeGen/X86/2006-05-25-CycleInDAG.ll | 2 +-
test/CodeGen/X86/2007-01-08-InstrSched.ll | 14 +-
test/CodeGen/X86/2007-01-13-StackPtrIndex.ll | 50 +-
test/CodeGen/X86/2007-03-01-SpillerCrash.ll | 22 +-
.../X86/2007-04-11-InlineAsmVectorResult.ll | 2 +-
test/CodeGen/X86/2007-04-24-VectorCrash.ll | 18 +-
.../X86/2007-06-29-VecFPConstantCSEBug.ll | 4 +-
test/CodeGen/X86/2007-07-10-StackerAssert.ll | 2 +-
.../CodeGen/X86/2007-09-18-ShuffleXformBug.ll | 2 +-
test/CodeGen/X86/2007-10-12-SpillerUnfold1.ll | 42 +-
test/CodeGen/X86/2007-11-02-BadAsm.ll | 4 +-
test/CodeGen/X86/2007-11-06-InstrSched.ll | 4 +-
.../CodeGen/X86/2007-11-30-LoadFolding-Bug.ll | 4 +-
.../CodeGen/X86/2007-12-11-FoldImpDefSpill.ll | 2 +-
.../X86/2008-01-16-FPStackifierAssert.ll | 14 +-
test/CodeGen/X86/2008-02-06-LoadFoldingBug.ll | 4 +-
test/CodeGen/X86/2008-02-08-LoadFoldingBug.ll | 16 +-
.../CodeGen/X86/2008-02-27-DeadSlotElimBug.ll | 12 +-
test/CodeGen/X86/2008-02-27-PEICrash.ll | 12 +-
test/CodeGen/X86/2008-03-18-CoalescerBug.ll | 4 +-
test/CodeGen/X86/2008-03-25-TwoAddrPassBug.ll | 10 +-
test/CodeGen/X86/2008-07-19-movups-spills.ll | 1122 ++++++++---------
test/CodeGen/X86/2008-07-23-VSetCC.ll | 6 +-
test/CodeGen/X86/2008-08-23-X86-64AsmBug.ll | 2 +-
test/CodeGen/X86/2008-10-27-CoalescerBug.ll | 4 +-
test/CodeGen/X86/2008-11-03-F80VAARG.ll | 2 +-
test/CodeGen/X86/2008-12-05-SpillerCrash.ll | 24 +-
test/CodeGen/X86/2009-01-16-UIntToFP.ll | 4 +-
test/CodeGen/X86/2009-02-12-SpillerBug.ll | 6 +-
test/CodeGen/X86/2009-02-25-CommuteBug.ll | 2 +-
.../X86/2009-03-03-BitcastLongDouble.ll | 2 +-
test/CodeGen/X86/2009-03-09-SpillerBug.ll | 2 +-
test/CodeGen/X86/2009-03-12-CPAlignBug.ll | 8 +-
test/CodeGen/X86/break-anti-dependencies.ll | 20 +-
test/CodeGen/X86/coalescer-commute1.ll | 2 +-
test/CodeGen/X86/coalescer-commute2.ll | 2 +-
test/CodeGen/X86/coalescer-commute4.ll | 4 +-
test/CodeGen/X86/complex-fca.ll | 2 +-
test/CodeGen/X86/constant-pool-remat-0.ll | 4 +-
test/CodeGen/X86/extract-combine.ll | 6 +-
test/CodeGen/X86/fabs.ll | 2 +-
test/CodeGen/X86/fast-isel.ll | 8 +-
test/CodeGen/X86/fold-pcmpeqd-0.ll | 32 +-
test/CodeGen/X86/fold-pcmpeqd-2.ll | 16 +-
test/CodeGen/X86/fp-in-intregs.ll | 2 +-
test/CodeGen/X86/fp-stack-compare.ll | 2 +-
test/CodeGen/X86/fp_constant_op.ll | 8 +-
test/CodeGen/X86/fp_load_fold.ll | 8 +-
test/CodeGen/X86/fsxor-alignment.ll | 4 +-
test/CodeGen/X86/full-lsr.ll | 4 +-
.../CodeGen/X86/illegal-vector-args-return.ll | 4 +-
test/CodeGen/X86/inline-asm-fpstack.ll | 2 +-
test/CodeGen/X86/inline-asm-mrv.ll | 2 +-
test/CodeGen/X86/inline-asm-x-scalar.ll | 2 +-
test/CodeGen/X86/iv-users-in-other-loops.ll | 122 +-
test/CodeGen/X86/masked-iv-safe.ll | 48 +-
test/CodeGen/X86/masked-iv-unsafe.ll | 78 +-
test/CodeGen/X86/multiple-return-values.ll | 2 +-
test/CodeGen/X86/neg_fp.ll | 4 +-
test/CodeGen/X86/negate-add-zero.ll | 46 +-
test/CodeGen/X86/negative-sin.ll | 4 +-
test/CodeGen/X86/peep-test-0.ll | 2 +-
test/CodeGen/X86/peep-test-1.ll | 2 +-
test/CodeGen/X86/phys_subreg_coalesce.ll | 8 +-
test/CodeGen/X86/pr2656.ll | 4 +-
test/CodeGen/X86/pr3154.ll | 2 +-
test/CodeGen/X86/pr3457.ll | 6 +-
test/CodeGen/X86/pre-split1.ll | 6 +-
test/CodeGen/X86/pre-split10.ll | 14 +-
test/CodeGen/X86/pre-split4.ll | 8 +-
test/CodeGen/X86/pre-split5.ll | 2 +-
test/CodeGen/X86/pre-split6.ll | 4 +-
test/CodeGen/X86/pre-split7.ll | 8 +-
test/CodeGen/X86/pre-split8.ll | 8 +-
test/CodeGen/X86/pre-split9.ll | 8 +-
test/CodeGen/X86/shrink-fp-const1.ll | 2 +-
test/CodeGen/X86/small-byval-memcpy.ll | 2 +-
test/CodeGen/X86/soft-fp.ll | 2 +-
test/CodeGen/X86/sse-align-0.ll | 4 +-
test/CodeGen/X86/sse-align-2.ll | 4 +-
test/CodeGen/X86/sse-fcopysign.ll | 2 +-
test/CodeGen/X86/sse41-extractps-bitcast-1.ll | 2 +-
test/CodeGen/X86/stack-align.ll | 2 +-
test/CodeGen/X86/storetrunc-fp.ll | 2 +-
test/CodeGen/X86/stride-reuse.ll | 2 +-
test/CodeGen/X86/twoaddr-coalesce-2.ll | 4 +-
test/CodeGen/X86/vec_extract.ll | 6 +-
test/CodeGen/X86/vec_fneg.ll | 4 +-
test/CodeGen/X86/vec_ins_extract.ll | 12 +-
test/CodeGen/X86/vec_insert.ll | 2 +-
test/CodeGen/X86/vec_logical.ll | 2 +-
test/CodeGen/X86/vec_select.ll | 2 +-
test/CodeGen/X86/vec_shuffle-27.ll | 6 +-
test/CodeGen/X86/vec_shuffle-3.ll | 4 +-
test/CodeGen/X86/vec_shuffle-5.ll | 2 +-
test/CodeGen/X86/vec_splat.ll | 4 +-
test/CodeGen/X86/vec_ss_load_fold.ll | 4 +-
test/CodeGen/X86/vec_zero.ll | 2 +-
test/CodeGen/X86/vector.ll | 20 +-
test/CodeGen/X86/widen_arith-6.ll | 4 +-
test/CodeGen/X86/widen_shuffle-1.ll | 2 +-
test/CodeGen/X86/widen_shuffle-2.ll | 2 +-
test/CodeGen/XCore/2009-01-14-Remat-Crash.ll | 12 +-
test/CodeGen/XCore/fneg.ll | 2 +-
test/ExecutionEngine/2003-01-10-FUCOM.ll | 6 +-
test/ExecutionEngine/test-fp.ll | 8 +-
test/ExecutionEngine/test-setcond-fp.ll | 8 +-
test/Feature/ppcld.ll | 2 +-
test/Feature/sparcld.ll | 2 +-
test/Feature/x86ld.ll | 2 +-
test/Other/2004-08-16-PackedSelect.ll | 2 +-
test/Other/2004-08-16-PackedSimple.ll | 2 +-
test/Other/2004-08-20-PackedControlFlow.ll | 2 +-
test/Transforms/ConstProp/calls.ll | 6 +-
.../2006-06-27-AST-Remove.ll | 2 +-
.../GVNPRE/2007-06-18-ConstantInPhi.ll | 4 +-
.../GlobalOpt/2008-01-29-VolatileGlobal.ll | 2 +-
.../GlobalOpt/2008-04-26-SROA-Global-Align.ll | 4 +-
.../GlobalOpt/constantexpr-dangle.ll | 2 +-
.../IndVarSimplify/2006-12-10-BitCast.ll | 2 +-
.../IndVarSimplify/2008-11-03-Floating.ll | 8 +-
.../IndVarSimplify/2008-11-17-Floating.ll | 4 +-
.../2008-11-25-APFloatAssert.ll | 2 +-
.../IndVarSimplify/2009-04-27-Floating.ll | 2 +-
test/Transforms/IndVarSimplify/iv-zext.ll | 6 +-
.../InstCombine/2006-10-26-VectorReassoc.ll | 4 +-
.../2006-12-01-BadFPVectorXform.ll | 4 +-
.../Transforms/InstCombine/2008-07-16-fsub.ll | 2 +-
test/Transforms/InstCombine/add-sitofp.ll | 2 +-
test/Transforms/InstCombine/dce-iterate.ll | 2 +-
test/Transforms/InstCombine/fpextend.ll | 4 +-
test/Transforms/InstCombine/mul.ll | 4 +-
test/Transforms/InstCombine/multi-use-or.ll | 2 +-
.../InstCombine/shufflemask-undef.ll | 10 +-
.../InstCombine/signed-comparison.ll | 2 +-
test/Transforms/InstCombine/sitofp.ll | 2 +-
.../InstCombine/vec_demanded_elts.ll | 6 +-
test/Transforms/InstCombine/vec_narrow.ll | 2 +-
.../InstCombine/zero-point-zero-add.ll | 6 +-
test/Transforms/LCSSA/2007-07-12-LICM-2.ll | 8 +-
test/Transforms/LCSSA/2007-07-12-LICM-3.ll | 8 +-
test/Transforms/LCSSA/2007-07-12-LICM.ll | 2 +-
.../2007-09-24-UpdateIterationSpace.ll | 10 +-
.../2007-09-25-UpdateIterationSpace-2.ll | 10 +-
.../Mem2Reg/PromoteMemToRegister.ll | 2 +-
test/Transforms/MemCpyOpt/memcpy.ll | 2 +-
test/Transforms/MemCpyOpt/sret.ll | 2 +-
.../Transforms/PruneEH/2008-09-05-CGUpdate.ll | 10 +-
.../2006-04-27-ReassociateVector.ll | 4 +-
test/Transforms/SCCP/2006-12-04-PackedType.ll | 4 +-
test/Transforms/SCCP/apint-ipsccp4.ll | 4 +-
.../ScalarRepl/2009-03-17-CleanUp.ll | 64 +-
test/Transforms/ScalarRepl/copy-aggregate.ll | 2 +-
.../ScalarRepl/memcpy-from-global.ll | 16 +-
test/Transforms/ScalarRepl/vector_promote.ll | 12 +-
.../SimplifyCFG/2006-10-29-InvokeCrash.ll | 14 +-
.../SimplifyCFG/2008-01-02-hoist-fp-add.ll | 2 +-
.../2008-04-27-MultipleReturnCrash.ll | 2 +-
.../SimplifyCFG/2009-05-12-externweak.ll | 2 +-
test/Transforms/SimplifyLibCalls/half-powr.ll | 2 +-
utils/llvm.grm | 3 +-
utils/vim/llvm.vim | 3 +-
265 files changed, 2375 insertions(+), 1925 deletions(-)
diff --git a/docs/LangRef.html b/docs/LangRef.html
index 5f23674b31b..60217ecff42 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -89,8 +89,11 @@
Binary Operations
- 'add' Instruction
+ - 'fadd' Instruction
- 'sub' Instruction
+ - 'fsub' Instruction
- 'mul' Instruction
+ - 'fmul' Instruction
- 'udiv' Instruction
- 'sdiv' Instruction
- 'fdiv' Instruction
@@ -2503,16 +2506,15 @@ The result value has the same type as its operands.
Arguments:
The two arguments to the 'add' instruction must be integer, floating point, or
- vector values. Both arguments must have identical
- types.
+ href="#t_integer">integer or
+ vector of integer values. Both arguments must
+ have identical types.
Semantics:
-The value produced is the integer or floating point sum of the two
-operands.
+The value produced is the integer sum of the two operands.
-If an integer sum has unsigned overflow, the result returned is the
+
If the sum has unsigned overflow, the result returned is the
mathematical result modulo 2n, where n is the bit width of
the result.
@@ -2526,6 +2528,39 @@ instruction is appropriate for both signed and unsigned integers.
+
+
+
+
+
Syntax:
+
+
+ <result> = fadd <ty> <op1>, <op2> ; yields {ty}:result
+
+
+
Overview:
+
+
The 'fadd' instruction returns the sum of its two operands.
+
+
Arguments:
+
+
The two arguments to the 'fadd' instruction must be
+floating point or vector of
+floating point values. Both arguments must have identical types.
+
+
Semantics:
+
+
The value produced is the floating point sum of the two operands.
+
+
Example:
+
+
+ <result> = fadd float 4.0, %var ; yields {float}:result = 4.0 + %var
+
+
+
@@ -2550,16 +2585,14 @@ representations.
Arguments:
The two arguments to the 'sub' instruction must be integer, floating point,
- or vector values. Both arguments must have identical
- types.
+ href="#t_integer">integer or vector of
+ integer values. Both arguments must have identical types.
Semantics:
-The value produced is the integer or floating point difference of
-the two operands.
+The value produced is the integer difference of the two operands.
-If an integer difference has unsigned overflow, the result returned is the
+
If the difference has unsigned overflow, the result returned is the
mathematical result modulo 2n, where n is the bit width of
the result.
@@ -2573,6 +2606,45 @@ instruction is appropriate for both signed and unsigned integers.
+
+
+
+
+
+
Syntax:
+
+
+ <result> = fsub <ty> <op1>, <op2> ; yields {ty}:result
+
+
+
Overview:
+
+
The 'fsub' instruction returns the difference of its two
+operands.
+
+
Note that the 'fsub' instruction is used to represent the
+'fneg' instruction present in most other intermediate
+representations.
+
+
Arguments:
+
+
The two arguments to the 'fsub' instruction must be floating point or vector
+ of floating point values. Both arguments must have identical types.
+
+
Semantics:
+
+
The value produced is the floating point difference of the two operands.
+
+
Example:
+
+ <result> = fsub float 4.0, %var ; yields {float}:result = 4.0 - %var
+ <result> = fsub float -0.0, %val ; yields {float}:result = -%var
+
+
+
'mul' Instruction
@@ -2590,16 +2662,14 @@ operands.
Arguments:
The two arguments to the 'mul' instruction must be integer, floating point,
-or vector values. Both arguments must have identical
-types.
+href="#t_integer">integer or
vector of integer
+values. Both arguments must have identical types.
Semantics:
-
The value produced is the integer or floating point product of the
-two operands.
+
The value produced is the integer product of the two operands.
-
If the result of an integer multiplication has unsigned overflow,
+
If the result of the multiplication has unsigned overflow,
the result returned is the mathematical result modulo
2n, where n is the bit width of the result.
Because LLVM integers use a two's complement representation, and the
@@ -2613,6 +2683,35 @@ width of the full product.
+
+
+
+
+
+
Syntax:
+
<result> = fmul <ty> <op1>, <op2> ; yields {ty}:result
+
+
Overview:
+
The 'fmul' instruction returns the product of its two
+operands.
+
+
Arguments:
+
+
The two arguments to the 'fmul' instruction must be
+floating point or vector
+of floating point values. Both arguments must have identical types.
+
+
Semantics:
+
+
The value produced is the floating point product of the two operands.
+
+
Example:
+
<result> = fmul float 4.0, %var ; yields {float}:result = 4.0 * %var
+
+
+
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 9e95a08fc96..ed0fe2740f9 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -704,10 +704,14 @@ public:
/// specify the full Instruction::OPCODE identifier.
///
static Constant *getNeg(Constant *C);
+ static Constant *getFNeg(Constant *C);
static Constant *getNot(Constant *C);
static Constant *getAdd(Constant *C1, Constant *C2);
+ static Constant *getFAdd(Constant *C1, Constant *C2);
static Constant *getSub(Constant *C1, Constant *C2);
+ static Constant *getFSub(Constant *C1, Constant *C2);
static Constant *getMul(Constant *C1, Constant *C2);
+ static Constant *getFMul(Constant *C1, Constant *C2);
static Constant *getUDiv(Constant *C1, Constant *C2);
static Constant *getSDiv(Constant *C1, Constant *C2);
static Constant *getFDiv(Constant *C1, Constant *C2);
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 3a774d45e92..1eab983da68 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -204,21 +204,30 @@ public:
Instruction *InsertBefore = 0);
static BinaryOperator *CreateNeg(Value *Op, const std::string &Name,
BasicBlock *InsertAtEnd);
+ static BinaryOperator *CreateFNeg(Value *Op, const std::string &Name = "",
+ Instruction *InsertBefore = 0);
+ static BinaryOperator *CreateFNeg(Value *Op, const std::string &Name,
+ BasicBlock *InsertAtEnd);
static BinaryOperator *CreateNot(Value *Op, const std::string &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateNot(Value *Op, const std::string &Name,
BasicBlock *InsertAtEnd);
- /// isNeg, isNot - Check if the given Value is a NEG or NOT instruction.
+ /// isNeg, isFNeg, isNot - Check if the given Value is a
+ /// NEG, FNeg, or NOT instruction.
///
static bool isNeg(const Value *V);
+ static bool isFNeg(const Value *V);
static bool isNot(const Value *V);
/// getNegArgument, getNotArgument - Helper functions to extract the
- /// unary argument of a NEG or NOT operation implemented via Sub or Xor.
+ /// unary argument of a NEG, FNEG or NOT operation implemented via
+ /// Sub, FSub, or Xor.
///
static const Value *getNegArgument(const Value *BinOp);
static Value *getNegArgument( Value *BinOp);
+ static const Value *getFNegArgument(const Value *BinOp);
+ static Value *getFNegArgument( Value *BinOp);
static const Value *getNotArgument(const Value *BinOp);
static Value *getNotArgument( Value *BinOp);
diff --git a/include/llvm/Instruction.def b/include/llvm/Instruction.def
index 66bf2ce9669..98fda777054 100644
--- a/include/llvm/Instruction.def
+++ b/include/llvm/Instruction.def
@@ -105,71 +105,74 @@ HANDLE_TERM_INST ( 6, Unreachable, UnreachableInst)
// Standard binary operators...
FIRST_BINARY_INST( 7)
HANDLE_BINARY_INST( 7, Add , BinaryOperator)
-HANDLE_BINARY_INST( 8, Sub , BinaryOperator)
-HANDLE_BINARY_INST( 9, Mul , BinaryOperator)
-HANDLE_BINARY_INST(10, UDiv , BinaryOperator)
-HANDLE_BINARY_INST(11, SDiv , BinaryOperator)
-HANDLE_BINARY_INST(12, FDiv , BinaryOperator)
-HANDLE_BINARY_INST(13, URem , BinaryOperator)
-HANDLE_BINARY_INST(14, SRem , BinaryOperator)
-HANDLE_BINARY_INST(15, FRem , BinaryOperator)
+HANDLE_BINARY_INST( 8, FAdd , BinaryOperator)
+HANDLE_BINARY_INST( 9, Sub , BinaryOperator)
+HANDLE_BINARY_INST(10, FSub , BinaryOperator)
+HANDLE_BINARY_INST(11, Mul , BinaryOperator)
+HANDLE_BINARY_INST(12, FMul , BinaryOperator)
+HANDLE_BINARY_INST(13, UDiv , BinaryOperator)
+HANDLE_BINARY_INST(14, SDiv , BinaryOperator)
+HANDLE_BINARY_INST(15, FDiv , BinaryOperator)
+HANDLE_BINARY_INST(16, URem , BinaryOperator)
+HANDLE_BINARY_INST(17, SRem , BinaryOperator)
+HANDLE_BINARY_INST(18, FRem , BinaryOperator)
// Logical operators (integer operands)
-HANDLE_BINARY_INST(16, Shl , BinaryOperator) // Shift left (logical)
-HANDLE_BINARY_INST(17, LShr , BinaryOperator) // Shift right (logical)
-HANDLE_BINARY_INST(18, AShr , BinaryOperator) // Shift right (arithmetic)
-HANDLE_BINARY_INST(19, And , BinaryOperator)
-HANDLE_BINARY_INST(20, Or , BinaryOperator)
-HANDLE_BINARY_INST(21, Xor , BinaryOperator)
- LAST_BINARY_INST(21)
+HANDLE_BINARY_INST(19, Shl , BinaryOperator) // Shift left (logical)
+HANDLE_BINARY_INST(20, LShr , BinaryOperator) // Shift right (logical)
+HANDLE_BINARY_INST(21, AShr , BinaryOperator) // Shift right (arithmetic)
+HANDLE_BINARY_INST(22, And , BinaryOperator)
+HANDLE_BINARY_INST(23, Or , BinaryOperator)
+HANDLE_BINARY_INST(24, Xor , BinaryOperator)
+ LAST_BINARY_INST(24)
// Memory operators...
- FIRST_MEMORY_INST(22)
-HANDLE_MEMORY_INST(22, Malloc, MallocInst) // Heap management instructions
-HANDLE_MEMORY_INST(23, Free , FreeInst )
-HANDLE_MEMORY_INST(24, Alloca, AllocaInst) // Stack management
-HANDLE_MEMORY_INST(25, Load , LoadInst ) // Memory manipulation instrs
-HANDLE_MEMORY_INST(26, Store , StoreInst )
-HANDLE_MEMORY_INST(27, GetElementPtr, GetElementPtrInst)
- LAST_MEMORY_INST(27)
+ FIRST_MEMORY_INST(25)
+HANDLE_MEMORY_INST(25, Malloc, MallocInst) // Heap management instructions
+HANDLE_MEMORY_INST(26, Free , FreeInst )
+HANDLE_MEMORY_INST(27, Alloca, AllocaInst) // Stack management
+HANDLE_MEMORY_INST(28, Load , LoadInst ) // Memory manipulation instrs
+HANDLE_MEMORY_INST(29, Store , StoreInst )
+HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst)
+ LAST_MEMORY_INST(30)
// Cast operators ...
// NOTE: The order matters here because CastInst::isEliminableCastPair
// NOTE: (see Instructions.cpp) encodes a table based on this ordering.
- FIRST_CAST_INST(28)
-HANDLE_CAST_INST(28, Trunc , TruncInst ) // Truncate integers
-HANDLE_CAST_INST(29, ZExt , ZExtInst ) // Zero extend integers
-HANDLE_CAST_INST(30, SExt , SExtInst ) // Sign extend integers
-HANDLE_CAST_INST(31, FPToUI , FPToUIInst ) // floating point -> UInt
-HANDLE_CAST_INST(32, FPToSI , FPToSIInst ) // floating point -> SInt
-HANDLE_CAST_INST(33, UIToFP , UIToFPInst ) // UInt -> floating point
-HANDLE_CAST_INST(34, SIToFP , SIToFPInst ) // SInt -> floating point
-HANDLE_CAST_INST(35, FPTrunc , FPTruncInst ) // Truncate floating point
-HANDLE_CAST_INST(36, FPExt , FPExtInst ) // Extend floating point
-HANDLE_CAST_INST(37, PtrToInt, PtrToIntInst) // Pointer -> Integer
-HANDLE_CAST_INST(38, IntToPtr, IntToPtrInst) // Integer -> Pointer
-HANDLE_CAST_INST(39, BitCast , BitCastInst ) // Type cast
- LAST_CAST_INST(39)
+ FIRST_CAST_INST(31)
+HANDLE_CAST_INST(31, Trunc , TruncInst ) // Truncate integers
+HANDLE_CAST_INST(32, ZExt , ZExtInst ) // Zero extend integers
+HANDLE_CAST_INST(33, SExt , SExtInst ) // Sign extend integers
+HANDLE_CAST_INST(34, FPToUI , FPToUIInst ) // floating point -> UInt
+HANDLE_CAST_INST(35, FPToSI , FPToSIInst ) // floating point -> SInt
+HANDLE_CAST_INST(36, UIToFP , UIToFPInst ) // UInt -> floating point
+HANDLE_CAST_INST(37, SIToFP , SIToFPInst ) // SInt -> floating point
+HANDLE_CAST_INST(38, FPTrunc , FPTruncInst ) // Truncate floating point
+HANDLE_CAST_INST(39, FPExt , FPExtInst ) // Extend floating point
+HANDLE_CAST_INST(40, PtrToInt, PtrToIntInst) // Pointer -> Integer
+HANDLE_CAST_INST(41, IntToPtr, IntToPtrInst) // Integer -> Pointer
+HANDLE_CAST_INST(42, BitCast , BitCastInst ) // Type cast
+ LAST_CAST_INST(42)
// Other operators...
- FIRST_OTHER_INST(40)
-HANDLE_OTHER_INST(40, ICmp , ICmpInst ) // Integer comparison instruction
-HANDLE_OTHER_INST(41, FCmp , FCmpInst ) // Floating point comparison instr.
-HANDLE_OTHER_INST(42, PHI , PHINode ) // PHI node instruction
-HANDLE_OTHER_INST(43, Call , CallInst ) // Call a function
-HANDLE_OTHER_INST(44, Select , SelectInst ) // select instruction
-HANDLE_OTHER_INST(45, UserOp1, Instruction) // May be used internally in a pass
-HANDLE_OTHER_INST(46, UserOp2, Instruction) // Internal to passes only
-HANDLE_OTHER_INST(47, VAArg , VAArgInst ) // vaarg instruction
-HANDLE_OTHER_INST(48, ExtractElement, ExtractElementInst)// extract from vector
-HANDLE_OTHER_INST(49, InsertElement, InsertElementInst) // insert into vector
-HANDLE_OTHER_INST(50, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
-HANDLE_OTHER_INST(51, ExtractValue, ExtractValueInst)// extract from aggregate
-HANDLE_OTHER_INST(52, InsertValue, InsertValueInst) // insert into aggregate
-HANDLE_OTHER_INST(53, VICmp , VICmpInst ) // Vec Int comparison instruction.
-HANDLE_OTHER_INST(54, VFCmp , VFCmpInst ) // Vec FP point comparison instr.
-
- LAST_OTHER_INST(55)
+ FIRST_OTHER_INST(43)
+HANDLE_OTHER_INST(43, ICmp , ICmpInst ) // Integer comparison instruction
+HANDLE_OTHER_INST(44, FCmp , FCmpInst ) // Floating point comparison instr.
+HANDLE_OTHER_INST(45, PHI , PHINode ) // PHI node instruction
+HANDLE_OTHER_INST(46, Call , CallInst ) // Call a function
+HANDLE_OTHER_INST(47, Select , SelectInst ) // select instruction
+HANDLE_OTHER_INST(48, UserOp1, Instruction) // May be used internally in a pass
+HANDLE_OTHER_INST(49, UserOp2, Instruction) // Internal to passes only
+HANDLE_OTHER_INST(50, VAArg , VAArgInst ) // vaarg instruction
+HANDLE_OTHER_INST(51, ExtractElement, ExtractElementInst)// extract from vector
+HANDLE_OTHER_INST(52, InsertElement, InsertElementInst) // insert into vector
+HANDLE_OTHER_INST(53, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
+HANDLE_OTHER_INST(54, ExtractValue, ExtractValueInst)// extract from aggregate
+HANDLE_OTHER_INST(55, InsertValue, InsertValueInst) // insert into aggregate
+HANDLE_OTHER_INST(56, VICmp , VICmpInst ) // Vec Int comparison instruction.
+HANDLE_OTHER_INST(57, VFCmp , VFCmpInst ) // Vec FP point comparison instr.
+
+ LAST_OTHER_INST(57)
#undef FIRST_TERM_INST
#undef HANDLE_TERM_INST
diff --git a/include/llvm/Support/ConstantFolder.h b/include/llvm/Support/ConstantFolder.h
index ca8bcae8598..35065a06086 100644
--- a/include/llvm/Support/ConstantFolder.h
+++ b/include/llvm/Support/ConstantFolder.h
@@ -32,12 +32,21 @@ public:
Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getAdd(LHS, RHS);
}
+ Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getFAdd(LHS, RHS);
+ }
Constant *CreateSub(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getSub(LHS, RHS);
}
+ Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getFSub(LHS, RHS);
+ }
Constant *CreateMul(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getMul(LHS, RHS);
}
+ Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getFMul(LHS, RHS);
+ }
Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getUDiv(LHS, RHS);
}
@@ -87,6 +96,9 @@ public:
Constant *CreateNeg(Constant *C) const {
return ConstantExpr::getNeg(C);
}
+ Constant *CreateFNeg(Constant *C) const {
+ return ConstantExpr::getFNeg(C);
+ }
Constant *CreateNot(Constant *C) const {
return ConstantExpr::getNot(C);
}
diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h
index 9ef14af51d9..7942de7857a 100644
--- a/include/llvm/Support/IRBuilder.h
+++ b/include/llvm/Support/IRBuilder.h
@@ -175,18 +175,36 @@ public:
return Folder.CreateAdd(LC, RC);
return Insert(BinaryOperator::CreateAdd(LHS, RHS), Name);
}
+ Value *CreateFAdd(Value *LHS, Value *RHS, const char *Name = "") {
+ if (Constant *LC = dyn_cast(LHS))
+ if (Constant *RC = dyn_cast(RHS))
+ return Folder.CreateFAdd(LC, RC);
+ return Insert(BinaryOperator::CreateFAdd(LHS, RHS), Name);
+ }
Value *CreateSub(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
return Folder.CreateSub(LC, RC);
return Insert(BinaryOperator::CreateSub(LHS, RHS), Name);
}
+ Value *CreateFSub(Value *LHS, Value *RHS, const char *Name = "") {
+ if (Constant *LC = dyn_cast(LHS))
+ if (Constant *RC = dyn_cast(RHS))
+ return Folder.CreateFSub(LC, RC);
+ return Insert(BinaryOperator::CreateFSub(LHS, RHS), Name);
+ }
Value *CreateMul(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
return Folder.CreateMul(LC, RC);
return Insert(BinaryOperator::CreateMul(LHS, RHS), Name);
}
+ Value *CreateFMul(Value *LHS, Value *RHS, const char *Name = "") {
+ if (Constant *LC = dyn_cast(LHS))
+ if (Constant *RC = dyn_cast(RHS))
+ return Folder.CreateMul(LC, RC);
+ return Insert(BinaryOperator::CreateFMul(LHS, RHS), Name);
+ }
Value *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
diff --git a/include/llvm/Support/NoFolder.h b/include/llvm/Support/NoFolder.h
index 1dce497017b..a49cf842406 100644
--- a/include/llvm/Support/NoFolder.h
+++ b/include/llvm/Support/NoFolder.h
@@ -39,12 +39,21 @@ public:
Value *CreateAdd(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateAdd(LHS, RHS);
}
+ Value *CreateFAdd(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateFAdd(LHS, RHS);
+ }
Value *CreateSub(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateSub(LHS, RHS);
}
+ Value *CreateFSub(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateFSub(LHS, RHS);
+ }
Value *CreateMul(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateMul(LHS, RHS);
}
+ Value *CreateFMul(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateFMul(LHS, RHS);
+ }
Value *CreateUDiv(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateUDiv(LHS, RHS);
}
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index d27a7f1ed78..fda925f5a9a 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -156,18 +156,36 @@ inline BinaryOp_match m_Add(const LHS &L,
return BinaryOp_match(L, R);
}
+template
+inline BinaryOp_match m_FAdd(const LHS &L,
+ const RHS &R) {
+ return BinaryOp_match(L, R);
+}
+
template
inline BinaryOp_match m_Sub(const LHS &L,
const RHS &R) {
return BinaryOp_match(L, R);
}
+template
+inline BinaryOp_match m_FSub(const LHS &L,
+ const RHS &R) {
+ return BinaryOp_match(L, R);
+}
+
template
inline BinaryOp_match m_Mul(const LHS &L,
const RHS &R) {
return BinaryOp_match(L, R);
}
+template
+inline BinaryOp_match m_FMul(const LHS &L,
+ const RHS &R) {
+ return BinaryOp_match(L, R);
+}
+
template
inline BinaryOp_match m_UDiv(const LHS &L,
const RHS &R) {
@@ -494,6 +512,35 @@ template
inline neg_match m_Neg(const LHS &L) { return L; }
+template
+struct fneg_match {
+ LHS_t L;
+
+ fneg_match(const LHS_t &LHS) : L(LHS) {}
+
+ template
+ bool match(OpTy *V) {
+ if (Instruction *I = dyn_cast(V))
+ if (I->getOpcode() == Instruction::FSub)
+ return matchIfFNeg(I->getOperand(0), I->getOperand(1));
+ if (ConstantExpr *CE = dyn_cast(V))
+ if (CE->getOpcode() == Instruction::FSub)
+ return matchIfFNeg(CE->getOperand(0), CE->getOperand(1));
+ if (ConstantFP *CF = dyn_cast(V))
+ return L.match(ConstantExpr::getFNeg(CF));
+ return false;
+ }
+private:
+ bool matchIfFNeg(Value *LHS, Value *RHS) {
+ return LHS == ConstantExpr::getZeroValueForNegationExpr(LHS->getType()) &&
+ L.match(RHS);
+ }
+};
+
+template
+inline fneg_match m_FNeg(const LHS &L) { return L; }
+
+
//===----------------------------------------------------------------------===//
// Matchers for control flow
//
diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h
index 172e4fe123d..b0700c1dadd 100644
--- a/include/llvm/Support/TargetFolder.h
+++ b/include/llvm/Support/TargetFolder.h
@@ -48,12 +48,21 @@ public:
Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getAdd(LHS, RHS));
}
+ Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getFAdd(LHS, RHS));
+ }
Constant *CreateSub(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getSub(LHS, RHS));
}
+ Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getFSub(LHS, RHS));
+ }
Constant *CreateMul(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getMul(LHS, RHS));
}
+ Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getFMul(LHS, RHS));
+ }
Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getUDiv(LHS, RHS));
}
@@ -103,6 +112,9 @@ public:
Constant *CreateNeg(Constant *C) const {
return Fold(ConstantExpr::getNeg(C));
}
+ Constant *CreateFNeg(Constant *C) const {
+ return Fold(ConstantExpr::getFNeg(C));
+ }
Constant *CreateNot(Constant *C) const {
return Fold(ConstantExpr::getNot(C));
}
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index 29ff8aa4f4d..45f97b8f64b 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -771,7 +771,7 @@ bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) {
if (I == 0) return false;
// (add x, 0.0) is guaranteed to return +0.0, not -0.0.
- if (I->getOpcode() == Instruction::Add &&
+ if (I->getOpcode() == Instruction::FAdd &&
isa(I->getOperand(1)) &&
cast(I->getOperand(1))->isNullValue())
return true;
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp
index 340cfe152f5..2cfb36656a2 100644
--- a/lib/AsmParser/LLLexer.cpp
+++ b/lib/AsmParser/LLLexer.cpp
@@ -591,7 +591,9 @@ lltok::Kind LLLexer::LexIdentifier() {
if (Len == strlen(#STR) && !memcmp(StartChar, #STR, strlen(#STR))) { \
UIntVal = Instruction::Enum; return lltok::kw_##STR; }
- INSTKEYWORD(add, Add); INSTKEYWORD(sub, Sub); INSTKEYWORD(mul, Mul);
+ INSTKEYWORD(add, Add); INSTKEYWORD(fadd, FAdd);
+ INSTKEYWORD(sub, Sub); INSTKEYWORD(fsub, FSub);
+ INSTKEYWORD(mul, Mul); INSTKEYWORD(fmul, FMul);
INSTKEYWORD(udiv, UDiv); INSTKEYWORD(sdiv, SDiv); INSTKEYWORD(fdiv, FDiv);
INSTKEYWORD(urem, URem); INSTKEYWORD(srem, SRem); INSTKEYWORD(frem, FRem);
INSTKEYWORD(shl, Shl); INSTKEYWORD(lshr, LShr); INSTKEYWORD(ashr, AShr);
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 4f8be889c70..b4577ad726d 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -1835,8 +1835,11 @@ bool LLParser::ParseValID(ValID &ID) {
// Binary Operators.
case lltok::kw_add:
+ case lltok::kw_fadd:
case lltok::kw_sub:
+ case lltok::kw_fsub:
case lltok::kw_mul:
+ case lltok::kw_fmul:
case lltok::kw_udiv:
case lltok::kw_sdiv:
case lltok::kw_fdiv:
@@ -2400,8 +2403,13 @@ bool LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB,
// Binary Operators.
case lltok::kw_add:
case lltok::kw_sub:
- case lltok::kw_mul: return ParseArithmetic(Inst, PFS, KeywordVal, 0);
-
+ case lltok::kw_mul:
+ // API compatibility: Accept either integer or floating-point types.
+ return ParseArithmetic(Inst, PFS, KeywordVal, 0);
+ case lltok::kw_fadd:
+ case lltok::kw_fsub:
+ case lltok::kw_fmul: return ParseArithmetic(Inst, PFS, KeywordVal, 2);
+
case lltok::kw_udiv:
case lltok::kw_sdiv:
case lltok::kw_urem:
diff --git a/lib/AsmParser/LLToken.h b/lib/AsmParser/LLToken.h
index 2d1cfa5a053..c2ce5601d41 100644
--- a/lib/AsmParser/LLToken.h
+++ b/lib/AsmParser/LLToken.h
@@ -90,7 +90,8 @@ namespace lltok {
kw_ueq, kw_une,
// Instruction Opcodes (Opcode in UIntVal).
- kw_add, kw_sub, kw_mul, kw_udiv, kw_sdiv, kw_fdiv,
+ kw_add, kw_fadd, kw_sub, kw_fsub, kw_mul, kw_fmul,
+ kw_udiv, kw_sdiv, kw_fdiv,
kw_urem, kw_srem, kw_frem, kw_shl, kw_lshr, kw_ashr,
kw_and, kw_or, kw_xor, kw_icmp, kw_fcmp, kw_vicmp, kw_vfcmp,
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 1dad04bd8f6..3b44f56421f 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -104,9 +104,12 @@ static int GetDecodedCastOpcode(unsigned Val) {
static int GetDecodedBinaryOpcode(unsigned Val, const Type *Ty) {
switch (Val) {
default: return -1;
- case bitc::BINOP_ADD: return Instruction::Add;
- case bitc::BINOP_SUB: return Instruction::Sub;
- case bitc::BINOP_MUL: return Instruction::Mul;
+ case bitc::BINOP_ADD:
+ return Ty->isFPOrFPVector() ? Instruction::FAdd : Instruction::Add;
+ case bitc::BINOP_SUB:
+ return Ty->isFPOrFPVector() ? Instruction::FSub : Instruction::Sub;
+ case bitc::BINOP_MUL:
+ return Ty->isFPOrFPVector() ? Instruction::FMul : Instruction::Mul;
case bitc::BINOP_UDIV: return Instruction::UDiv;
case bitc::BINOP_SDIV:
return Ty->isFPOrFPVector() ? Instruction::FDiv : Instruction::SDiv;
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index bfc029c1f27..9f16728d492 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -77,9 +77,12 @@ static unsigned GetEncodedCastOpcode(unsigned Opcode) {
static unsigned GetEncodedBinaryOpcode(unsigned Opcode) {
switch (Opcode) {
default: assert(0 && "Unknown binary instruction!");
- case Instruction::Add: return bitc::BINOP_ADD;
- case Instruction::Sub: return bitc::BINOP_SUB;
- case Instruction::Mul: return bitc::BINOP_MUL;
+ case Instruction::Add:
+ case Instruction::FAdd: return bitc::BINOP_ADD;
+ case Instruction::Sub:
+ case Instruction::FSub: return bitc::BINOP_SUB;
+ case Instruction::Mul:
+ case Instruction::FMul: return bitc::BINOP_MUL;
case Instruction::UDiv: return bitc::BINOP_UDIV;
case Instruction::FDiv:
case Instruction::SDiv: return bitc::BINOP_SDIV;
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index 6becff32176..4a7dbebe2de 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -639,18 +639,18 @@ FastISel::FastEmitBranch(MachineBasicBlock *MSucc) {
bool
FastISel::SelectOperator(User *I, unsigned Opcode) {
switch (Opcode) {
- case Instruction::Add: {
- ISD::NodeType Opc = I->getType()->isFPOrFPVector() ? ISD::FADD : ISD::ADD;
- return SelectBinaryOp(I, Opc);
- }
- case Instruction::Sub: {
- ISD::NodeType Opc = I->getType()->isFPOrFPVector() ? ISD::FSUB : ISD::SUB;
- return SelectBinaryOp(I, Opc);
- }
- case Instruction::Mul: {
- ISD::NodeType Opc = I->getType()->isFPOrFPVector() ? ISD::FMUL : ISD::MUL;
- return SelectBinaryOp(I, Opc);
- }
+ case Instruction::Add:
+ return SelectBinaryOp(I, ISD::ADD);
+ case Instruction::FAdd:
+ return SelectBinaryOp(I, ISD::FADD);
+ case Instruction::Sub:
+ return SelectBinaryOp(I, ISD::SUB);
+ case Instruction::FSub:
+ return SelectBinaryOp(I, ISD::FSUB);
+ case Instruction::Mul:
+ return SelectBinaryOp(I, ISD::MUL);
+ case Instruction::FMul:
+ return SelectBinaryOp(I, ISD::FMUL);
case Instruction::SDiv:
return SelectBinaryOp(I, ISD::SDIV);
case Instruction::UDiv:
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
index 889d7f5dd93..93750d6b98c 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -842,20 +842,6 @@ void SelectionDAGLowering::visit(unsigned Opcode, User &I) {
}
}
-void SelectionDAGLowering::visitAdd(User &I) {
- if (I.getType()->isFPOrFPVector())
- visitBinary(I, ISD::FADD);
- else
- visitBinary(I, ISD::ADD);
-}
-
-void SelectionDAGLowering::visitMul(User &I) {
- if (I.getType()->isFPOrFPVector())
- visitBinary(I, ISD::FMUL);
- else
- visitBinary(I, ISD::MUL);
-}
-
SDValue SelectionDAGLowering::getValue(const Value *V) {
SDValue &N = NodeMap[V];
if (N.getNode()) return N;
@@ -2161,37 +2147,33 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &SI) {
}
-void SelectionDAGLowering::visitSub(User &I) {
+void SelectionDAGLowering::visitFSub(User &I) {
// -0.0 - X --> fneg
const Type *Ty = I.getType();
if (isa(Ty)) {
if (ConstantVector *CV = dyn_cast(I.getOperand(0))) {
const VectorType *DestTy = cast(I.getType());
const Type *ElTy = DestTy->getElementType();
- if (ElTy->isFloatingPoint()) {
- unsigned VL = DestTy->getNumElements();
- std::vector NZ(VL, ConstantFP::getNegativeZero(ElTy));
- Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
- if (CV == CNZ) {
- SDValue Op2 = getValue(I.getOperand(1));
- setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
- Op2.getValueType(), Op2));
- return;
- }
- }
- }
- }
- if (Ty->isFloatingPoint()) {
- if (ConstantFP *CFP = dyn_cast(I.getOperand(0)))
- if (CFP->isExactlyValue(ConstantFP::getNegativeZero(Ty)->getValueAPF())) {
+ unsigned VL = DestTy->getNumElements();
+ std::vector NZ(VL, ConstantFP::getNegativeZero(ElTy));
+ Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
+ if (CV == CNZ) {
SDValue Op2 = getValue(I.getOperand(1));
setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
Op2.getValueType(), Op2));
return;
}
+ }
}
+ if (ConstantFP *CFP = dyn_cast(I.getOperand(0)))
+ if (CFP->isExactlyValue(ConstantFP::getNegativeZero(Ty)->getValueAPF())) {
+ SDValue Op2 = getValue(I.getOperand(1));
+ setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
+ Op2.getValueType(), Op2));
+ return;
+ }
- visitBinary(I, Ty->isFPOrFPVector() ? ISD::FSUB : ISD::SUB);
+ visitBinary(I, ISD::FSUB);
}
void SelectionDAGLowering::visitBinary(User &I, unsigned OpCode) {
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h
index 578aa591ce6..057c8410da0 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h
@@ -469,9 +469,12 @@ private:
void visitBinary(User &I, unsigned OpCode);
void visitShift(User &I, unsigned Opcode);
- void visitAdd(User &I);
- void visitSub(User &I);
- void visitMul(User &I);
+ void visitAdd(User &I) { visitBinary(I, ISD::ADD); }
+ void visitFAdd(User &I) { visitBinary(I, ISD::FADD); }
+ void visitSub(User &I) { visitBinary(I, ISD::SUB); }
+ void visitFSub(User &I);
+ void visitMul(User &I) { visitBinary(I, ISD::MUL); }
+ void visitFMul(User &I) { visitBinary(I, ISD::FMUL); }
void visitURem(User &I) { visitBinary(I, ISD::UREM); }
void visitSRem(User &I) { visitBinary(I, ISD::SREM); }
void visitFRem(User &I) { visitBinary(I, ISD::FREM); }
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index 29a05bbbdb6..a80513f3df9 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -573,8 +573,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
return GV;
}
case Instruction::Add:
+ case Instruction::FAdd:
case Instruction::Sub:
+ case Instruction::FSub:
case Instruction::Mul:
+ case Instruction::FMul:
case Instruction::UDiv:
case Instruction::SDiv:
case Instruction::URem:
@@ -605,11 +608,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
case Type::FloatTyID:
switch (CE->getOpcode()) {
default: assert(0 && "Invalid float opcode"); abort();
- case Instruction::Add:
+ case Instruction::FAdd:
GV.FloatVal = LHS.FloatVal + RHS.FloatVal; break;
- case Instruction::Sub:
+ case Instruction::FSub:
GV.FloatVal = LHS.FloatVal - RHS.FloatVal; break;
- case Instruction::Mul:
+ case Instruction::FMul:
GV.FloatVal = LHS.FloatVal * RHS.FloatVal; break;
case Instruction::FDiv:
GV.FloatVal = LHS.FloatVal / RHS.FloatVal; break;
@@ -620,11 +623,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
case Type::DoubleTyID:
switch (CE->getOpcode()) {
default: assert(0 && "Invalid double opcode"); abort();
- case Instruction::Add:
+ case Instruction::FAdd:
GV.DoubleVal = LHS.DoubleVal + RHS.DoubleVal; break;
- case Instruction::Sub:
+ case Instruction::FSub:
GV.DoubleVal = LHS.DoubleVal - RHS.DoubleVal; break;
- case Instruction::Mul:
+ case Instruction::FMul:
GV.DoubleVal = LHS.DoubleVal * RHS.DoubleVal; break;
case Instruction::FDiv:
GV.DoubleVal = LHS.DoubleVal / RHS.DoubleVal; break;
@@ -638,15 +641,15 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
APFloat apfLHS = APFloat(LHS.IntVal);
switch (CE->getOpcode()) {
default: assert(0 && "Invalid long double opcode"); abort();
- case Instruction::Add:
+ case Instruction::FAdd:
apfLHS.add(APFloat(RHS.IntVal), APFloat::rmNearestTiesToEven);
GV.IntVal = apfLHS.bitcastToAPInt();
break;
- case Instruction::Sub:
+ case Instruction::FSub:
apfLHS.subtract(APFloat(RHS.IntVal), APFloat::rmNearestTiesToEven);
GV.IntVal = apfLHS.bitcastToAPInt();
break;
- case Instruction::Mul:
+ case Instruction::FMul:
apfLHS.multiply(APFloat(RHS.IntVal), APFloat::rmNearestTiesToEven);
GV.IntVal = apfLHS.bitcastToAPInt();
break;
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 765fed248f9..7dfeae0ab2e 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -64,45 +64,35 @@ void Interpreter::initializeExecutionEngine() {
Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; \
break
-#define IMPLEMENT_INTEGER_BINOP1(OP, TY) \
- case Type::IntegerTyID: { \
- Dest.IntVal = Src1.IntVal OP Src2.IntVal; \
- break; \
- }
-
-
-static void executeAddInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
+static void executeFAddInst(GenericValue &Dest, GenericValue Src1,
+ GenericValue Src2, const Type *Ty) {
switch (Ty->getTypeID()) {
- IMPLEMENT_INTEGER_BINOP1(+, Ty);
IMPLEMENT_BINARY_OPERATOR(+, Float);
IMPLEMENT_BINARY_OPERATOR(+, Double);
default:
- cerr << "Unhandled type for Add instruction: " << *Ty << "\n";
+ cerr << "Unhandled type for FAdd instruction: " << *Ty << "\n";
abort();
}
}
-static void executeSubInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
+static void executeFSubInst(GenericValue &Dest, GenericValue Src1,
+ GenericValue Src2, const Type *Ty) {
switch (Ty->getTypeID()) {
- IMPLEMENT_INTEGER_BINOP1(-, Ty);
IMPLEMENT_BINARY_OPERATOR(-, Float);
IMPLEMENT_BINARY_OPERATOR(-, Double);
default:
- cerr << "Unhandled type for Sub instruction: " << *Ty << "\n";
+ cerr << "Unhandled type for FSub instruction: " << *Ty << "\n";
abort();
}
}
-static void executeMulInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
+static void executeFMulInst(GenericValue &Dest, GenericValue Src1,
+ GenericValue Src2, const Type *Ty) {
switch (Ty->getTypeID()) {
- IMPLEMENT_INTEGER_BINOP1(*, Ty);
IMPLEMENT_BINARY_OPERATOR(*, Float);
IMPLEMENT_BINARY_OPERATOR(*, Double);
default:
- cerr << "Unhandled type for Mul instruction: " << *Ty << "\n";
+ cerr << "Unhandled type for FMul instruction: " << *Ty << "\n";
abort();
}
}
@@ -550,11 +540,14 @@ void Interpreter::visitBinaryOperator(BinaryOperator &I) {
GenericValue R; // Result
switch (I.getOpcode()) {
- case Instruction::Add: executeAddInst (R, Src1, Src2, Ty); break;
- case Instruction::Sub: executeSubInst (R, Src1, Src2, Ty); break;
- case Instruction::Mul: executeMulInst (R, Src1, Src2, Ty); break;
- case Instruction::FDiv: executeFDivInst (R, Src1, Src2, Ty); break;
- case Instruction::FRem: executeFRemInst (R, Src1, Src2, Ty); break;
+ case Instruction::Add: R.IntVal = Src1.IntVal + Src2.IntVal; break;
+ case Instruction::Sub: R.IntVal = Src1.IntVal - Src2.IntVal; break;
+ case Instruction::Mul: R.IntVal = Src1.IntVal * Src2.IntVal; break;
+ case Instruction::FAdd: executeFAddInst(R, Src1, Src2, Ty); break;
+ case Instruction::FSub: executeFSubInst(R, Src1, Src2, Ty); break;
+ case Instruction::FMul: executeFMulInst(R, Src1, Src2, Ty); break;
+ case Instruction::FDiv: executeFDivInst(R, Src1, Src2, Ty); break;
+ case Instruction::FRem: executeFRemInst(R, Src1, Src2, Ty); break;
case Instruction::UDiv: R.IntVal = Src1.IntVal.udiv(Src2.IntVal); break;
case Instruction::SDiv: R.IntVal = Src1.IntVal.sdiv(Src2.IntVal); break;
case Instruction::URem: R.IntVal = Src1.IntVal.urem(Src2.IntVal); break;
@@ -1258,18 +1251,21 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
GenericValue Dest;
const Type * Ty = CE->getOperand(0)->getType();
switch (CE->getOpcode()) {
- case Instruction::Add: executeAddInst (Dest, Op0, Op1, Ty); break;
- case Instruction::Sub: executeSubInst (Dest, Op0, Op1, Ty); break;
- case Instruction::Mul: executeMulInst (Dest, Op0, Op1, Ty); break;
+ case Instruction::Add: Dest.IntVal = Op0.IntVal + Op1.IntVal; break;
+ case Instruction::Sub: Dest.IntVal = Op0.IntVal - Op1.IntVal; break;
+ case Instruction::Mul: Dest.IntVal = Op0.IntVal * Op1.IntVal; break;
+ case Instruction::FAdd: executeFAddInst(Dest, Op0, Op1, Ty); break;
+ case Instruction::FSub: executeFSubInst(Dest, Op0, Op1, Ty); break;
+ case Instruction::FMul: executeFMulInst(Dest, Op0, Op1, Ty); break;
case Instruction::FDiv: executeFDivInst(Dest, Op0, Op1, Ty); break;
case Instruction::FRem: executeFRemInst(Dest, Op0, Op1, Ty); break;
case Instruction::SDiv: Dest.IntVal = Op0.IntVal.sdiv(Op1.IntVal); break;
case Instruction::UDiv: Dest.IntVal = Op0.IntVal.udiv(Op1.IntVal); break;
case Instruction::URem: Dest.IntVal = Op0.IntVal.urem(Op1.IntVal); break;
case Instruction::SRem: Dest.IntVal = Op0.IntVal.srem(Op1.IntVal); break;
- case Instruction::And: Dest.IntVal = Op0.IntVal.And(Op1.IntVal); break;
- case Instruction::Or: Dest.IntVal = Op0.IntVal.Or(Op1.IntVal); break;
- case Instruction::Xor: Dest.IntVal = Op0.IntVal.Xor(Op1.IntVal); break;
+ case Instruction::And: Dest.IntVal = Op0.IntVal & Op1.IntVal; break;
+ case Instruction::Or: Dest.IntVal = Op0.IntVal | Op1.IntVal; break;
+ case Instruction::Xor: Dest.IntVal = Op0.IntVal ^ Op1.IntVal; break;
case Instruction::Shl:
Dest.IntVal = Op0.IntVal.shl(Op1.IntVal.getZExtValue());
break;
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp
index d3b0820c5f0..43f23e44342 100644
--- a/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -891,8 +891,11 @@ unsigned JITEmitter::addSizeOfGlobalsInConstantVal(const Constant *C,
break;
}
case Instruction::Add:
+ case Instruction::FAdd:
case Instruction::Sub:
+ case Instruction::FSub:
case Instruction::Mul:
+ case Instruction::FMul:
case Instruction::UDiv:
case Instruction::SDiv:
case Instruction::URem:
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 4d7b54503e8..ed3ff8171f2 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -1000,8 +1000,11 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
Out << ')';
return;
case Instruction::Add:
+ case Instruction::FAdd:
case Instruction::Sub:
+ case Instruction::FSub:
case Instruction::Mul:
+ case Instruction::FMul:
case Instruction::SDiv:
case Instruction::UDiv:
case Instruction::FDiv:
@@ -1020,9 +1023,12 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
bool NeedsClosingParens = printConstExprCast(CE, Static);
printConstantWithCast(CE->getOperand(0), CE->getOpcode());
switch (CE->getOpcode()) {
- case Instruction::Add: Out << " + "; break;
- case Instruction::Sub: Out << " - "; break;
- case Instruction::Mul: Out << " * "; break;
+ case Instruction::Add:
+ case Instruction::FAdd: Out << " + "; break;
+ case Instruction::Sub:
+ case Instruction::FSub: Out << " - "; break;
+ case Instruction::Mul:
+ case Instruction::FMul: Out << " * "; break;
case Instruction::URem:
case Instruction::SRem:
case Instruction::FRem: Out << " % "; break;
@@ -1322,8 +1328,6 @@ bool CWriter::printConstExprCast(const ConstantExpr* CE, bool Static) {
case Instruction::Mul:
// We need to cast integer arithmetic so that it is always performed
// as unsigned, to avoid undefined behavior on overflow.
- if (!Ty->isIntOrIntVector()) break;
- // FALL THROUGH
case Instruction::LShr:
case Instruction::URem:
case Instruction::UDiv: NeedsExplicitCast = true; break;
@@ -1387,8 +1391,6 @@ void CWriter::printConstantWithCast(Constant* CPV, unsigned Opcode) {
case Instruction::Mul:
// We need to cast integer arithmetic so that it is always performed
// as unsigned, to avoid undefined behavior on overflow.
- if (!OpTy->isIntOrIntVector()) break;
- // FALL THROUGH
case Instruction::LShr:
case Instruction::UDiv:
case Instruction::URem:
@@ -1505,8 +1507,6 @@ bool CWriter::writeInstructionCast(const Instruction &I) {
case Instruction::Mul:
// We need to cast integer arithmetic so that it is always performed
// as unsigned, to avoid undefined behavior on overflow.
- if (!Ty->isIntOrIntVector()) break;
- // FALL THROUGH
case Instruction::LShr:
case Instruction::URem:
case Instruction::UDiv:
@@ -1552,8 +1552,6 @@ void CWriter::writeOperandWithCast(Value* Operand, unsigned Opcode) {
case Instruction::Mul:
// We need to cast integer arithmetic so that it is always performed
// as unsigned, to avoid undefined behavior on overflow.
- if (!OpTy->isIntOrIntVector()) break;
- // FALL THROUGH
case Instruction::LShr:
case Instruction::UDiv:
case Instruction::URem: // Cast to unsigned first
@@ -2602,10 +2600,14 @@ void CWriter::visitBinaryOperator(Instruction &I) {
// If this is a negation operation, print it out as such. For FP, we don't
// want to print "-0.0 - X".
- if (BinaryOperator::isNeg(&I)) {
+ if (BinaryOperator::isNeg(&I) || BinaryOperator::isFNeg(&I)) {
Out << "-(";
writeOperand(BinaryOperator::getNegArgument(cast(&I)));
Out << ")";
+ } else if (BinaryOperator::isFNeg(&I)) {
+ Out << "-(";
+ writeOperand(BinaryOperator::getFNegArgument(cast(&I)));
+ Out << ")";
} else if (I.getOpcode() == Instruction::FRem) {
// Output a call to fmod/fmodf instead of emitting a%b
if (I.getType() == Type::FloatTy)
@@ -2630,9 +2632,12 @@ void CWriter::visitBinaryOperator(Instruction &I) {
writeOperandWithCast(I.getOperand(0), I.getOpcode());
switch (I.getOpcode()) {
- case Instruction::Add: Out << " + "; break;
- case Instruction::Sub: Out << " - "; break;
- case Instruction::Mul: Out << " * "; break;
+ case Instruction::Add:
+ case Instruction::FAdd: Out << " + "; break;
+ case Instruction::Sub:
+ case Instruction::FSub: Out << " - "; break;
+ case Instruction::Mul:
+ case Instruction::FMul: Out << " * "; break;
case Instruction::URem:
case Instruction::SRem:
case Instruction::FRem: Out << " % "; break;
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index 4082989c4c4..04a6829d9cf 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -865,8 +865,11 @@ namespace {
Out << "Constant* " << constName << " = ConstantExpr::";
switch (CE->getOpcode()) {
case Instruction::Add: Out << "getAdd("; break;
+ case Instruction::FAdd: Out << "getFAdd("; break;
case Instruction::Sub: Out << "getSub("; break;
+ case Instruction::FSub: Out << "getFSub("; break;
case Instruction::Mul: Out << "getMul("; break;
+ case Instruction::FMul: Out << "getFMul("; break;
case Instruction::UDiv: Out << "getUDiv("; break;
case Instruction::SDiv: Out << "getSDiv("; break;
case Instruction::FDiv: Out << "getFDiv("; break;
@@ -1159,8 +1162,11 @@ namespace {
break;
}
case Instruction::Add:
+ case Instruction::FAdd:
case Instruction::Sub:
+ case Instruction::FSub:
case Instruction::Mul:
+ case Instruction::FMul:
case Instruction::UDiv:
case Instruction::SDiv:
case Instruction::FDiv:
@@ -1176,8 +1182,11 @@ namespace {
Out << "BinaryOperator* " << iName << " = BinaryOperator::Create(";
switch (I->getOpcode()) {
case Instruction::Add: Out << "Instruction::Add"; break;
+ case Instruction::FAdd: Out << "Instruction::FAdd"; break;
case Instruction::Sub: Out << "Instruction::Sub"; break;
+ case Instruction::FSub: Out << "Instruction::FSub"; break;
case Instruction::Mul: Out << "Instruction::Mul"; break;
+ case Instruction::FMul: Out << "Instruction::FMul"; break;
case Instruction::UDiv:Out << "Instruction::UDiv"; break;
case Instruction::SDiv:Out << "Instruction::SDiv"; break;
case Instruction::FDiv:Out << "Instruction::FDiv"; break;
diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp
index ada851d4f22..37e5b1eccde 100644
--- a/lib/Target/MSIL/MSILWriter.cpp
+++ b/lib/Target/MSIL/MSILWriter.cpp
@@ -1060,12 +1060,15 @@ void MSILWriter::printInstruction(const Instruction* Inst) {
break;
// Binary
case Instruction::Add:
+ case Instruction::FAdd:
printBinaryInstruction("add",Left,Right);
break;
case Instruction::Sub:
+ case Instruction::FSub:
printBinaryInstruction("sub",Left,Right);
break;
- case Instruction::Mul:
+ case Instruction::Mul:
+ case Instruction::FMul:
printBinaryInstruction("mul",Left,Right);
break;
case Instruction::UDiv:
@@ -1322,12 +1325,15 @@ void MSILWriter::printConstantExpr(const ConstantExpr* CE) {
printSelectInstruction(CE->getOperand(0),CE->getOperand(1),CE->getOperand(2));
break;
case Instruction::Add:
+ case Instruction::FAdd:
printBinaryInstruction("add",left,right);
break;
case Instruction::Sub:
+ case Instruction::FSub:
printBinaryInstruction("sub",left,right);
break;
case Instruction::Mul:
+ case Instruction::FMul:
printBinaryInstruction("mul",left,right);
break;
case Instruction::UDiv:
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 733dfa97a15..673d38b7f3a 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -59,7 +59,8 @@ cl::opt EnableLoadPRE("enable-load-pre", cl::init(true));
/// two values.
namespace {
struct VISIBILITY_HIDDEN Expression {
- enum ExpressionOpcode { ADD, SUB, MUL, UDIV, SDIV, FDIV, UREM, SREM,
+ enum ExpressionOpcode { ADD, FADD, SUB, FSUB, MUL, FMUL,
+ UDIV, SDIV, FDIV, UREM, SREM,
FREM, SHL, LSHR, ASHR, AND, OR, XOR, ICMPEQ,
ICMPNE, ICMPUGT, ICMPUGE, ICMPULT, ICMPULE,
ICMPSGT, ICMPSGE, ICMPSLT, ICMPSLE, FCMPOEQ,
@@ -200,8 +201,11 @@ Expression::ExpressionOpcode ValueTable::getOpcode(BinaryOperator* BO) {
default: // THIS SHOULD NEVER HAPPEN
assert(0 && "Binary operator with unknown opcode?");
case Instruction::Add: return Expression::ADD;
+ case Instruction::FAdd: return Expression::FADD;
case Instruction::Sub: return Expression::SUB;
+ case Instruction::FSub: return Expression::FSUB;
case Instruction::Mul: return Expression::MUL;
+ case Instruction::FMul: return Expression::FMUL;
case Instruction::UDiv: return Expression::UDIV;
case Instruction::SDiv: return Expression::SDIV;
case Instruction::FDiv: return Expression::FDIV;
diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp
index e3b09379a22..0f3153f2a7b 100644
--- a/lib/Transforms/Scalar/GVNPRE.cpp
+++ b/lib/Transforms/Scalar/GVNPRE.cpp
@@ -55,7 +55,8 @@ namespace {
/// two values.
struct Expression {
- enum ExpressionOpcode { ADD, SUB, MUL, UDIV, SDIV, FDIV, UREM, SREM,
+ enum ExpressionOpcode { ADD, FADD, SUB, FSUB, MUL, FMUL,
+ UDIV, SDIV, FDIV, UREM, SREM,
FREM, SHL, LSHR, ASHR, AND, OR, XOR, ICMPEQ,
ICMPNE, ICMPUGT, ICMPUGE, ICMPULT, ICMPULE,
ICMPSGT, ICMPSGE, ICMPSLT, ICMPSLE, FCMPOEQ,
@@ -202,10 +203,16 @@ Expression::ExpressionOpcode
switch(BO->getOpcode()) {
case Instruction::Add:
return Expression::ADD;
+ case Instruction::FAdd:
+ return Expression::FADD;
case Instruction::Sub:
return Expression::SUB;
+ case Instruction::FSub:
+ return Expression::FSUB;
case Instruction::Mul:
return Expression::MUL;
+ case Instruction::FMul:
+ return Expression::FMUL;
case Instruction::UDiv:
return Expression::UDIV;
case Instruction::SDiv:
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index af61eae16f8..83503fdea24 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -754,7 +754,7 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
BinaryOperator *Incr =
dyn_cast(PH->getIncomingValue(BackEdge));
if (!Incr) return;
- if (Incr->getOpcode() != Instruction::Add) return;
+ if (Incr->getOpcode() != Instruction::FAdd) return;
ConstantFP *IncrValue = NULL;
unsigned IncrVIndex = 1;
if (Incr->getOperand(1) == PH)
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 8bb16f3de19..97bd34c771c 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -167,8 +167,11 @@ namespace {
// otherwise - Change was made, replace I with returned instruction
//
Instruction *visitAdd(BinaryOperator &I);
+ Instruction *visitFAdd(BinaryOperator &I);
Instruction *visitSub(BinaryOperator &I);
+ Instruction *visitFSub(BinaryOperator &I);
Instruction *visitMul(BinaryOperator &I);
+ Instruction *visitFMul(BinaryOperator &I);
Instruction *visitURem(BinaryOperator &I);
Instruction *visitSRem(BinaryOperator &I);
Instruction *visitFRem(BinaryOperator &I);
@@ -403,7 +406,8 @@ X("instcombine", "Combine redundant instructions");
// 0 -> undef, 1 -> Const, 2 -> Other, 3 -> Arg, 3 -> Unary, 4 -> OtherInst
static unsigned getComplexity(Value *V) {
if (isa(V)) {
- if (BinaryOperator::isNeg(V) || BinaryOperator::isNot(V))
+ if (BinaryOperator::isNeg(V) || BinaryOperator::isFNeg(V) ||
+ BinaryOperator::isNot(V))
return 3;
return 4;
}
@@ -576,6 +580,25 @@ static inline Value *dyn_castNegVal(Value *V) {
return 0;
}
+// dyn_castFNegVal - Given a 'fsub' instruction, return the RHS of the
+// instruction if the LHS is a constant negative zero (which is the 'negate'
+// form).
+//
+static inline Value *dyn_castFNegVal(Value *V) {
+ if (BinaryOperator::isFNeg(V))
+ return BinaryOperator::getFNegArgument(V);
+
+ // Constants can be considered to be negated values if they can be folded.
+ if (ConstantFP *C = dyn_cast(V))
+ return ConstantExpr::getFNeg(C);
+
+ if (ConstantVector *C = dyn_cast(V))
+ if (C->getType()->getElementType()->isFloatingPoint())
+ return ConstantExpr::getFNeg(C);
+
+ return 0;
+}
+
static inline Value *dyn_castNotVal(Value *V) {
if (BinaryOperator::isNot(V))
return BinaryOperator::getNotArgument(V);
@@ -1733,12 +1756,12 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
default: assert(0 && "Case stmts out of sync!");
case Intrinsic::x86_sse_sub_ss:
case Intrinsic::x86_sse2_sub_sd:
- TmpV = InsertNewInstBefore(BinaryOperator::CreateSub(LHS, RHS,
+ TmpV = InsertNewInstBefore(BinaryOperator::CreateFSub(LHS, RHS,
II->getName()), *II);
break;
case Intrinsic::x86_sse_mul_ss:
case Intrinsic::x86_sse2_mul_sd:
- TmpV = InsertNewInstBefore(BinaryOperator::CreateMul(LHS, RHS,
+ TmpV = InsertNewInstBefore(BinaryOperator::CreateFMul(LHS, RHS,
II->getName()), *II);
break;
}
@@ -2052,14 +2075,8 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
return ReplaceInstUsesWith(I, RHS);
// X + 0 --> X
- if (!I.getType()->isFPOrFPVector()) { // NOTE: -0 + +0 = +0.
- if (RHSC->isNullValue())
- return ReplaceInstUsesWith(I, LHS);
- } else if (ConstantFP *CFP = dyn_cast(RHSC)) {
- if (CFP->isExactlyValue(ConstantFP::getNegativeZero
- (I.getType())->getValueAPF()))
- return ReplaceInstUsesWith(I, LHS);
- }
+ if (RHSC->isNullValue())
+ return ReplaceInstUsesWith(I, LHS);
if (ConstantInt *CI = dyn_cast(RHSC)) {
// X + (signbit) --> X ^ signbit
@@ -2317,11 +2334,6 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
return SelectInst::Create(SI->getCondition(), A, N);
}
}
-
- // Check for X+0.0. Simplify it to X if we know X is not -0.0.
- if (ConstantFP *CFP = dyn_cast(RHS))
- if (CFP->getValueAPF().isPosZero() && CannotBeNegativeZero(LHS))
- return ReplaceInstUsesWith(I, LHS);
// Check for (add (sext x), y), see if we can merge this into an
// integer add followed by a sext.
@@ -2359,7 +2371,42 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
}
}
}
-
+
+ return Changed ? &I : 0;
+}
+
+Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
+ bool Changed = SimplifyCommutative(I);
+ Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
+
+ if (Constant *RHSC = dyn_cast(RHS)) {
+ // X + 0 --> X
+ if (ConstantFP *CFP = dyn_cast(RHSC)) {
+ if (CFP->isExactlyValue(ConstantFP::getNegativeZero
+ (I.getType())->getValueAPF()))
+ return ReplaceInstUsesWith(I, LHS);
+ }
+
+ if (isa(LHS))
+ if (Instruction *NV = FoldOpIntoPhi(I))
+ return NV;
+ }
+
+ // -A + B --> B - A
+ // -A + -B --> -(A + B)
+ if (Value *LHSV = dyn_castFNegVal(LHS))
+ return BinaryOperator::CreateFSub(RHS, LHSV);
+
+ // A + -B --> A - B
+ if (!isa(RHS))
+ if (Value *V = dyn_castFNegVal(RHS))
+ return BinaryOperator::CreateFSub(LHS, V);
+
+ // Check for X+0.0. Simplify it to X if we know X is not -0.0.
+ if (ConstantFP *CFP = dyn_cast(RHS))
+ if (CFP->getValueAPF().isPosZero() && CannotBeNegativeZero(LHS))
+ return ReplaceInstUsesWith(I, LHS);
+
// Check for (add double (sitofp x), y), see if we can merge this into an
// integer add followed by a promotion.
if (SIToFPInst *LHSConv = dyn_cast(LHS)) {
@@ -2407,8 +2454,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
Instruction *InstCombiner::visitSub(BinaryOperator &I) {
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
- if (Op0 == Op1 && // sub X, X -> 0
- !I.getType()->isFPOrFPVector())
+ if (Op0 == Op1) // sub X, X -> 0
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
// If this is a 'B = x-(-A)', change to B = x+A...
@@ -2469,8 +2515,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
return BinaryOperator::CreateXor(Op0, Op1);
if (BinaryOperator *Op1I = dyn_cast(Op1)) {
- if (Op1I->getOpcode() == Instruction::Add &&
- !Op0->getType()->isFPOrFPVector()) {
+ if (Op1I->getOpcode() == Instruction::Add) {
if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y
return BinaryOperator::CreateNeg(Op1I->getOperand(1), I.getName());
else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y
@@ -2487,8 +2532,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
// Replace (x - (y - z)) with (x + (z - y)) if the (y - z) subexpression
// is not used by anyone else...
//
- if (Op1I->getOpcode() == Instruction::Sub &&
- !Op1I->getType()->isFPOrFPVector()) {
+ if (Op1I->getOpcode() == Instruction::Sub) {
// Swap the two operands of the subexpr...
Value *IIOp0 = Op1I->getOperand(0), *IIOp1 = Op1I->getOperand(1);
Op1I->setOperand(0, IIOp1);
@@ -2526,18 +2570,17 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
}
}
- if (!Op0->getType()->isFPOrFPVector())
- if (BinaryOperator *Op0I = dyn_cast(Op0)) {
- if (Op0I->getOpcode() == Instruction::Add) {
- if (Op0I->getOperand(0) == Op1) // (Y+X)-Y == X
- return ReplaceInstUsesWith(I, Op0I->getOperand(1));
- else if (Op0I->getOperand(1) == Op1) // (X+Y)-Y == X
- return ReplaceInstUsesWith(I, Op0I->getOperand(0));
- } else if (Op0I->getOpcode() == Instruction::Sub) {
- if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y
- return BinaryOperator::CreateNeg(Op0I->getOperand(1), I.getName());
- }
+ if (BinaryOperator *Op0I = dyn_cast(Op0)) {
+ if (Op0I->getOpcode() == Instruction::Add) {
+ if (Op0I->getOperand(0) == Op1) // (Y+X)-Y == X
+ return ReplaceInstUsesWith(I, Op0I->getOperand(1));
+ else if (Op0I->getOperand(1) == Op1) // (X+Y)-Y == X
+ return ReplaceInstUsesWith(I, Op0I->getOperand(0));
+ } else if (Op0I->getOpcode() == Instruction::Sub) {
+ if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y
+ return BinaryOperator::CreateNeg(Op0I->getOperand(1), I.getName());
}
+ }
ConstantInt *C1;
if (Value *X = dyn_castFoldableMul(Op0, C1)) {
@@ -2551,6 +2594,40 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
return 0;
}
+Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
+ Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
+
+ // If this is a 'B = x-(-A)', change to B = x+A...
+ if (Value *V = dyn_castFNegVal(Op1))
+ return BinaryOperator::CreateFAdd(Op0, V);
+
+ if (BinaryOperator *Op1I = dyn_cast(Op1)) {
+ if (Op1I->getOpcode() == Instruction::FAdd) {
+ if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y
+ return BinaryOperator::CreateFNeg(Op1I->getOperand(1), I.getName());
+ else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y
+ return BinaryOperator::CreateFNeg(Op1I->getOperand(0), I.getName());
+ }
+
+ if (Op1I->hasOneUse()) {
+ // Replace (x - (y - z)) with (x + (z - y)) if the (y - z) subexpression
+ // is not used by anyone else...
+ //
+ if (Op1I->getOpcode() == Instruction::FSub) {
+ // Swap the two operands of the subexpr...
+ Value *IIOp0 = Op1I->getOperand(0), *IIOp1 = Op1I->getOperand(1);
+ Op1I->setOperand(0, IIOp1);
+ Op1I->setOperand(1, IIOp0);
+
+ // Create the new top level fadd instruction...
+ return BinaryOperator::CreateFAdd(Op0, Op1);
+ }
+ }
+ }
+
+ return 0;
+}
+
/// isSignBitCheck - Given an exploded icmp instruction, return true if the
/// comparison only checks the sign bit. If it only checks the sign bit, set
/// TrueIfSigned if the result of the comparison is true when the input value is
@@ -2613,13 +2690,6 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
return BinaryOperator::CreateShl(Op0,
ConstantInt::get(Op0->getType(), Val.logBase2()));
}
- } else if (ConstantFP *Op1F = dyn_cast(Op1)) {
- // TODO: If Op1 is zero and Op0 is finite, return zero.
-
- // "In IEEE floating point, x*1 is not equivalent to x for nans. However,
- // ANSI says we can drop signals, so we can do this anyway." (from GCC)
- if (Op1F->isExactlyValue(1.0))
- return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
} else if (isa(Op1->getType())) {
// TODO: If Op1 is all zeros and Op0 is all finite, return all zeros.
@@ -2629,9 +2699,6 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
// As above, vector X*splat(1.0) -> X in all defined cases.
if (Constant *Splat = Op1V->getSplatValue()) {
- if (ConstantFP *F = dyn_cast(Splat))
- if (F->isExactlyValue(1.0))
- return ReplaceInstUsesWith(I, Op0);
if (ConstantInt *CI = dyn_cast(Splat))
if (CI->equalsInt(1))
return ReplaceInstUsesWith(I, Op0);
@@ -2755,6 +2822,45 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
return Changed ? &I : 0;
}
+Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
+ bool Changed = SimplifyCommutative(I);
+ Value *Op0 = I.getOperand(0);
+
+ // Simplify mul instructions with a constant RHS...
+ if (Constant *Op1 = dyn_cast(I.getOperand(1))) {
+ if (ConstantFP *Op1F = dyn_cast(Op1)) {
+ // "In IEEE floating point, x*1 is not equivalent to x for nans. However,
+ // ANSI says we can drop signals, so we can do this anyway." (from GCC)
+ if (Op1F->isExactlyValue(1.0))
+ return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
+ } else if (isa(Op1->getType())) {
+ if (ConstantVector *Op1V = dyn_cast(Op1)) {
+ // As above, vector X*splat(1.0) -> X in all defined cases.
+ if (Constant *Splat = Op1V->getSplatValue()) {
+ if (ConstantFP *F = dyn_cast(Splat))
+ if (F->isExactlyValue(1.0))
+ return ReplaceInstUsesWith(I, Op0);
+ }
+ }
+ }
+
+ // Try to fold constant mul into select arguments.
+ if (SelectInst *SI = dyn_cast(Op0))
+ if (Instruction *R = FoldOpIntoSelect(I, SI, this))
+ return R;
+
+ if (isa(Op0))
+ if (Instruction *NV = FoldOpIntoPhi(I))
+ return NV;
+ }
+
+ if (Value *Op0v = dyn_castFNegVal(Op0)) // -X * -Y = X*Y
+ if (Value *Op1v = dyn_castFNegVal(I.getOperand(1)))
+ return BinaryOperator::CreateFMul(Op0v, Op1v);
+
+ return Changed ? &I : 0;
+}
+
/// SimplifyDivRemOfSelect - Try to fold a divide or remainder of a select
/// instruction.
bool InstCombiner::SimplifyDivRemOfSelect(BinaryOperator &I) {
@@ -8562,17 +8668,17 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
if (Instruction *I = commonCastTransforms(CI))
return I;
- // If we have fptrunc(add (fpextend x), (fpextend y)), where x and y are
+ // If we have fptrunc(fadd (fpextend x), (fpextend y)), where x and y are
// smaller than the destination type, we can eliminate the truncate by doing
- // the add as the smaller type. This applies to add/sub/mul/div as well as
+ // the add as the smaller type. This applies to fadd/fsub/fmul/fdiv as well as
// many builtins (sqrt, etc).
BinaryOperator *OpI = dyn_cast(CI.getOperand(0));
if (OpI && OpI->hasOneUse()) {
switch (OpI->getOpcode()) {
default: break;
- case Instruction::Add:
- case Instruction::Sub:
- case Instruction::Mul:
+ case Instruction::FAdd:
+ case Instruction::FSub:
+ case Instruction::FMul:
case Instruction::FDiv:
case Instruction::FRem:
const Type *SrcTy = OpI->getType();
@@ -9322,11 +9428,15 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
// Turn select C, (X+Y), (X-Y) --> (X+(select C, Y, (-Y))). This is
// even legal for FP.
- if (TI->getOpcode() == Instruction::Sub &&
- FI->getOpcode() == Instruction::Add) {
+ if ((TI->getOpcode() == Instruction::Sub &&
+ FI->getOpcode() == Instruction::Add) ||
+ (TI->getOpcode() == Instruction::FSub &&
+ FI->getOpcode() == Instruction::FAdd)) {
AddOp = FI; SubOp = TI;
- } else if (FI->getOpcode() == Instruction::Sub &&
- TI->getOpcode() == Instruction::Add) {
+ } else if ((FI->getOpcode() == Instruction::Sub &&
+ TI->getOpcode() == Instruction::Add) ||
+ (FI->getOpcode() == Instruction::FSub &&
+ TI->getOpcode() == Instruction::FAdd)) {
AddOp = TI; SubOp = FI;
}
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 92270b5b647..f05afeca32a 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -2268,7 +2268,8 @@ void LoopStrengthReduce::OptimizeShadowIV(Loop *L) {
/* create new increment. '++d' in above example. */
ConstantFP *CFP = ConstantFP::get(DestTy, C->getZExtValue());
BinaryOperator *NewIncr =
- BinaryOperator::Create(Incr->getOpcode(),
+ BinaryOperator::Create(Incr->getOpcode() == Instruction::Add ?
+ Instruction::FAdd : Instruction::FSub,
NewPH, CFP, "IV.S.next.", Incr);
NewPH->addIncoming(NewInit, PH->getIncomingBlock(Entry));
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index 4b0064090cf..59989c92d74 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -1009,7 +1009,7 @@ struct VISIBILITY_HIDDEN PowOpt : public LibCallOptimization {
if (Op2C->isExactlyValue(1.0)) // pow(x, 1.0) -> x
return Op1;
if (Op2C->isExactlyValue(2.0)) // pow(x, 2.0) -> x*x
- return B.CreateMul(Op1, Op1, "pow2");
+ return B.CreateFMul(Op1, Op1, "pow2");
if (Op2C->isExactlyValue(-1.0)) // pow(x, -1.0) -> 1.0/x
return B.CreateFDiv(ConstantFP::get(CI->getType(), 1.0), Op1, "powrecip");
return 0;
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 2cde765560b..bcc6b819013 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -419,9 +419,6 @@ static bool DominatesMergePoint(Value *V, BasicBlock *BB,
case Instruction::LShr:
case Instruction::AShr:
case Instruction::ICmp:
- case Instruction::FCmp:
- if (I->getOperand(0)->getType()->isFPOrFPVector())
- return false; // FP arithmetic might trap.
break; // These are all cheap and non-trapping instructions.
}
@@ -1012,9 +1009,8 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *BB1) {
default: return false; // Not safe / profitable to hoist.
case Instruction::Add:
case Instruction::Sub:
- // FP arithmetic might trap. Not worth doing for vector ops.
- if (HInst->getType()->isFloatingPoint()
- || isa(HInst->getType()))
+ // Not worth doing for vector ops.
+ if (isa(HInst->getType()))
return false;
break;
case Instruction::And:
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 7e4902fd563..1d293ccbd44 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -602,10 +602,8 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
return Constant::getNullValue(C1->getType());
case Instruction::UDiv:
case Instruction::SDiv:
- case Instruction::FDiv:
case Instruction::URem:
case Instruction::SRem:
- case Instruction::FRem:
if (!isa(C2)) // undef / X -> 0
return Constant::getNullValue(C1->getType());
return const_cast(C2); // X / undef -> undef
@@ -783,13 +781,13 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
switch (Opcode) {
default:
break;
- case Instruction::Add:
+ case Instruction::FAdd:
(void)C3V.add(C2V, APFloat::rmNearestTiesToEven);
return ConstantFP::get(C3V);
- case Instruction::Sub:
+ case Instruction::FSub:
(void)C3V.subtract(C2V, APFloat::rmNearestTiesToEven);
return ConstantFP::get(C3V);
- case Instruction::Mul:
+ case Instruction::FMul:
(void)C3V.multiply(C2V, APFloat::rmNearestTiesToEven);
return ConstantFP::get(C3V);
case Instruction::FDiv:
@@ -808,12 +806,18 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
switch (Opcode) {
default:
break;
- case Instruction::Add:
+ case Instruction::Add:
return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getAdd);
- case Instruction::Sub:
+ case Instruction::FAdd:
+ return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFAdd);
+ case Instruction::Sub:
return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getSub);
- case Instruction::Mul:
+ case Instruction::FSub:
+ return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFSub);
+ case Instruction::Mul:
return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getMul);
+ case Instruction::FMul:
+ return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFMul);
case Instruction::UDiv:
return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getUDiv);
case Instruction::SDiv:
@@ -851,7 +855,9 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
// other way if possible.
switch (Opcode) {
case Instruction::Add:
+ case Instruction::FAdd:
case Instruction::Mul:
+ case Instruction::FMul:
case Instruction::And:
case Instruction::Or:
case Instruction::Xor:
@@ -862,6 +868,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
case Instruction::LShr:
case Instruction::AShr:
case Instruction::Sub:
+ case Instruction::FSub:
case Instruction::SDiv:
case Instruction::UDiv:
case Instruction::FDiv:
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 97f3ac9c270..69c503dff95 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -775,26 +775,46 @@ const SmallVector &ConstantExpr::getIndices() const {
/// specify the full Instruction::OPCODE identifier.
///
Constant *ConstantExpr::getNeg(Constant *C) {
+ // API compatibility: Adjust integer opcodes to floating-point opcodes.
+ if (C->getType()->isFPOrFPVector())
+ return getFNeg(C);
+ assert(C->getType()->isIntOrIntVector() &&
+ "Cannot NEG a nonintegral value!");
return get(Instruction::Sub,
ConstantExpr::getZeroValueForNegationExpr(C->getType()),
C);
}
+Constant *ConstantExpr::getFNeg(Constant *C) {
+ assert(C->getType()->isFPOrFPVector() &&
+ "Cannot FNEG a non-floating-point value!");
+ return get(Instruction::FSub,
+ ConstantExpr::getZeroValueForNegationExpr(C->getType()),
+ C);
+}
Constant *ConstantExpr::getNot(Constant *C) {
- assert((isa(C->getType()) ||
- cast(C->getType())->getElementType()->isInteger()) &&
- "Cannot NOT a nonintegral value!");
+ assert(C->getType()->isIntOrIntVector() &&
+ "Cannot NOT a nonintegral value!");
return get(Instruction::Xor, C,
Constant::getAllOnesValue(C->getType()));
}
Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2) {
return get(Instruction::Add, C1, C2);
}
+Constant *ConstantExpr::getFAdd(Constant *C1, Constant *C2) {
+ return get(Instruction::FAdd, C1, C2);
+}
Constant *ConstantExpr::getSub(Constant *C1, Constant *C2) {
return get(Instruction::Sub, C1, C2);
}
+Constant *ConstantExpr::getFSub(Constant *C1, Constant *C2) {
+ return get(Instruction::FSub, C1, C2);
+}
Constant *ConstantExpr::getMul(Constant *C1, Constant *C2) {
return get(Instruction::Mul, C1, C2);
}
+Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2) {
+ return get(Instruction::FMul, C1, C2);
+}
Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2) {
return get(Instruction::UDiv, C1, C2);
}
@@ -2142,15 +2162,28 @@ Constant *ConstantExpr::getCompareTy(unsigned short predicate,
}
Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
+ // API compatibility: Adjust integer opcodes to floating-point opcodes.
+ if (C1->getType()->isFPOrFPVector()) {
+ if (Opcode == Instruction::Add) Opcode = Instruction::FAdd;
+ else if (Opcode == Instruction::Sub) Opcode = Instruction::FSub;
+ else if (Opcode == Instruction::Mul) Opcode = Instruction::FMul;
+ }
#ifndef NDEBUG
switch (Opcode) {
- case Instruction::Add:
+ case Instruction::Add:
case Instruction::Sub:
- case Instruction::Mul:
+ case Instruction::Mul:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
- assert((C1->getType()->isInteger() || C1->getType()->isFloatingPoint() ||
- isa(C1->getType())) &&
- "Tried to create an arithmetic operation on a non-arithmetic type!");
+ assert(C1->getType()->isIntOrIntVector() &&
+ "Tried to create an integer operation on a non-integer type!");
+ break;
+ case Instruction::FAdd:
+ case Instruction::FSub:
+ case Instruction::FMul:
+ assert(C1->getType() == C2->getType() && "Op types should be identical!");
+ assert(C1->getType()->isFPOrFPVector() &&
+ "Tried to create a floating-point operation on a "
+ "non-floating-point type!");
break;
case Instruction::UDiv:
case Instruction::SDiv:
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 9e030b78e9e..7556b8ebe76 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -101,8 +101,11 @@ const char *Instruction::getOpcodeName(unsigned OpCode) {
// Standard binary operators...
case Add: return "add";
+ case FAdd: return "fadd";
case Sub: return "sub";
+ case FSub: return "fsub";
case Mul: return "mul";
+ case FMul: return "fmul";
case UDiv: return "udiv";
case SDiv: return "sdiv";
case FDiv: return "fdiv";
@@ -330,19 +333,13 @@ bool Instruction::mayThrow() const {
/// isAssociative - Return true if the instruction is associative:
///
-/// Associative operators satisfy: x op (y op z) === (x op y) op z)
+/// Associative operators satisfy: x op (y op z) === (x op y) op z
///
-/// In LLVM, the Add, Mul, And, Or, and Xor operators are associative, when not
-/// applied to floating point types.
+/// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
///
bool Instruction::isAssociative(unsigned Opcode, const Type *Ty) {
- if (Opcode == And || Opcode == Or || Opcode == Xor)
- return true;
-
- // Add/Mul reassociate unless they are FP or FP vectors.
- if (Opcode == Add || Opcode == Mul)
- return !Ty->isFPOrFPVector();
- return 0;
+ return Opcode == And || Opcode == Or || Opcode == Xor ||
+ Opcode == Add || Opcode == Mul;
}
/// isCommutative - Return true if the instruction is commutative:
@@ -355,7 +352,9 @@ bool Instruction::isAssociative(unsigned Opcode, const Type *Ty) {
bool Instruction::isCommutative(unsigned op) {
switch (op) {
case Add:
+ case FAdd:
case Mul:
+ case FMul:
case And:
case Or:
case Xor:
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index fe30271f844..4c228fe81c0 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -1502,29 +1502,43 @@ const Type* ExtractValueInst::getIndexedType(const Type *Agg,
// BinaryOperator Class
//===----------------------------------------------------------------------===//
+/// AdjustIType - Map Add, Sub, and Mul to FAdd, FSub, and FMul when the
+/// type is floating-point, to help provide compatibility with an older API.
+///
+static BinaryOperator::BinaryOps AdjustIType(BinaryOperator::BinaryOps iType,
+ const Type *Ty) {
+ // API compatibility: Adjust integer opcodes to floating-point opcodes.
+ if (Ty->isFPOrFPVector()) {
+ if (iType == BinaryOperator::Add) iType = BinaryOperator::FAdd;
+ else if (iType == BinaryOperator::Sub) iType = BinaryOperator::FSub;
+ else if (iType == BinaryOperator::Mul) iType = BinaryOperator::FMul;
+ }
+ return iType;
+}
+
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
const Type *Ty, const std::string &Name,
Instruction *InsertBefore)
- : Instruction(Ty, iType,
+ : Instruction(Ty, AdjustIType(iType, Ty),
OperandTraits::op_begin(this),
OperandTraits::operands(this),
InsertBefore) {
Op<0>() = S1;
Op<1>() = S2;
- init(iType);
+ init(AdjustIType(iType, Ty));
setName(Name);
}
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
const Type *Ty, const std::string &Name,
BasicBlock *InsertAtEnd)
- : Instruction(Ty, iType,
+ : Instruction(Ty, AdjustIType(iType, Ty),
OperandTraits::op_begin(this),
OperandTraits::operands(this),
InsertAtEnd) {
Op<0>() = S1;
Op<1>() = S2;
- init(iType);
+ init(AdjustIType(iType, Ty));
setName(Name);
}
@@ -1537,12 +1551,19 @@ void BinaryOperator::init(BinaryOps iType) {
#ifndef NDEBUG
switch (iType) {
case Add: case Sub:
- case Mul:
+ case Mul:
+ assert(getType() == LHS->getType() &&
+ "Arithmetic operation should return same type as operands!");
+ assert(getType()->isIntOrIntVector() &&
+ "Tried to create an integer operation on a non-integer type!");
+ break;
+ case FAdd: case FSub:
+ case FMul:
assert(getType() == LHS->getType() &&
"Arithmetic operation should return same type as operands!");
- assert((getType()->isInteger() || getType()->isFloatingPoint() ||
- isa(getType())) &&
- "Tried to create an arithmetic operation on a non-arithmetic type!");
+ assert(getType()->isFPOrFPVector() &&
+ "Tried to create a floating-point operation on a "
+ "non-floating-point type!");
break;
case UDiv:
case SDiv:
@@ -1631,6 +1652,22 @@ BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const std::string &Name,
Op->getType(), Name, InsertAtEnd);
}
+BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const std::string &Name,
+ Instruction *InsertBefore) {
+ Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
+ return new BinaryOperator(Instruction::FSub,
+ zero, Op,
+ Op->getType(), Name, InsertBefore);
+}
+
+BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const std::string &Name,
+ BasicBlock *InsertAtEnd) {
+ Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
+ return new BinaryOperator(Instruction::FSub,
+ zero, Op,
+ Op->getType(), Name, InsertAtEnd);
+}
+
BinaryOperator *BinaryOperator::CreateNot(Value *Op, const std::string &Name,
Instruction *InsertBefore) {
Constant *C;
@@ -1679,6 +1716,14 @@ bool BinaryOperator::isNeg(const Value *V) {
return false;
}
+bool BinaryOperator::isFNeg(const Value *V) {
+ if (const BinaryOperator *Bop = dyn_cast(V))
+ if (Bop->getOpcode() == Instruction::FSub)
+ return Bop->getOperand(0) ==
+ ConstantExpr::getZeroValueForNegationExpr(Bop->getType());
+ return false;
+}
+
bool BinaryOperator::isNot(const Value *V) {
if (const BinaryOperator *Bop = dyn_cast(V))
return (Bop->getOpcode() == Instruction::Xor &&
@@ -1696,6 +1741,15 @@ const Value *BinaryOperator::getNegArgument(const Value *BinOp) {
return getNegArgument(const_cast(BinOp));
}
+Value *BinaryOperator::getFNegArgument(Value *BinOp) {
+ assert(isFNeg(BinOp) && "getFNegArgument from non-'fneg' instruction!");
+ return cast(BinOp)->getOperand(1);
+}
+
+const Value *BinaryOperator::getFNegArgument(const Value *BinOp) {
+ return getFNegArgument(const_cast(BinOp));
+}
+
Value *BinaryOperator::getNotArgument(Value *BinOp) {
assert(isNot(BinOp) && "getNotArgument on non-'not' instruction!");
BinaryOperator *BO = cast(BinOp);
diff --git a/test/Analysis/ScalarEvolution/sext-iv-0.ll b/test/Analysis/ScalarEvolution/sext-iv-0.ll
index 4b2fcea0df9..17f2dffdbfc 100644
--- a/test/Analysis/ScalarEvolution/sext-iv-0.ll
+++ b/test/Analysis/ScalarEvolution/sext-iv-0.ll
@@ -18,7 +18,7 @@ bb1: ; preds = %bb1, %bb1.thread
%2 = sext i9 %1 to i64 ; [#uses=1]
%3 = getelementptr double* %x, i64 %2 ; [#uses=1]
%4 = load double* %3, align 8 ; [#uses=1]
- %5 = mul double %4, 3.900000e+00 ; [#uses=1]
+ %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
%6 = sext i8 %0 to i64 ; [#uses=1]
%7 = getelementptr double* %x, i64 %6 ; [#uses=1]
store double %5, double* %7, align 8
diff --git a/test/Analysis/ScalarEvolution/sext-iv-1.ll b/test/Analysis/ScalarEvolution/sext-iv-1.ll
index a9175c31d06..ca6ad0aaba1 100644
--- a/test/Analysis/ScalarEvolution/sext-iv-1.ll
+++ b/test/Analysis/ScalarEvolution/sext-iv-1.ll
@@ -18,7 +18,7 @@ bb1: ; preds = %bb1, %bb1.thread
%2 = sext i9 %1 to i64 ; [#uses=1]
%3 = getelementptr double* %x, i64 %2 ; [#uses=1]
%4 = load double* %3, align 8 ; [#uses=1]
- %5 = mul double %4, 3.900000e+00 ; [#uses=1]
+ %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
%6 = sext i7 %0 to i64 ; [#uses=1]
%7 = getelementptr double* %x, i64 %6 ; [#uses=1]
store double %5, double* %7, align 8
@@ -41,7 +41,7 @@ bb1: ; preds = %bb1, %bb1.thread
%2 = sext i9 %1 to i64 ; [#uses=1]
%3 = getelementptr double* %x, i64 %2 ; [#uses=1]
%4 = load double* %3, align 8 ; [#uses=1]
- %5 = mul double %4, 3.900000e+00 ; [#uses=1]
+ %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
%6 = sext i8 %0 to i64 ; [#uses=1]
%7 = getelementptr double* %x, i64 %6 ; [#uses=1]
store double %5, double* %7, align 8
@@ -64,7 +64,7 @@ bb1: ; preds = %bb1, %bb1.thread
%2 = sext i9 %1 to i64 ; [#uses=1]
%3 = getelementptr double* %x, i64 %2 ; [#uses=1]
%4 = load double* %3, align 8 ; [#uses=1]
- %5 = mul double %4, 3.900000e+00 ; [#uses=1]
+ %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
%6 = sext i8 %0 to i64 ; [#uses=1]
%7 = getelementptr double* %x, i64 %6 ; [#uses=1]
store double %5, double* %7, align 8
@@ -87,7 +87,7 @@ bb1: ; preds = %bb1, %bb1.thread
%2 = sext i9 %1 to i64 ; [#uses=1]
%3 = getelementptr double* %x, i64 %2 ; [#uses=1]
%4 = load double* %3, align 8 ; [#uses=1]
- %5 = mul double %4, 3.900000e+00 ; [#uses=1]
+ %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
%6 = sext i8 %0 to i64 ; [#uses=1]
%7 = getelementptr double* %x, i64 %6 ; [#uses=1]
store double %5, double* %7, align 8
diff --git a/test/Analysis/ScalarEvolution/trip-count4.ll b/test/Analysis/ScalarEvolution/trip-count4.ll
index a61d5da57ea..49c4e133b46 100644
--- a/test/Analysis/ScalarEvolution/trip-count4.ll
+++ b/test/Analysis/ScalarEvolution/trip-count4.ll
@@ -13,7 +13,7 @@ loop: ; preds = %loop, %entry
%indvar.i8 = ashr i64 %s0, 8 ; [#uses=1]
%t0 = getelementptr double* %d, i64 %indvar.i8 ; [#uses=2]
%t1 = load double* %t0 ; [#uses=1]
- %t2 = mul double %t1, 1.000000e-01 ; [#uses=1]
+ %t2 = fmul double %t1, 1.000000e-01 ; [#uses=1]
store double %t2, double* %t0
%indvar.next = sub i64 %indvar, 1 ; [#uses=2]
%exitcond = icmp eq i64 %indvar.next, 10 ; [#uses=1]
diff --git a/test/Assembler/2002-04-07-HexFloatConstants.ll b/test/Assembler/2002-04-07-HexFloatConstants.ll
index b9860b3ac5a..5c54b39b808 100644
--- a/test/Assembler/2002-04-07-HexFloatConstants.ll
+++ b/test/Assembler/2002-04-07-HexFloatConstants.ll
@@ -11,6 +11,6 @@
; RUN: diff %t.1 %t.2
define double @test() {
- %tmp = mul double 7.200000e+101, 0x427F4000 ; [#uses=1]
+ %tmp = fmul double 7.200000e+101, 0x427F4000 ; [#uses=1]
ret double %tmp
}
diff --git a/test/Assembler/2002-04-07-InfConstant.ll b/test/Assembler/2002-04-07-InfConstant.ll
index 317b8f3654c..71837c94378 100644
--- a/test/Assembler/2002-04-07-InfConstant.ll
+++ b/test/Assembler/2002-04-07-InfConstant.ll
@@ -3,7 +3,7 @@
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep 0x7FF0000000000000
define float @test() {
- %tmp = mul float 0x7FF0000000000000, 1.000000e+01 ; [#uses=1]
+ %tmp = fmul float 0x7FF0000000000000, 1.000000e+01 ; [#uses=1]
ret float %tmp
}
diff --git a/test/CodeGen/ARM/2007-01-19-InfiniteLoop.ll b/test/CodeGen/ARM/2007-01-19-InfiniteLoop.ll
index 3661c4c06d6..6e11b169101 100644
--- a/test/CodeGen/ARM/2007-01-19-InfiniteLoop.ll
+++ b/test/CodeGen/ARM/2007-01-19-InfiniteLoop.ll
@@ -35,8 +35,8 @@ cond_next589: ; preds = %cond_next489
%tmp612 = load i32* null ; [#uses=1]
%tmp629 = load i32* null ; [#uses=1]
%tmp629a = sitofp i32 %tmp629 to double ; [#uses=1]
- %tmp631 = mul double %tmp629a, 0.000000e+00 ; [#uses=1]
- %tmp632 = add double 0.000000e+00, %tmp631 ; [#uses=1]
+ %tmp631 = fmul double %tmp629a, 0.000000e+00 ; [#uses=1]
+ %tmp632 = fadd double 0.000000e+00, %tmp631 ; [#uses=1]
%tmp642 = call fastcc i32 @sign( i32 %tmp576, i32 %tmp561 ) ; [#uses=1]
%tmp650 = mul i32 %tmp606, %tmp642 ; [#uses=1]
%tmp656 = mul i32 %tmp650, %tmp612 ; [#uses=1]
@@ -46,8 +46,8 @@ cond_next589: ; preds = %cond_next489
%tmp666 = sub i32 %tmp660, %tmp496 ; [#uses=1]
%tmp667 = sitofp i32 %tmp666 to double ; [#uses=2]
call void @levrun_linfo_inter( i32 %tmp576, i32 0, i32* null, i32* null )
- %tmp671 = mul double %tmp667, %tmp667 ; [#uses=1]
- %tmp675 = add double %tmp671, 0.000000e+00 ; [#uses=1]
+ %tmp671 = fmul double %tmp667, %tmp667 ; [#uses=1]
+ %tmp675 = fadd double %tmp671, 0.000000e+00 ; [#uses=1]
%tmp678 = fcmp oeq double %tmp632, %tmp675 ; [#uses=1]
br i1 %tmp678, label %cond_true679, label %cond_false693
diff --git a/test/CodeGen/ARM/2009-02-27-SpillerBug.ll b/test/CodeGen/ARM/2009-02-27-SpillerBug.ll
index 56e949f832c..bd5b7195944 100644
--- a/test/CodeGen/ARM/2009-02-27-SpillerBug.ll
+++ b/test/CodeGen/ARM/2009-02-27-SpillerBug.ll
@@ -11,7 +11,7 @@ bb.thread:
br label %bb52
bb32: ; preds = %bb52
- %0 = add double 0.000000e+00, 0.000000e+00 ; [#uses=1]
+ %0 = fadd double 0.000000e+00, 0.000000e+00 ; [#uses=1]
%1 = add i32 %j.1, 1 ; [#uses=1]
br label %bb52
@@ -29,14 +29,14 @@ bb53: ; preds = %bb52
bb55: ; preds = %bb53
%4 = load double* @a, align 4 ; [#uses=10]
- %5 = add double %4, 0.000000e+00 ; [#uses=16]
+ %5 = fadd double %4, 0.000000e+00 ; [#uses=16]
%6 = fcmp ogt double %k.4, 0.000000e+00 ; [#uses=1]
- %.pn404 = mul double %4, %4 ; [#uses=4]
- %.pn402 = mul double %5, %5 ; [#uses=5]
+ %.pn404 = fmul double %4, %4 ; [#uses=4]
+ %.pn402 = fmul double %5, %5 ; [#uses=5]
%.pn165.in = load double* @N ; [#uses=5]
- %.pn198 = mul double 0.000000e+00, %5 ; [#uses=1]
- %.pn185 = sub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
- %.pn147 = sub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
+ %.pn198 = fmul double 0.000000e+00, %5 ; [#uses=1]
+ %.pn185 = fsub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
+ %.pn147 = fsub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
%.pn141 = fdiv double 0.000000e+00, %4 ; [#uses=1]
%.pn142 = fdiv double 0.000000e+00, %5 ; [#uses=1]
%.pn136 = fdiv double 0.000000e+00, 0.000000e+00 ; [#uses=1]
@@ -47,178 +47,178 @@ bb55: ; preds = %bb53
%.pn117 = fdiv double 0.000000e+00, %4 ; [#uses=1]
%.pn118 = fdiv double %.pn185, %5 ; [#uses=1]
%.pn88 = fdiv double %.pn147, %5 ; [#uses=1]
- %.pn81 = sub double %.pn141, %.pn142 ; [#uses=1]
- %.pn77 = sub double 0.000000e+00, %.pn136 ; [#uses=1]
- %.pn75 = sub double 0.000000e+00, %.pn132 ; [#uses=1]
- %.pn69 = sub double %.pn123, %.pn124 ; [#uses=1]
- %.pn67 = sub double 0.000000e+00, %.pn120 ; [#uses=1]
- %.pn56 = sub double %.pn117, %.pn118 ; [#uses=1]
- %.pn42 = sub double 0.000000e+00, %.pn88 ; [#uses=1]
- %.pn60 = mul double %.pn81, 0.000000e+00 ; [#uses=1]
- %.pn57 = add double %.pn77, 0.000000e+00 ; [#uses=1]
- %.pn58 = mul double %.pn75, %.pn165.in ; [#uses=1]
- %.pn32 = add double %.pn69, 0.000000e+00 ; [#uses=1]
- %.pn33 = mul double %.pn67, %.pn165.in ; [#uses=1]
- %.pn17 = sub double 0.000000e+00, %.pn60 ; [#uses=1]
- %.pn9 = add double %.pn57, %.pn58 ; [#uses=1]
- %.pn30 = mul double 0.000000e+00, %.pn56 ; [#uses=1]
- %.pn24 = mul double 0.000000e+00, %.pn42 ; [#uses=1]
- %.pn1 = add double %.pn32, %.pn33 ; [#uses=1]
- %.pn28 = sub double %.pn30, 0.000000e+00 ; [#uses=1]
- %.pn26 = add double %.pn28, 0.000000e+00 ; [#uses=1]
- %.pn22 = sub double %.pn26, 0.000000e+00 ; [#uses=1]
- %.pn20 = sub double %.pn24, 0.000000e+00 ; [#uses=1]
- %.pn18 = add double %.pn22, 0.000000e+00 ; [#uses=1]
- %.pn16 = add double %.pn20, 0.000000e+00 ; [#uses=1]
- %.pn14 = sub double %.pn18, 0.000000e+00 ; [#uses=1]
- %.pn12 = sub double %.pn16, %.pn17 ; [#uses=1]
- %.pn10 = add double %.pn14, 0.000000e+00 ; [#uses=1]
- %.pn8 = add double %.pn12, 0.000000e+00 ; [#uses=1]
- %.pn6 = sub double %.pn10, 0.000000e+00 ; [#uses=1]
- %.pn4 = sub double %.pn8, %.pn9 ; [#uses=1]
- %.pn2 = add double %.pn6, 0.000000e+00 ; [#uses=1]
- %.pn = add double %.pn4, 0.000000e+00 ; [#uses=1]
- %N1.0 = sub double %.pn2, 0.000000e+00 ; [#uses=2]
- %D1.0 = sub double %.pn, %.pn1 ; [#uses=2]
+ %.pn81 = fsub double %.pn141, %.pn142 ; [#uses=1]
+ %.pn77 = fsub double 0.000000e+00, %.pn136 ; [#uses=1]
+ %.pn75 = fsub double 0.000000e+00, %.pn132 ; [#uses=1]
+ %.pn69 = fsub double %.pn123, %.pn124 ; [#uses=1]
+ %.pn67 = fsub double 0.000000e+00, %.pn120 ; [#uses=1]
+ %.pn56 = fsub double %.pn117, %.pn118 ; [#uses=1]
+ %.pn42 = fsub double 0.000000e+00, %.pn88 ; [#uses=1]
+ %.pn60 = fmul double %.pn81, 0.000000e+00 ; [#uses=1]
+ %.pn57 = fadd double %.pn77, 0.000000e+00 ; [#uses=1]
+ %.pn58 = fmul double %.pn75, %.pn165.in ; [#uses=1]
+ %.pn32 = fadd double %.pn69, 0.000000e+00 ; [#uses=1]
+ %.pn33 = fmul double %.pn67, %.pn165.in ; [#uses=1]
+ %.pn17 = fsub double 0.000000e+00, %.pn60 ; [#uses=1]
+ %.pn9 = fadd double %.pn57, %.pn58 ; [#uses=1]
+ %.pn30 = fmul double 0.000000e+00, %.pn56 ; [#uses=1]
+ %.pn24 = fmul double 0.000000e+00, %.pn42 ; [#uses=1]
+ %.pn1 = fadd double %.pn32, %.pn33 ; [#uses=1]
+ %.pn28 = fsub double %.pn30, 0.000000e+00 ; [#uses=1]
+ %.pn26 = fadd double %.pn28, 0.000000e+00 ; [#uses=1]
+ %.pn22 = fsub double %.pn26, 0.000000e+00 ; [#uses=1]
+ %.pn20 = fsub double %.pn24, 0.000000e+00 ; [#uses=1]
+ %.pn18 = fadd double %.pn22, 0.000000e+00 ; [#uses=1]
+ %.pn16 = fadd double %.pn20, 0.000000e+00 ; [#uses=1]
+ %.pn14 = fsub double %.pn18, 0.000000e+00 ; [#uses=1]
+ %.pn12 = fsub double %.pn16, %.pn17 ; [#uses=1]
+ %.pn10 = fadd double %.pn14, 0.000000e+00 ; [#uses=1]
+ %.pn8 = fadd double %.pn12, 0.000000e+00 ; [#uses=1]
+ %.pn6 = fsub double %.pn10, 0.000000e+00 ; [#uses=1]
+ %.pn4 = fsub double %.pn8, %.pn9 ; [#uses=1]
+ %.pn2 = fadd double %.pn6, 0.000000e+00 ; [#uses=1]
+ %.pn = fadd double %.pn4, 0.000000e+00 ; [#uses=1]
+ %N1.0 = fsub double %.pn2, 0.000000e+00 ; [#uses=2]
+ %D1.0 = fsub double %.pn, %.pn1 ; [#uses=2]
br i1 %6, label %bb62, label %bb64
bb62: ; preds = %bb55
- %7 = mul double 0.000000e+00, %4 ;