llvm.org GIT mirror llvm / ae3a0be
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 Dan Gohman 11 years ago
265 changed file(s) with 2497 addition(s) and 2047 deletion(s). Raw diff Collapse all Expand all
8888
  • Binary Operations
  • 8989
    9090
  • 'add' Instruction
  • 91
  • 'fadd' Instruction
  • 9192
  • 'sub' Instruction
  • 93
  • 'fsub' Instruction
  • 9294
  • 'mul' Instruction
  • 95
  • 'fmul' Instruction
  • 9396
  • 'udiv' Instruction
  • 9497
  • 'sdiv' Instruction
  • 9598
  • 'fdiv' Instruction
  • 25022505
    Arguments:
    25032506
    25042507

    The two arguments to the 'add' instruction must be

    2505 href="#t_integer">integer, floating point, or
    2506 vector values. Both arguments must have identical
    2507 types.

    2508
    2509
    Semantics:
    2510
    2511

    The value produced is the integer or floating point sum of the two

    2512 operands.

    2513
    2514

    If an integer sum has unsigned overflow, the result returned is the

    2508 href="#t_integer">integer or
    2509 vector of integer values. Both arguments must
    2510 have identical types.

    2511
    2512
    Semantics:
    2513
    2514

    The value produced is the integer sum of the two operands.

    2515
    2516

    If the sum has unsigned overflow, the result returned is the

    25152517 mathematical result modulo 2n, where n is the bit width of
    25162518 the result.

    25172519
    25222524
    25232525
    
                      
                    
    25242526 <result> = add i32 4, %var ; yields {i32}:result = 4 + %var
    2527
    2528
    2529
    2530
    2531 'fadd' Instruction
    2532
    2533
    2534
    2535
    2536
    Syntax:
    2537
    2538
    
                      
                    
    2539 <result> = fadd <ty> <op1>, <op2> ; yields {ty}:result
    2540
    2541
    2542
    Overview:
    2543
    2544

    The 'fadd' instruction returns the sum of its two operands.

    2545
    2546
    Arguments:
    2547
    2548

    The two arguments to the 'fadd' instruction must be

    2549 floating point or vector of
    2550 floating point values. Both arguments must have identical types.

    2551
    2552
    Semantics:
    2553
    2554

    The value produced is the floating point sum of the two operands.

    2555
    2556
    Example:
    2557
    2558
    
                      
                    
    2559 <result> = fadd float 4.0, %var ; yields {float}:result = 4.0 + %var
    25252560
    25262561
    25272562
    25492584
    Arguments:
    25502585
    25512586

    The two arguments to the 'sub' instruction must be

    2552 href="#t_integer">integer, floating point,
    2553 or vector values. Both arguments must have identical
    2554 types.

    2555
    2556
    Semantics:
    2557
    2558

    The value produced is the integer or floating point difference of

    2559 the two operands.

    2560
    2561

    If an integer difference has unsigned overflow, the result returned is the

    2587 href="#t_integer">integer or vector of
    2588 integer values. Both arguments must have identical types.

    2589
    2590
    Semantics:
    2591
    2592

    The value produced is the integer difference of the two operands.

    2593
    2594

    If the difference has unsigned overflow, the result returned is the

    25622595 mathematical result modulo 2n, where n is the bit width of
    25632596 the result.

    25642597
    25742607
    25752608
    25762609
    2610 'fsub' Instruction
    2611
    2612
    2613
    2614
    2615
    Syntax:
    2616
    2617
    
                      
                    
    2618 <result> = fsub <ty> <op1>, <op2> ; yields {ty}:result
    2619
    2620
    2621
    Overview:
    2622
    2623

    The 'fsub' instruction returns the difference of its two

    2624 operands.

    2625
    2626

    Note that the 'fsub' instruction is used to represent the

    2627 'fneg' instruction present in most other intermediate
    2628 representations.

    2629
    2630
    Arguments:
    2631
    2632

    The two arguments to the 'fsub' instruction must be

    2633 floating point or vector
    2634 of floating point values. Both arguments must have identical types.

    2635
    2636
    Semantics:
    2637
    2638

    The value produced is the floating point difference of the two operands.

    2639
    2640
    Example:
    2641
    
                      
                    
    2642 <result> = fsub float 4.0, %var ; yields {float}:result = 4.0 - %var
    2643 <result> = fsub float -0.0, %val ; yields {float}:result = -%var
    2644
    2645
    2646
    2647
    2648
    25772649 'mul' Instruction
    25782650
    25792651
    25892661
    Arguments:
    25902662
    25912663

    The two arguments to the 'mul' instruction must be

    2592 href="#t_integer">integer, floating point,
    2593 or vector values. Both arguments must have identical
    2594 types.

    2664 href="#t_integer">integer or vector of integer
    2665 values. Both arguments must have identical types.

    25952666
    25962667
    Semantics:
    25972668
    2598

    The value produced is the integer or floating point product of the

    2599 two operands.

    2600
    2601

    If the result of an integer multiplication has unsigned overflow,

    2669

    The value produced is the integer product of the two operands.

    2670
    2671

    If the result of the multiplication has unsigned overflow,

    26022672 the result returned is the mathematical result modulo
    26032673 2n, where n is the bit width of the result.

    26042674

    Because LLVM integers use a two's complement representation, and the

    26092679 width of the full product.

    26102680
    Example:
    26112681
      <result> = mul i32 4, %var          ; yields {i32}:result = 4 * %var
    
                      
                    
    2682
    2683
    2684
    2685
    2686
    2687 'fmul' Instruction
    2688
    2689
    2690
    2691
    2692
    Syntax:
    2693
      <result> = fmul <ty> <op1>, <op2>   ; yields {ty}:result
    
                      
                    
    2694
    2695
    Overview:
    2696

    The 'fmul' instruction returns the product of its two

    2697 operands.

    2698
    2699
    Arguments:
    2700
    2701

    The two arguments to the 'fmul' instruction must be

    2702 floating point or vector
    2703 of floating point values. Both arguments must have identical types.

    2704
    2705
    Semantics:
    2706
    2707

    The value produced is the floating point product of the two operands.

    2708
    2709
    Example:
    2710
      <result> = fmul float 4.0, %var          ; yields {float}:result = 4.0 * %var
    
                      
                    
    26122711
    26132712
    26142713
    703703 /// specify the full Instruction::OPCODE identifier.
    704704 ///
    705705 static Constant *getNeg(Constant *C);
    706 static Constant *getFNeg(Constant *C);
    706707 static Constant *getNot(Constant *C);
    707708 static Constant *getAdd(Constant *C1, Constant *C2);
    709 static Constant *getFAdd(Constant *C1, Constant *C2);
    708710 static Constant *getSub(Constant *C1, Constant *C2);
    711 static Constant *getFSub(Constant *C1, Constant *C2);
    709712 static Constant *getMul(Constant *C1, Constant *C2);
    713 static Constant *getFMul(Constant *C1, Constant *C2);
    710714 static Constant *getUDiv(Constant *C1, Constant *C2);
    711715 static Constant *getSDiv(Constant *C1, Constant *C2);
    712716 static Constant *getFDiv(Constant *C1, Constant *C2);
    203203 Instruction *InsertBefore = 0);
    204204 static BinaryOperator *CreateNeg(Value *Op, const std::string &Name,
    205205 BasicBlock *InsertAtEnd);
    206 static BinaryOperator *CreateFNeg(Value *Op, const std::string &Name = "",
    207 Instruction *InsertBefore = 0);
    208 static BinaryOperator *CreateFNeg(Value *Op, const std::string &Name,
    209 BasicBlock *InsertAtEnd);
    206210 static BinaryOperator *CreateNot(Value *Op, const std::string &Name = "",
    207211 Instruction *InsertBefore = 0);
    208212 static BinaryOperator *CreateNot(Value *Op, const std::string &Name,
    209213 BasicBlock *InsertAtEnd);
    210214
    211 /// isNeg, isNot - Check if the given Value is a NEG or NOT instruction.
    215 /// isNeg, isFNeg, isNot - Check if the given Value is a
    216 /// NEG, FNeg, or NOT instruction.
    212217 ///
    213218 static bool isNeg(const Value *V);
    219 static bool isFNeg(const Value *V);
    214220 static bool isNot(const Value *V);
    215221
    216222 /// getNegArgument, getNotArgument - Helper functions to extract the
    217 /// unary argument of a NEG or NOT operation implemented via Sub or Xor.
    223 /// unary argument of a NEG, FNEG or NOT operation implemented via
    224 /// Sub, FSub, or Xor.
    218225 ///
    219226 static const Value *getNegArgument(const Value *BinOp);
    220227 static Value *getNegArgument( Value *BinOp);
    228 static const Value *getFNegArgument(const Value *BinOp);
    229 static Value *getFNegArgument( Value *BinOp);
    221230 static const Value *getNotArgument(const Value *BinOp);
    222231 static Value *getNotArgument( Value *BinOp);
    223232
    104104 // Standard binary operators...
    105105 FIRST_BINARY_INST( 7)
    106106 HANDLE_BINARY_INST( 7, Add , BinaryOperator)
    107 HANDLE_BINARY_INST( 8, Sub , BinaryOperator)
    108 HANDLE_BINARY_INST( 9, Mul , BinaryOperator)
    109 HANDLE_BINARY_INST(10, UDiv , BinaryOperator)
    110 HANDLE_BINARY_INST(11, SDiv , BinaryOperator)
    111 HANDLE_BINARY_INST(12, FDiv , BinaryOperator)
    112 HANDLE_BINARY_INST(13, URem , BinaryOperator)
    113 HANDLE_BINARY_INST(14, SRem , BinaryOperator)
    114 HANDLE_BINARY_INST(15, FRem , BinaryOperator)
    107 HANDLE_BINARY_INST( 8, FAdd , BinaryOperator)
    108 HANDLE_BINARY_INST( 9, Sub , BinaryOperator)
    109 HANDLE_BINARY_INST(10, FSub , BinaryOperator)
    110 HANDLE_BINARY_INST(11, Mul , BinaryOperator)
    111 HANDLE_BINARY_INST(12, FMul , BinaryOperator)
    112 HANDLE_BINARY_INST(13, UDiv , BinaryOperator)
    113 HANDLE_BINARY_INST(14, SDiv , BinaryOperator)
    114 HANDLE_BINARY_INST(15, FDiv , BinaryOperator)
    115 HANDLE_BINARY_INST(16, URem , BinaryOperator)
    116 HANDLE_BINARY_INST(17, SRem , BinaryOperator)
    117 HANDLE_BINARY_INST(18, FRem , BinaryOperator)
    115118
    116119 // Logical operators (integer operands)
    117 HANDLE_BINARY_INST(16, Shl , BinaryOperator) // Shift left (logical)
    118 HANDLE_BINARY_INST(17, LShr , BinaryOperator) // Shift right (logical)
    119 HANDLE_BINARY_INST(18, AShr , BinaryOperator) // Shift right (arithmetic)
    120 HANDLE_BINARY_INST(19, And , BinaryOperator)
    121 HANDLE_BINARY_INST(20, Or , BinaryOperator)
    122 HANDLE_BINARY_INST(21, Xor , BinaryOperator)
    123 LAST_BINARY_INST(21)
    120 HANDLE_BINARY_INST(19, Shl , BinaryOperator) // Shift left (logical)
    121 HANDLE_BINARY_INST(20, LShr , BinaryOperator) // Shift right (logical)
    122 HANDLE_BINARY_INST(21, AShr , BinaryOperator) // Shift right (arithmetic)
    123 HANDLE_BINARY_INST(22, And , BinaryOperator)
    124 HANDLE_BINARY_INST(23, Or , BinaryOperator)
    125 HANDLE_BINARY_INST(24, Xor , BinaryOperator)
    126 LAST_BINARY_INST(24)
    124127
    125128 // Memory operators...
    126 FIRST_MEMORY_INST(22)
    127 HANDLE_MEMORY_INST(22, Malloc, MallocInst) // Heap management instructions
    128 HANDLE_MEMORY_INST(23, Free , FreeInst )
    129 HANDLE_MEMORY_INST(24, Alloca, AllocaInst) // Stack management
    130 HANDLE_MEMORY_INST(25, Load , LoadInst ) // Memory manipulation instrs
    131 HANDLE_MEMORY_INST(26, Store , StoreInst )
    132 HANDLE_MEMORY_INST(27, GetElementPtr, GetElementPtrInst)
    133 LAST_MEMORY_INST(27)
    129 FIRST_MEMORY_INST(25)
    130 HANDLE_MEMORY_INST(25, Malloc, MallocInst) // Heap management instructions
    131 HANDLE_MEMORY_INST(26, Free , FreeInst )
    132 HANDLE_MEMORY_INST(27, Alloca, AllocaInst) // Stack management
    133 HANDLE_MEMORY_INST(28, Load , LoadInst ) // Memory manipulation instrs
    134 HANDLE_MEMORY_INST(29, Store , StoreInst )
    135 HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst)
    136 LAST_MEMORY_INST(30)
    134137
    135138 // Cast operators ...
    136139 // NOTE: The order matters here because CastInst::isEliminableCastPair
    137140 // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
    138 FIRST_CAST_INST(28)
    139 HANDLE_CAST_INST(28, Trunc , TruncInst ) // Truncate integers
    140 HANDLE_CAST_INST(29, ZExt , ZExtInst ) // Zero extend integers
    141 HANDLE_CAST_INST(30, SExt , SExtInst ) // Sign extend integers
    142 HANDLE_CAST_INST(31, FPToUI , FPToUIInst ) // floating point -> UInt
    143 HANDLE_CAST_INST(32, FPToSI , FPToSIInst ) // floating point -> SInt
    144 HANDLE_CAST_INST(33, UIToFP , UIToFPInst ) // UInt -> floating point
    145 HANDLE_CAST_INST(34, SIToFP , SIToFPInst ) // SInt -> floating point
    146 HANDLE_CAST_INST(35, FPTrunc , FPTruncInst ) // Truncate floating point
    147 HANDLE_CAST_INST(36, FPExt , FPExtInst ) // Extend floating point
    148 HANDLE_CAST_INST(37, PtrToInt, PtrToIntInst) // Pointer -> Integer
    149 HANDLE_CAST_INST(38, IntToPtr, IntToPtrInst) // Integer -> Pointer
    150 HANDLE_CAST_INST(39, BitCast , BitCastInst ) // Type cast
    151 LAST_CAST_INST(39)
    141 FIRST_CAST_INST(31)
    142 HANDLE_CAST_INST(31, Trunc , TruncInst ) // Truncate integers
    143 HANDLE_CAST_INST(32, ZExt , ZExtInst ) // Zero extend integers
    144 HANDLE_CAST_INST(33, SExt , SExtInst ) // Sign extend integers
    145 HANDLE_CAST_INST(34, FPToUI , FPToUIInst ) // floating point -> UInt
    146 HANDLE_CAST_INST(35, FPToSI , FPToSIInst ) // floating point -> SInt
    147 HANDLE_CAST_INST(36, UIToFP , UIToFPInst ) // UInt -> floating point
    148 HANDLE_CAST_INST(37, SIToFP , SIToFPInst ) // SInt -> floating point
    149 HANDLE_CAST_INST(38, FPTrunc , FPTruncInst ) // Truncate floating point
    150 HANDLE_CAST_INST(39, FPExt , FPExtInst ) // Extend floating point
    151 HANDLE_CAST_INST(40, PtrToInt, PtrToIntInst) // Pointer -> Integer
    152 HANDLE_CAST_INST(41, IntToPtr, IntToPtrInst) // Integer -> Pointer
    153 HANDLE_CAST_INST(42, BitCast , BitCastInst ) // Type cast
    154 LAST_CAST_INST(42)
    152155
    153156 // Other operators...
    154 FIRST_OTHER_INST(40)
    155 HANDLE_OTHER_INST(40, ICmp , ICmpInst ) // Integer comparison instruction
    156 HANDLE_OTHER_INST(41, FCmp , FCmpInst ) // Floating point comparison instr.
    157 HANDLE_OTHER_INST(42, PHI , PHINode ) // PHI node instruction
    158 HANDLE_OTHER_INST(43, Call , CallInst ) // Call a function
    159 HANDLE_OTHER_INST(44, Select , SelectInst ) // select instruction
    160 HANDLE_OTHER_INST(45, UserOp1, Instruction) // May be used internally in a pass
    161 HANDLE_OTHER_INST(46, UserOp2, Instruction) // Internal to passes only
    162 HANDLE_OTHER_INST(47, VAArg , VAArgInst ) // vaarg instruction
    163 HANDLE_OTHER_INST(48, ExtractElement, ExtractElementInst)// extract from vector
    164 HANDLE_OTHER_INST(49, InsertElement, InsertElementInst) // insert into vector
    165 HANDLE_OTHER_INST(50, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
    166 HANDLE_OTHER_INST(51, ExtractValue, ExtractValueInst)// extract from aggregate
    167 HANDLE_OTHER_INST(52, InsertValue, InsertValueInst) // insert into aggregate
    168 HANDLE_OTHER_INST(53, VICmp , VICmpInst ) // Vec Int comparison instruction.
    169 HANDLE_OTHER_INST(54, VFCmp , VFCmpInst ) // Vec FP point comparison instr.
    157 FIRST_OTHER_INST(43)
    158 HANDLE_OTHER_INST(43, ICmp , ICmpInst ) // Integer comparison instruction
    159 HANDLE_OTHER_INST(44, FCmp , FCmpInst ) // Floating point comparison instr.
    160 HANDLE_OTHER_INST(45, PHI , PHINode ) // PHI node instruction
    161 HANDLE_OTHER_INST(46, Call , CallInst ) // Call a function
    162 HANDLE_OTHER_INST(47, Select , SelectInst ) // select instruction
    163 HANDLE_OTHER_INST(48, UserOp1, Instruction) // May be used internally in a pass
    164 HANDLE_OTHER_INST(49, UserOp2, Instruction) // Internal to passes only
    165 HANDLE_OTHER_INST(50, VAArg , VAArgInst ) // vaarg instruction
    166 HANDLE_OTHER_INST(51, ExtractElement, ExtractElementInst)// extract from vector
    167 HANDLE_OTHER_INST(52, InsertElement, InsertElementInst) // insert into vector
    168 HANDLE_OTHER_INST(53, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
    169 HANDLE_OTHER_INST(54, ExtractValue, ExtractValueInst)// extract from aggregate
    170 HANDLE_OTHER_INST(55, InsertValue, InsertValueInst) // insert into aggregate
    171 HANDLE_OTHER_INST(56, VICmp , VICmpInst ) // Vec Int comparison instruction.
    172 HANDLE_OTHER_INST(57, VFCmp , VFCmpInst ) // Vec FP point comparison instr.
    170173
    171 LAST_OTHER_INST(55)
    174 LAST_OTHER_INST(57)
    172175
    173176 #undef FIRST_TERM_INST
    174177 #undef HANDLE_TERM_INST
    3131 Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
    3232 return ConstantExpr::getAdd(LHS, RHS);
    3333 }
    34 Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
    35 return ConstantExpr::getFAdd(LHS, RHS);
    36 }
    3437 Constant *CreateSub(Constant *LHS, Constant *RHS) const {
    3538 return ConstantExpr::getSub(LHS, RHS);
    3639 }
    40 Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
    41 return ConstantExpr::getFSub(LHS, RHS);
    42 }
    3743 Constant *CreateMul(Constant *LHS, Constant *RHS) const {
    3844 return ConstantExpr::getMul(LHS, RHS);
    45 }
    46 Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
    47 return ConstantExpr::getFMul(LHS, RHS);
    3948 }
    4049 Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
    4150 return ConstantExpr::getUDiv(LHS, RHS);
    8695 Constant *CreateNeg(Constant *C) const {
    8796 return ConstantExpr::getNeg(C);
    8897 }
    98 Constant *CreateFNeg(Constant *C) const {
    99 return ConstantExpr::getFNeg(C);
    100 }
    89101 Constant *CreateNot(Constant *C) const {
    90102 return ConstantExpr::getNot(C);
    91103 }
    174174 return Folder.CreateAdd(LC, RC);
    175175 return Insert(BinaryOperator::CreateAdd(LHS, RHS), Name);
    176176 }
    177 Value *CreateFAdd(Value *LHS, Value *RHS, const char *Name = "") {
    178 if (Constant *LC = dyn_cast(LHS))
    179 if (Constant *RC = dyn_cast(RHS))
    180 return Folder.CreateFAdd(LC, RC);
    181 return Insert(BinaryOperator::CreateFAdd(LHS, RHS), Name);
    182 }
    177183 Value *CreateSub(Value *LHS, Value *RHS, const char *Name = "") {
    178184 if (Constant *LC = dyn_cast(LHS))
    179185 if (Constant *RC = dyn_cast(RHS))
    180186 return Folder.CreateSub(LC, RC);
    181187 return Insert(BinaryOperator::CreateSub(LHS, RHS), Name);
    182188 }
    189 Value *CreateFSub(Value *LHS, Value *RHS, const char *Name = "") {
    190 if (Constant *LC = dyn_cast(LHS))
    191 if (Constant *RC = dyn_cast(RHS))
    192 return Folder.CreateFSub(LC, RC);
    193 return Insert(BinaryOperator::CreateFSub(LHS, RHS), Name);
    194 }
    183195 Value *CreateMul(Value *LHS, Value *RHS, const char *Name = "") {
    184196 if (Constant *LC = dyn_cast(LHS))
    185197 if (Constant *RC = dyn_cast(RHS))
    186198 return Folder.CreateMul(LC, RC);
    187199 return Insert(BinaryOperator::CreateMul(LHS, RHS), Name);
    200 }
    201 Value *CreateFMul(Value *LHS, Value *RHS, const char *Name = "") {
    202 if (Constant *LC = dyn_cast(LHS))
    203 if (Constant *RC = dyn_cast(RHS))
    204 return Folder.CreateMul(LC, RC);
    205 return Insert(BinaryOperator::CreateFMul(LHS, RHS), Name);
    188206 }
    189207 Value *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") {
    190208 if (Constant *LC = dyn_cast(LHS))
    3838 Value *CreateAdd(Constant *LHS, Constant *RHS) const {
    3939 return BinaryOperator::CreateAdd(LHS, RHS);
    4040 }
    41 Value *CreateFAdd(Constant *LHS, Constant *RHS) const {
    42 return BinaryOperator::CreateFAdd(LHS, RHS);
    43 }
    4144 Value *CreateSub(Constant *LHS, Constant *RHS) const {
    4245 return BinaryOperator::CreateSub(LHS, RHS);
    4346 }
    47 Value *CreateFSub(Constant *LHS, Constant *RHS) const {
    48 return BinaryOperator::CreateFSub(LHS, RHS);
    49 }
    4450 Value *CreateMul(Constant *LHS, Constant *RHS) const {
    4551 return BinaryOperator::CreateMul(LHS, RHS);
    52 }
    53 Value *CreateFMul(Constant *LHS, Constant *RHS) const {
    54 return BinaryOperator::CreateFMul(LHS, RHS);
    4655 }
    4756 Value *CreateUDiv(Constant *LHS, Constant *RHS) const {
    4857 return BinaryOperator::CreateUDiv(LHS, RHS);
    156156 }
    157157
    158158 template
    159 inline BinaryOp_match m_FAdd(const LHS &L,
    160 const RHS &R) {
    161 return BinaryOp_match(L, R);
    162 }
    163
    164 template
    159165 inline BinaryOp_match m_Sub(const LHS &L,
    160166 const RHS &R) {
    161167 return BinaryOp_match(L, R);
    162168 }
    163169
    164170 template
    171 inline BinaryOp_match m_FSub(const LHS &L,
    172 const RHS &R) {
    173 return BinaryOp_match(L, R);
    174 }
    175
    176 template
    165177 inline BinaryOp_match m_Mul(const LHS &L,
    166178 const RHS &R) {
    167179 return BinaryOp_match(L, R);
    180 }
    181
    182 template
    183 inline BinaryOp_match m_FMul(const LHS &L,
    184 const RHS &R) {
    185 return BinaryOp_match(L, R);
    168186 }
    169187
    170188 template
    493511 inline neg_match m_Neg(const LHS &L) { return L; }
    494512
    495513
    514 template
    515 struct fneg_match {
    516 LHS_t L;
    517
    518 fneg_match(const LHS_t &LHS) : L(LHS) {}
    519
    520 template
    521 bool match(OpTy *V) {
    522 if (Instruction *I = dyn_cast(V))
    523 if (I->getOpcode() == Instruction::FSub)
    524 return matchIfFNeg(I->getOperand(0), I->getOperand(1));
    525 if (ConstantExpr *CE = dyn_cast(V))
    526 if (CE->getOpcode() == Instruction::FSub)
    527 return matchIfFNeg(CE->getOperand(0), CE->getOperand(1));
    528 if (ConstantFP *CF = dyn_cast(V))
    529 return L.match(ConstantExpr::getFNeg(CF));
    530 return false;
    531 }
    532 private:
    533 bool matchIfFNeg(Value *LHS, Value *RHS) {
    534 return LHS == ConstantExpr::getZeroValueForNegationExpr(LHS->getType()) &&
    535 L.match(RHS);
    536 }
    537 };
    538
    539 template
    540 inline fneg_match m_FNeg(const LHS &L) { return L; }
    541
    542
    496543 //===----------------------------------------------------------------------===//
    497544 // Matchers for control flow
    498545 //
    4747 Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
    4848 return Fold(ConstantExpr::getAdd(LHS, RHS));
    4949 }
    50 Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
    51 return Fold(ConstantExpr::getFAdd(LHS, RHS));
    52 }
    5053 Constant *CreateSub(Constant *LHS, Constant *RHS) const {
    5154 return Fold(ConstantExpr::getSub(LHS, RHS));
    5255 }
    56 Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
    57 return Fold(ConstantExpr::getFSub(LHS, RHS));
    58 }
    5359 Constant *CreateMul(Constant *LHS, Constant *RHS) const {
    5460 return Fold(ConstantExpr::getMul(LHS, RHS));
    61 }
    62 Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
    63 return Fold(ConstantExpr::getFMul(LHS, RHS));
    5564 }
    5665 Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
    5766 return Fold(ConstantExpr::getUDiv(LHS, RHS));
    101110
    102111 Constant *CreateNeg(Constant *C) const {
    103112 return Fold(ConstantExpr::getNeg(C));
    113 }
    114 Constant *CreateFNeg(Constant *C) const {
    115 return Fold(ConstantExpr::getFNeg(C));
    104116 }
    105117 Constant *CreateNot(Constant *C) const {
    106118 return Fold(ConstantExpr::getNot(C));
    770770 if (I == 0) return false;
    771771
    772772 // (add x, 0.0) is guaranteed to return +0.0, not -0.0.
    773 if (I->getOpcode() == Instruction::Add &&
    773 if (I->getOpcode() == Instruction::FAdd &&
    774774 isa(I->getOperand(1)) &&
    775775 cast(I->getOperand(1))->isNullValue())
    776776 return true;
    590590 if (Len == strlen(#STR) && !memcmp(StartChar, #STR, strlen(#STR))) { \
    591591 UIntVal = Instruction::Enum; return lltok::kw_##STR; }
    592592
    593 INSTKEYWORD(add, Add); INSTKEYWORD(sub, Sub); INSTKEYWORD(mul, Mul);
    593 INSTKEYWORD(add, Add); INSTKEYWORD(fadd, FAdd);
    594 INSTKEYWORD(sub, Sub); INSTKEYWORD(fsub, FSub);
    595 INSTKEYWORD(mul, Mul); INSTKEYWORD(fmul, FMul);
    594596 INSTKEYWORD(udiv, UDiv); INSTKEYWORD(sdiv, SDiv); INSTKEYWORD(fdiv, FDiv);
    595597 INSTKEYWORD(urem, URem); INSTKEYWORD(srem, SRem); INSTKEYWORD(frem, FRem);
    596598 INSTKEYWORD(shl, Shl); INSTKEYWORD(lshr, LShr); INSTKEYWORD(ashr, AShr);
    18341834
    18351835 // Binary Operators.
    18361836 case lltok::kw_add:
    1837 case lltok::kw_fadd:
    18371838 case lltok::kw_sub:
    1839 case lltok::kw_fsub:
    18381840 case lltok::kw_mul:
    1841 case lltok::kw_fmul:
    18391842 case lltok::kw_udiv:
    18401843 case lltok::kw_sdiv:
    18411844 case lltok::kw_fdiv:
    23992402 // Binary Operators.
    24002403 case lltok::kw_add:
    24012404 case lltok::kw_sub:
    2402 case lltok::kw_mul: return ParseArithmetic(Inst, PFS, KeywordVal, 0);
    2403
    2405 case lltok::kw_mul:
    2406 // API compatibility: Accept either integer or floating-point types.
    2407 return ParseArithmetic(Inst, PFS, KeywordVal, 0);
    2408 case lltok::kw_fadd:
    2409 case lltok::kw_fsub:
    2410 case lltok::kw_fmul: return ParseArithmetic(Inst, PFS, KeywordVal, 2);
    2411
    24042412 case lltok::kw_udiv:
    24052413 case lltok::kw_sdiv:
    24062414 case lltok::kw_urem:
    8989 kw_ueq, kw_une,
    9090
    9191 // Instruction Opcodes (Opcode in UIntVal).
    92 kw_add, kw_sub, kw_mul, kw_udiv, kw_sdiv, kw_fdiv,
    92 kw_add, kw_fadd, kw_sub, kw_fsub, kw_mul, kw_fmul,
    93 kw_udiv, kw_sdiv, kw_fdiv,
    9394 kw_urem, kw_srem, kw_frem, kw_shl, kw_lshr, kw_ashr,
    9495 kw_and, kw_or, kw_xor, kw_icmp, kw_fcmp, kw_vicmp, kw_vfcmp,
    9596
    103103 static int GetDecodedBinaryOpcode(unsigned Val, const Type *Ty) {
    104104 switch (Val) {
    105105 default: return -1;
    106 case bitc::BINOP_ADD: return Instruction::Add;
    107 case bitc::BINOP_SUB: return Instruction::Sub;
    108 case bitc::BINOP_MUL: return Instruction::Mul;
    106 case bitc::BINOP_ADD:
    107 return Ty->isFPOrFPVector() ? Instruction::FAdd : Instruction::Add;
    108 case bitc::BINOP_SUB:
    109 return Ty->isFPOrFPVector() ? Instruction::FSub : Instruction::Sub;
    110 case bitc::BINOP_MUL:
    111 return Ty->isFPOrFPVector() ? Instruction::FMul : Instruction::Mul;
    109112 case bitc::BINOP_UDIV: return Instruction::UDiv;
    110113 case bitc::BINOP_SDIV:
    111114 return Ty->isFPOrFPVector() ? Instruction::FDiv : Instruction::SDiv;
    7676 static unsigned GetEncodedBinaryOpcode(unsigned Opcode) {
    7777 switch (Opcode) {
    7878 default: assert(0 && "Unknown binary instruction!");
    79 case Instruction::Add: return bitc::BINOP_ADD;
    80 case Instruction::Sub: return bitc::BINOP_SUB;
    81 case Instruction::Mul: return bitc::BINOP_MUL;
    79 case Instruction::Add:
    80 case Instruction::FAdd: return bitc::BINOP_ADD;
    81 case Instruction::Sub:
    82 case Instruction::FSub: return bitc::BINOP_SUB;
    83 case Instruction::Mul:
    84 case Instruction::FMul: return bitc::BINOP_MUL;
    8285 case Instruction::UDiv: return bitc::BINOP_UDIV;
    8386 case Instruction::FDiv:
    8487 case Instruction::SDiv: return bitc::BINOP_SDIV;
    638638 bool
    639639 FastISel::SelectOperator(User *I, unsigned Opcode) {
    640640 switch (Opcode) {
    641 case Instruction::Add: {
    642 ISD::NodeType Opc = I->getType()->isFPOrFPVector() ? ISD::FADD : ISD::ADD;
    643 return SelectBinaryOp(I, Opc);
    644 }
    645 case Instruction::Sub: {
    646 ISD::NodeType Opc = I->getType()->isFPOrFPVector() ? ISD::FSUB : ISD::SUB;
    647 return SelectBinaryOp(I, Opc);
    648 }
    649 case Instruction::Mul: {
    650 ISD::NodeType Opc = I->getType()->isFPOrFPVector() ? ISD::FMUL : ISD::MUL;
    651 return SelectBinaryOp(I, Opc);
    652 }
    641 case Instruction::Add:
    642 return SelectBinaryOp(I, ISD::ADD);
    643 case Instruction::FAdd:
    644 return SelectBinaryOp(I, ISD::FADD);
    645 case Instruction::Sub:
    646 return SelectBinaryOp(I, ISD::SUB);
    647 case Instruction::FSub:
    648 return SelectBinaryOp(I, ISD::FSUB);
    649 case Instruction::Mul:
    650 return SelectBinaryOp(I, ISD::MUL);
    651 case Instruction::FMul:
    652 return SelectBinaryOp(I, ISD::FMUL);
    653653 case Instruction::SDiv:
    654654 return SelectBinaryOp(I, ISD::SDIV);
    655655 case Instruction::UDiv:
    841841 }
    842842 }
    843843
    844 void SelectionDAGLowering::visitAdd(User &I) {
    845 if (I.getType()->isFPOrFPVector())
    846 visitBinary(I, ISD::FADD);
    847 else
    848 visitBinary(I, ISD::ADD);
    849 }
    850
    851 void SelectionDAGLowering::visitMul(User &I) {
    852 if (I.getType()->isFPOrFPVector())
    853 visitBinary(I, ISD::FMUL);
    854 else
    855 visitBinary(I, ISD::MUL);
    856 }
    857
    858844 SDValue SelectionDAGLowering::getValue(const Value *V) {
    859845 SDValue &N = NodeMap[V];
    860846 if (N.getNode()) return N;
    21602146 }
    21612147
    21622148
    2163 void SelectionDAGLowering::visitSub(User &I) {
    2149 void SelectionDAGLowering::visitFSub(User &I) {
    21642150 // -0.0 - X --> fneg
    21652151 const Type *Ty = I.getType();
    21662152 if (isa(Ty)) {
    21672153 if (ConstantVector *CV = dyn_cast(I.getOperand(0))) {
    21682154 const VectorType *DestTy = cast(I.getType());
    21692155 const Type *ElTy = DestTy->getElementType();
    2170 if (ElTy->isFloatingPoint()) {
    2171 unsigned VL = DestTy->getNumElements();
    2172 std::vector NZ(VL, ConstantFP::getNegativeZero(ElTy));
    2173 Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
    2174 if (CV == CNZ) {
    2175 SDValue Op2 = getValue(I.getOperand(1));
    2176 setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
    2177 Op2.getValueType(), Op2));
    2178 return;
    2179 }
    2180 }
    2181 }
    2182 }
    2183 if (Ty->isFloatingPoint()) {
    2184 if (ConstantFP *CFP = dyn_cast(I.getOperand(0)))
    2185 if (CFP->isExactlyValue(ConstantFP::getNegativeZero(Ty)->getValueAPF())) {
    2156 unsigned VL = DestTy->getNumElements();
    2157 std::vector NZ(VL, ConstantFP::getNegativeZero(ElTy));
    2158 Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
    2159 if (CV == CNZ) {
    21862160 SDValue Op2 = getValue(I.getOperand(1));
    21872161 setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
    21882162 Op2.getValueType(), Op2));
    21892163 return;
    21902164 }
    2191 }
    2192
    2193 visitBinary(I, Ty->isFPOrFPVector() ? ISD::FSUB : ISD::SUB);
    2165 }
    2166 }
    2167 if (ConstantFP *CFP = dyn_cast(I.getOperand(0)))
    2168 if (CFP->isExactlyValue(ConstantFP::getNegativeZero(Ty)->getValueAPF())) {
    2169 SDValue Op2 = getValue(I.getOperand(1));
    2170 setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
    2171 Op2.getValueType(), Op2));
    2172 return;
    2173 }
    2174
    2175 visitBinary(I, ISD::FSUB);
    21942176 }
    21952177
    21962178 void SelectionDAGLowering::visitBinary(User &I, unsigned OpCode) {
    468468
    469469 void visitBinary(User &I, unsigned OpCode);
    470470 void visitShift(User &I, unsigned Opcode);
    471 void visitAdd(User &I);
    472 void visitSub(User &I);
    473 void visitMul(User &I);
    471 void visitAdd(User &I) { visitBinary(I, ISD::ADD); }
    472 void visitFAdd(User &I) { visitBinary(I, ISD::FADD); }
    473 void visitSub(User &I) { visitBinary(I, ISD::SUB); }
    474 void visitFSub(User &I);
    475 void visitMul(User &I) { visitBinary(I, ISD::MUL); }
    476 void visitFMul(User &I) { visitBinary(I, ISD::FMUL); }
    474477 void visitURem(User &I) { visitBinary(I, ISD::UREM); }
    475478 void visitSRem(User &I) { visitBinary(I, ISD::SREM); }
    476479 void visitFRem(User &I) { visitBinary(I, ISD::FREM); }
    572572 return GV;
    573573 }
    574574 case Instruction::Add:
    575 case Instruction::FAdd:
    575576 case Instruction::Sub:
    577 case Instruction::FSub:
    576578 case Instruction::Mul:
    579 case Instruction::FMul:
    577580 case Instruction::UDiv:
    578581 case Instruction::SDiv:
    579582 case Instruction::URem:
    604607 case Type::FloatTyID:
    605608 switch (CE->getOpcode()) {
    606609 default: assert(0 && "Invalid float opcode"); abort();
    607 case Instruction::Add:
    610 case Instruction::FAdd:
    608611 GV.FloatVal = LHS.FloatVal + RHS.FloatVal; break;
    609 case Instruction::Sub:
    612 case Instruction::FSub:
    610613 GV.FloatVal = LHS.FloatVal - RHS.FloatVal; break;
    611 case Instruction::Mul:
    614 case Instruction::FMul:
    612615 GV.FloatVal = LHS.FloatVal * RHS.FloatVal; break;
    613616 case Instruction::FDiv:
    614617 GV.FloatVal = LHS.FloatVal / RHS.FloatVal; break;
    619622 case Type::DoubleTyID:
    620623 switch (CE->getOpcode()) {
    621624 default: assert(0 && "Invalid double opcode"); abort();
    622 case Instruction::Add:
    625 case Instruction::FAdd:
    623626 GV.DoubleVal = LHS.DoubleVal + RHS.DoubleVal; break;
    624 case Instruction::Sub:
    627 case Instruction::FSub:
    625628 GV.DoubleVal = LHS.DoubleVal - RHS.DoubleVal; break;
    626 case Instruction::Mul:
    629 case Instruction::FMul:
    627630 GV.DoubleVal = LHS.DoubleVal * RHS.DoubleVal; break;
    628631 case Instruction::FDiv:
    629632 GV.DoubleVal = LHS.DoubleVal / RHS.DoubleVal; break;
    637640 APFloat apfLHS = APFloat(LHS.IntVal);
    638641 switch (CE->getOpcode()) {
    639642 default: assert(0 && "Invalid long double opcode"); abort();
    640 case Instruction::Add:
    643 case Instruction::FAdd:
    641644 apfLHS.add(APFloat(RHS.IntVal), APFloat::rmNearestTiesToEven);
    642645 GV.IntVal = apfLHS.bitcastToAPInt();
    643646 break;
    644 case Instruction::Sub:
    647 case Instruction::FSub:
    645648 apfLHS.subtract(APFloat(RHS.IntVal), APFloat::rmNearestTiesToEven);
    646649 GV.IntVal = apfLHS.bitcastToAPInt();
    647650 break;
    648 case Instruction::Mul:
    651 case Instruction::FMul:
    649652 apfLHS.multiply(APFloat(RHS.IntVal), APFloat::rmNearestTiesToEven);
    650653 GV.IntVal = apfLHS.bitcastToAPInt();
    651654 break;
    6363 Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; \
    6464 break
    6565
    66 #define IMPLEMENT_INTEGER_BINOP1(OP, TY) \
    67 case Type::IntegerTyID: { \
    68 Dest.IntVal = Src1.IntVal OP Src2.IntVal; \
    69 break; \
    70 }
    71
    72
    73 static void executeAddInst(GenericValue &Dest, GenericValue Src1,
    74 GenericValue Src2, const Type *Ty) {
    75 switch (Ty->getTypeID()) {
    76 IMPLEMENT_INTEGER_BINOP1(+, Ty);
    66 static void executeFAddInst(GenericValue &Dest, GenericValue Src1,
    67 GenericValue Src2, const Type *Ty) {
    68 switch (Ty->getTypeID()) {
    7769 IMPLEMENT_BINARY_OPERATOR(+, Float);
    7870 IMPLEMENT_BINARY_OPERATOR(+, Double);
    7971 default:
    80 cerr << "Unhandled type for Add instruction: " << *Ty << "\n";
    81 abort();
    82 }
    83 }
    84
    85 static void executeSubInst(GenericValue &Dest, GenericValue Src1,
    86 GenericValue Src2, const Type *Ty) {
    87 switch (Ty->getTypeID()) {
    88 IMPLEMENT_INTEGER_BINOP1(-, Ty);
    72 cerr << "Unhandled type for FAdd instruction: " << *Ty << "\n";
    73 abort();
    74 }
    75 }
    76
    77 static void executeFSubInst(GenericValue &Dest, GenericValue Src1,
    78 GenericValue Src2, const Type *Ty) {
    79 switch (Ty->getTypeID()) {
    8980 IMPLEMENT_BINARY_OPERATOR(-, Float);
    9081 IMPLEMENT_BINARY_OPERATOR(-, Double);
    9182 default:
    92 cerr << "Unhandled type for Sub instruction: " << *Ty << "\n";
    93 abort();
    94 }
    95 }
    96
    97 static void executeMulInst(GenericValue &Dest, GenericValue Src1,
    98 GenericValue Src2, const Type *Ty) {
    99 switch (Ty->getTypeID()) {
    100 IMPLEMENT_INTEGER_BINOP1(*, Ty);
    83 cerr << "Unhandled type for FSub instruction: " << *Ty << "\n";
    84 abort();
    85 }
    86 }
    87
    88 static void executeFMulInst(GenericValue &Dest, GenericValue Src1,
    89 GenericValue Src2, const Type *Ty) {
    90 switch (Ty->getTypeID()) {
    10191 IMPLEMENT_BINARY_OPERATOR(*, Float);
    10292 IMPLEMENT_BINARY_OPERATOR(*, Double);
    10393 default:
    104 cerr << "Unhandled type for Mul instruction: " << *Ty << "\n";
    94 cerr << "Unhandled type for FMul instruction: " << *Ty << "\n";
    10595 abort();
    10696 }
    10797 }
    549539 GenericValue R; // Result
    550540
    551541 switch (I.getOpcode()) {
    552 case Instruction::Add: executeAddInst (R, Src1, Src2, Ty); break;
    553 case Instruction::Sub: executeSubInst (R, Src1, Src2, Ty); break;
    554 case Instruction::Mul: executeMulInst (R, Src1, Src2, Ty); break;
    555 case Instruction::FDiv: executeFDivInst (R, Src1, Src2, Ty); break;
    556 case Instruction::FRem: executeFRemInst (R, Src1, Src2, Ty); break;
    542 case Instruction::Add: R.IntVal = Src1.IntVal + Src2.IntVal; break;
    543 case Instruction::Sub: R.IntVal = Src1.IntVal - Src2.IntVal; break;
    544 case Instruction::Mul: R.IntVal = Src1.IntVal * Src2.IntVal; break;
    545 case Instruction::FAdd: executeFAddInst(R, Src1, Src2, Ty); break;
    546 case Instruction::FSub: executeFSubInst(R, Src1, Src2, Ty); break;
    547 case Instruction::FMul: executeFMulInst(R, Src1, Src2, Ty); break;
    548 case Instruction::FDiv: executeFDivInst(R, Src1, Src2, Ty); break;
    549 case Instruction::FRem: executeFRemInst(R, Src1, Src2, Ty); break;
    557550 case Instruction::UDiv: R.IntVal = Src1.IntVal.udiv(Src2.IntVal); break;
    558551 case Instruction::SDiv: R.IntVal = Src1.IntVal.sdiv(Src2.IntVal); break;
    559552 case Instruction::URem: R.IntVal = Src1.IntVal.urem(Src2.IntVal); break;
    12571250 GenericValue Dest;
    12581251 const Type * Ty = CE->getOperand(0)->getType();
    12591252 switch (CE->getOpcode()) {
    1260 case Instruction::Add: executeAddInst (Dest, Op0, Op1, Ty); break;
    1261 case Instruction::Sub: executeSubInst (Dest, Op0, Op1, Ty); break;
    1262 case Instruction::Mul: executeMulInst (Dest, Op0, Op1, Ty); break;
    1253 case Instruction::Add: Dest.IntVal = Op0.IntVal + Op1.IntVal; break;
    1254 case Instruction::Sub: Dest.IntVal = Op0.IntVal - Op1.IntVal; break;
    1255 case Instruction::Mul: Dest.IntVal = Op0.IntVal * Op1.IntVal; break;
    1256 case Instruction::FAdd: executeFAddInst(Dest, Op0, Op1, Ty); break;
    1257 case Instruction::FSub: executeFSubInst(Dest, Op0, Op1, Ty); break;
    1258 case Instruction::FMul: executeFMulInst(Dest, Op0, Op1, Ty); break;
    12631259 case Instruction::FDiv: executeFDivInst(Dest, Op0, Op1, Ty); break;
    12641260 case Instruction::FRem: executeFRemInst(Dest, Op0, Op1, Ty); break;
    12651261 case Instruction::SDiv: Dest.IntVal = Op0.IntVal.sdiv(Op1.IntVal); break;
    12661262 case Instruction::UDiv: Dest.IntVal = Op0.IntVal.udiv(Op1.IntVal); break;
    12671263 case Instruction::URem: Dest.IntVal = Op0.IntVal.urem(Op1.IntVal); break;
    12681264 case Instruction::SRem: Dest.IntVal = Op0.IntVal.srem(Op1.IntVal); break;
    1269 case Instruction::And: Dest.IntVal = Op0.IntVal.And(Op1.IntVal); break;
    1270 case Instruction::Or: Dest.IntVal = Op0.IntVal.Or(Op1.IntVal); break;
    1271 case Instruction::Xor: Dest.IntVal = Op0.IntVal.Xor(Op1.IntVal); break;
    1265 case Instruction::And: Dest.IntVal = Op0.IntVal & Op1.IntVal; break;
    1266 case Instruction::Or: Dest.IntVal = Op0.IntVal | Op1.IntVal; break;
    1267 case Instruction::Xor: Dest.IntVal = Op0.IntVal ^ Op1.IntVal; break;
    12721268 case Instruction::Shl:
    12731269 Dest.IntVal = Op0.IntVal.shl(Op1.IntVal.getZExtValue());
    12741270 break;
    890890 break;
    891891 }
    892892 case Instruction::Add:
    893 case Instruction::FAdd:
    893894 case Instruction::Sub:
    895 case Instruction::FSub:
    894896 case Instruction::Mul:
    897 case Instruction::FMul:
    895898 case Instruction::UDiv:
    896899 case Instruction::SDiv:
    897900 case Instruction::URem:
    999999 Out << ')';
    10001000 return;
    10011001 case Instruction::Add:
    1002 case Instruction::FAdd:
    10021003 case Instruction::Sub:
    1004 case Instruction::FSub:
    10031005 case Instruction::Mul:
    1006 case Instruction::FMul:
    10041007 case Instruction::SDiv:
    10051008 case Instruction::UDiv:
    10061009 case Instruction::FDiv:
    10191022 bool NeedsClosingParens = printConstExprCast(CE, Static);
    10201023 printConstantWithCast(CE->getOperand(0), CE->getOpcode());
    10211024 switch (CE->getOpcode()) {
    1022 case Instruction::Add: Out << " + "; break;
    1023 case Instruction::Sub: Out << " - "; break;
    1024 case Instruction::Mul: Out << " * "; break;
    1025 case Instruction::Add:
    1026 case Instruction::FAdd: Out << " + "; break;
    1027 case Instruction::Sub:
    1028 case Instruction::FSub: Out << " - "; break;
    1029 case Instruction::Mul:
    1030 case Instruction::FMul: Out << " * "; break;
    10251031 case Instruction::URem:
    10261032 case Instruction::SRem:
    10271033 case Instruction::FRem: Out << " % "; break;
    13211327 case Instruction::Mul:
    13221328 // We need to cast integer arithmetic so that it is always performed
    13231329 // as unsigned, to avoid undefined behavior on overflow.
    1324 if (!Ty->isIntOrIntVector()) break;
    1325 // FALL THROUGH
    13261330 case Instruction::LShr:
    13271331 case Instruction::URem:
    13281332 case Instruction::UDiv: NeedsExplicitCast = true; break;
    13861390 case Instruction::Mul:
    13871391 // We need to cast integer arithmetic so that it is always performed
    13881392 // as unsigned, to avoid undefined behavior on overflow.
    1389 if (!OpTy->isIntOrIntVector()) break;
    1390 // FALL THROUGH
    13911393 case Instruction::LShr:
    13921394 case Instruction::UDiv:
    13931395 case Instruction::URem:
    15041506 case Instruction::Mul:
    15051507 // We need to cast integer arithmetic so that it is always performed
    15061508 // as unsigned, to avoid undefined behavior on overflow.
    1507 if (!Ty->isIntOrIntVector()) break;
    1508 // FALL THROUGH
    15091509 case Instruction::LShr:
    15101510 case Instruction::URem:
    15111511 case Instruction::UDiv:
    15511551 case Instruction::Mul:
    15521552 // We need to cast integer arithmetic so that it is always performed
    15531553 // as unsigned, to avoid undefined behavior on overflow.
    1554 if (!OpTy->isIntOrIntVector()) break;
    1555 // FALL THROUGH
    15561554 case Instruction::LShr:
    15571555 case Instruction::UDiv:
    15581556 case Instruction::URem: // Cast to unsigned first
    26012599
    26022600 // If this is a negation operation, print it out as such. For FP, we don't
    26032601 // want to print "-0.0 - X".
    2604 if (BinaryOperator::isNeg(&I)) {
    2602 if (BinaryOperator::isNeg(&I) || BinaryOperator::isFNeg(&I)) {
    26052603 Out << "-(";
    26062604 writeOperand(BinaryOperator::getNegArgument(cast(&I)));
    2605 Out << ")";
    2606 } else if (BinaryOperator::isFNeg(&I)) {
    2607 Out << "-(";
    2608 writeOperand(BinaryOperator::getFNegArgument(cast(&I)));
    26072609 Out << ")";
    26082610 } else if (I.getOpcode() == Instruction::FRem) {
    26092611 // Output a call to fmod/fmodf instead of emitting a%b
    26292631 writeOperandWithCast(I.getOperand(0), I.getOpcode());
    26302632
    26312633 switch (I.getOpcode()) {
    2632 case Instruction::Add: Out << " + "; break;
    2633 case Instruction::Sub: Out << " - "; break;
    2634 case Instruction::Mul: Out << " * "; break;
    2634 case Instruction::Add:
    2635 case Instruction::FAdd: Out << " + "; break;
    2636 case Instruction::Sub:
    2637 case Instruction::FSub: Out << " - "; break;
    2638 case Instruction::Mul:
    2639 case Instruction::FMul: Out << " * "; break;
    26352640 case Instruction::URem:
    26362641 case Instruction::SRem:
    26372642 case Instruction::FRem: Out << " % "; break;
    864864 Out << "Constant* " << constName << " = ConstantExpr::";
    865865 switch (CE->getOpcode()) {
    866866 case Instruction::Add: Out << "getAdd("; break;
    867 case Instruction::FAdd: Out << "getFAdd("; break;
    867868 case Instruction::Sub: Out << "getSub("; break;
    869 case Instruction::FSub: Out << "getFSub("; break;
    868870 case Instruction::Mul: Out << "getMul("; break;
    871 case Instruction::FMul: Out << "getFMul("; break;
    869872 case Instruction::UDiv: Out << "getUDiv("; break;
    870873 case Instruction::SDiv: Out << "getSDiv("; break;
    871874 case Instruction::FDiv: Out << "getFDiv("; break;
    11581161 break;
    11591162 }
    11601163 case Instruction::Add:
    1164 case Instruction::FAdd:
    11611165 case Instruction::Sub:
    1166 case Instruction::FSub:
    11621167 case Instruction::Mul:
    1168 case Instruction::FMul:
    11631169 case Instruction::UDiv:
    11641170 case Instruction::SDiv:
    11651171 case Instruction::FDiv:
    11751181 Out << "BinaryOperator* " << iName << " = BinaryOperator::Create(";
    11761182 switch (I->getOpcode()) {
    11771183 case Instruction::Add: Out << "Instruction::Add"; break;
    1184 case Instruction::FAdd: Out << "Instruction::FAdd"; break;
    11781185 case Instruction::Sub: Out << "Instruction::Sub"; break;
    1186 case Instruction::FSub: Out << "Instruction::FSub"; break;
    11791187 case Instruction::Mul: Out << "Instruction::Mul"; break;
    1188 case Instruction::FMul: Out << "Instruction::FMul"; break;
    11801189 case Instruction::UDiv:Out << "Instruction::UDiv"; break;
    11811190 case Instruction::SDiv:Out << "Instruction::SDiv"; break;
    11821191 case Instruction::FDiv:Out << "Instruction::FDiv"; break;
    10591059 break;
    10601060 // Binary
    10611061 case Instruction::Add:
    1062 case Instruction::FAdd:
    10621063 printBinaryInstruction("add",Left,Right);
    10631064 break;
    10641065 case Instruction::Sub:
    1066 case Instruction::FSub:
    10651067 printBinaryInstruction("sub",Left,Right);
    10661068 break;
    1067 case Instruction::Mul:
    1069 case Instruction::Mul:
    1070 case Instruction::FMul:
    10681071 printBinaryInstruction("mul",Left,Right);
    10691072 break;
    10701073 case Instruction::UDiv:
    13211324 printSelectInstruction(CE->getOperand(0),CE->getOperand(1),CE->getOperand(2));
    13221325 break;
    13231326 case Instruction::Add:
    1327 case Instruction::FAdd:
    13241328 printBinaryInstruction("add",left,right);
    13251329 break;
    13261330 case Instruction::Sub:
    1331 case Instruction::FSub:
    13271332 printBinaryInstruction("sub",left,right);
    13281333 break;
    13291334 case Instruction::Mul:
    1335 case Instruction::FMul:
    13301336 printBinaryInstruction("mul",left,right);
    13311337 break;
    13321338 case Instruction::UDiv:
    5858 /// two values.
    5959 namespace {
    6060 struct VISIBILITY_HIDDEN Expression {
    61 enum ExpressionOpcode { ADD, SUB, MUL, UDIV, SDIV, FDIV, UREM, SREM,
    61 enum ExpressionOpcode { ADD, FADD, SUB, FSUB, MUL, FMUL,
    62 UDIV, SDIV, FDIV, UREM, SREM,
    6263 FREM, SHL, LSHR, ASHR, AND, OR, XOR, ICMPEQ,
    6364 ICMPNE, ICMPUGT, ICMPUGE, ICMPULT, ICMPULE,
    6465 ICMPSGT, ICMPSGE, ICMPSLT, ICMPSLE, FCMPOEQ,
    199200 default: // THIS SHOULD NEVER HAPPEN
    200201 assert(0 && "Binary operator with unknown opcode?");
    201202 case Instruction::Add: return Expression::ADD;
    203 case Instruction::FAdd: return Expression::FADD;
    202204 case Instruction::Sub: return Expression::SUB;
    205 case Instruction::FSub: return Expression::FSUB;
    203206 case Instruction::Mul: return Expression::MUL;
    207 case Instruction::FMul: return Expression::FMUL;
    204208 case Instruction::UDiv: return Expression::UDIV;
    205209 case Instruction::SDiv: return Expression::SDIV;
    206210 case Instruction::FDiv: return Expression::FDIV;
    5454 /// two values.
    5555
    5656 struct Expression {
    57 enum ExpressionOpcode { ADD, SUB, MUL, UDIV, SDIV, FDIV, UREM, SREM,
    57 enum ExpressionOpcode { ADD, FADD, SUB, FSUB, MUL, FMUL,
    58 UDIV, SDIV, FDIV, UREM, SREM,
    5859 FREM, SHL, LSHR, ASHR, AND, OR, XOR, ICMPEQ,
    5960 ICMPNE, ICMPUGT, ICMPUGE, ICMPULT, ICMPULE,
    6061 ICMPSGT, ICMPSGE, ICMPSLT, ICMPSLE, FCMPOEQ,
    201202 switch(BO->getOpcode()) {
    202203 case Instruction::Add:
    203204 return Expression::ADD;
    205 case Instruction::FAdd:
    206 return Expression::FADD;
    204207 case Instruction::Sub:
    205208 return Expression::SUB;
    209 case Instruction::FSub:
    210 return Expression::FSUB;
    206211 case Instruction::Mul:
    207212 return Expression::MUL;
    213 case Instruction::FMul:
    214 return Expression::FMUL;
    208215 case Instruction::UDiv:
    209216 return Expression::UDIV;
    210217 case Instruction::SDiv:
    753753 BinaryOperator *Incr =
    754754 dyn_cast(PH->getIncomingValue(BackEdge));
    755755 if (!Incr) return;
    756 if (Incr->getOpcode() != Instruction::Add) return;
    756 if (Incr->getOpcode() != Instruction::FAdd) return;
    757757 ConstantFP *IncrValue = NULL;
    758758 unsigned IncrVIndex = 1;
    759759 if (Incr->getOperand(1) == PH)
    166166 // otherwise - Change was made, replace I with returned instruction
    167167 //
    168168 Instruction *visitAdd(BinaryOperator &I);
    169 Instruction *visitFAdd(BinaryOperator &I);
    169170 Instruction *visitSub(BinaryOperator &I);
    171 Instruction *visitFSub(BinaryOperator &I);
    170172 Instruction *visitMul(BinaryOperator &I);
    173 Instruction *visitFMul(BinaryOperator &I);
    171174 Instruction *visitURem(BinaryOperator &I);
    172175 Instruction *visitSRem(BinaryOperator &I);
    173176 Instruction *visitFRem(BinaryOperator &I);
    402405 // 0 -> undef, 1 -> Const, 2 -> Other, 3 -> Arg, 3 -> Unary, 4 -> OtherInst
    403406 static unsigned getComplexity(Value *V) {
    404407 if (isa(V)) {
    405 if (BinaryOperator::isNeg(V) || BinaryOperator::isNot(V))
    408 if (BinaryOperator::isNeg(V) || BinaryOperator::isFNeg(V) ||
    409 BinaryOperator::isNot(V))
    406410 return 3;
    407411 return 4;
    408412 }
    571575 if (ConstantVector *C = dyn_cast(V))
    572576 if (C->getType()->getElementType()->isInteger())
    573577 return ConstantExpr::getNeg(C);
    578
    579 return 0;
    580 }
    581
    582 // dyn_castFNegVal - Given a 'fsub' instruction, return the RHS of the
    583 // instruction if the LHS is a constant negative zero (which is the 'negate'
    584 // form).
    585 //
    586 static inline Value *dyn_castFNegVal(Value *V) {
    587 if (BinaryOperator::isFNeg(V))
    588 return BinaryOperator::getFNegArgument(V);
    589
    590 // Constants can be considered to be negated values if they can be folded.
    591 if (ConstantFP *C = dyn_cast(V))
    592 return ConstantExpr::getFNeg(C);
    593
    594 if (ConstantVector *C = dyn_cast(V))
    595 if (C->getType()->getElementType()->isFloatingPoint())
    596 return ConstantExpr::getFNeg(C);
    574597
    575598 return 0;
    576599 }
    17321755 default: assert(0 && "Case stmts out of sync!");
    17331756 case Intrinsic::x86_sse_sub_ss:
    17341757 case Intrinsic::x86_sse2_sub_sd:
    1735 TmpV = InsertNewInstBefore(BinaryOperator::CreateSub(LHS, RHS,
    1758 TmpV = InsertNewInstBefore(BinaryOperator::CreateFSub(LHS, RHS,
    17361759 II->getName()), *II);
    17371760 break;
    17381761 case Intrinsic::x86_sse_mul_ss:
    17391762 case Intrinsic::x86_sse2_mul_sd:
    1740 TmpV = InsertNewInstBefore(BinaryOperator::CreateMul(LHS, RHS,
    1763 TmpV = InsertNewInstBefore(BinaryOperator::CreateFMul(LHS, RHS,
    17411764 II->getName()), *II);
    17421765 break;
    17431766 }
    20512074 return ReplaceInstUsesWith(I, RHS);
    20522075
    20532076 // X + 0 --> X
    2054 if (!I.getType()->isFPOrFPVector()) { // NOTE: -0 + +0 = +0.
    2055 if (RHSC->isNullValue())
    2056 return ReplaceInstUsesWith(I, LHS);
    2057 } else if (ConstantFP *CFP = dyn_cast(RHSC)) {
    2058 if (CFP->isExactlyValue(ConstantFP::getNegativeZero
    2059 (I.getType())->getValueAPF()))
    2060 return ReplaceInstUsesWith(I, LHS);
    2061 }
    2077 if (RHSC->isNullValue())
    2078 return ReplaceInstUsesWith(I, LHS);
    20622079
    20632080 if (ConstantInt *CI = dyn_cast(RHSC)) {
    20642081 // X + (signbit) --> X ^ signbit
    23162333 return SelectInst::Create(SI->getCondition(), A, N);
    23172334 }
    23182335 }
    2319
    2320 // Check for X+0.0. Simplify it to X if we know X is not -0.0.
    2321 if (ConstantFP *CFP = dyn_cast(RHS))
    2322 if (CFP->getValueAPF().isPosZero() && CannotBeNegativeZero(LHS))
    2323 return ReplaceInstUsesWith(I, LHS);
    23242336
    23252337 // Check for (add (sext x), y), see if we can merge this into an
    23262338 // integer add followed by a sext.
    23582370 }
    23592371 }
    23602372 }
    2361
    2373
    2374 return Changed ? &I : 0;
    2375 }
    2376
    2377 Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
    2378 bool Changed = SimplifyCommutative(I);
    2379 Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
    2380
    2381 if (Constant *RHSC = dyn_cast(RHS)) {
    2382 // X + 0 --> X
    2383 if (ConstantFP *CFP = dyn_cast(RHSC)) {
    2384 if (CFP->isExactlyValue(ConstantFP::getNegativeZero
    2385 (I.getType())->getValueAPF()))
    2386 return ReplaceInstUsesWith(I, LHS);
    2387 }
    2388
    2389 if (isa(LHS))
    2390 if (Instruction *NV = FoldOpIntoPhi(I))
    2391 return NV;
    2392 }
    2393
    2394 // -A + B --> B - A
    2395 // -A + -B --> -(A + B)
    2396 if (Value *LHSV = dyn_castFNegVal(LHS))
    2397 return BinaryOperator::CreateFSub(RHS, LHSV);
    2398
    2399 // A + -B --> A - B
    2400 if (!isa(RHS))
    2401 if (Value *V = dyn_castFNegVal(RHS))
    2402 return BinaryOperator::CreateFSub(LHS, V);
    2403
    2404 // Check for X+0.0. Simplify it to X if we know X is not -0.0.
    2405 if (ConstantFP *CFP = dyn_cast(RHS))
    2406 if (CFP->getValueAPF().isPosZero() && CannotBeNegativeZero(LHS))
    2407 return ReplaceInstUsesWith(I, LHS);
    2408
    23622409 // Check for (add double (sitofp x), y), see if we can merge this into an
    23632410 // integer add followed by a promotion.
    23642411 if (SIToFPInst *LHSConv = dyn_cast(LHS)) {
    24062453 Instruction *InstCombiner::visitSub(BinaryOperator &I) {
    24072454 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
    24082455
    2409 if (Op0 == Op1 && // sub X, X -> 0
    2410 !I.getType()->isFPOrFPVector())
    2456 if (Op0 == Op1) // sub X, X -> 0
    24112457 return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
    24122458
    24132459 // If this is a 'B = x-(-A)', change to B = x+A...
    24682514 return BinaryOperator::CreateXor(Op0, Op1);
    24692515
    24702516 if (BinaryOperator *Op1I = dyn_cast(Op1)) {
    2471 if (Op1I->getOpcode() == Instruction::Add &&
    2472 !Op0->getType()->isFPOrFPVector()) {
    2517 if (Op1I->getOpcode() == Instruction::Add) {
    24732518 if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y
    24742519 return BinaryOperator::CreateNeg(Op1I->getOperand(1), I.getName());
    24752520 else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y
    24862531 // Replace (x - (y - z)) with (x + (z - y)) if the (y - z) subexpression
    24872532 // is not used by anyone else...
    24882533 //
    2489 if (Op1I->getOpcode() == Instruction::Sub &&
    2490 !Op1I->getType()->isFPOrFPVector()) {
    2534 if (Op1I->getOpcode() == Instruction::Sub) {
    24912535 // Swap the two operands of the subexpr...
    24922536 Value *IIOp0 = Op1I->getOperand(0), *IIOp1 = Op1I->getOperand(1);
    24932537 Op1I->setOperand(0, IIOp1);
    25252569 }
    25262570 }
    25272571
    2528 if (!Op0->getType()->isFPOrFPVector())
    2529 if (BinaryOperator *Op0I = dyn_cast(Op0)) {
    2530 if (Op0I->getOpcode() == Instruction::Add) {
    2531 if (Op0I->getOperand(0) == Op1) // (Y+X)-Y == X
    2532 return ReplaceInstUsesWith(I, Op0I->getOperand(1));
    2533 else if (Op0I->getOperand(1) == Op1) // (X+Y)-Y == X
    2534 return ReplaceInstUsesWith(I, Op0I->getOperand(0));
    2535 } else if (Op0I->getOpcode() == Instruction::Sub) {
    2536 if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y
    2537 return BinaryOperator::CreateNeg(Op0I->getOperand(1), I.getName());
    2538 }
    2539 }
    2572 if (BinaryOperator *Op0I = dyn_cast(Op0)) {
    2573 if (Op0I->getOpcode() == Instruction::Add) {
    2574 if (Op0I->getOperand(0) == Op1) // (Y+X)-Y == X
    2575 return ReplaceInstUsesWith(I, Op0I->getOperand(1));
    2576 else if (Op0I->getOperand(1) == Op1) // (X+Y)-Y == X
    2577 return ReplaceInstUsesWith(I, Op0I->getOperand(0));
    2578 } else if (Op0I->getOpcode() == Instruction::Sub) {
    2579 if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y
    2580 return BinaryOperator::CreateNeg(Op0I->getOperand(1), I.getName());
    2581 }
    2582 }
    25402583
    25412584 ConstantInt *C1;
    25422585 if (Value *X = dyn_castFoldableMul(Op0, C1)) {
    25472590 if (X == dyn_castFoldableMul(Op1, C2))
    25482591 return BinaryOperator::CreateMul(X, Subtract(C1, C2));
    25492592 }
    2593 return 0;
    2594 }
    2595
    2596 Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
    2597 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
    2598
    2599 // If this is a 'B = x-(-A)', change to B = x+A...
    2600 if (Value *V = dyn_castFNegVal(Op1))
    2601 return BinaryOperator::CreateFAdd(Op0, V);
    2602
    2603 if (BinaryOperator *Op1I = dyn_cast(Op1)) {
    2604 if (Op1I->getOpcode() == Instruction::FAdd) {
    2605 if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y
    2606 return BinaryOperator::CreateFNeg(Op1I->getOperand(1), I.getName());
    2607 else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y
    2608 return BinaryOperator::CreateFNeg(Op1I->getOperand(0), I.getName());
    2609 }
    2610
    2611 if (Op1I->hasOneUse()) {
    2612 // Replace (x - (y - z)) with (x + (z - y)) if the (y - z) subexpression
    2613 // is not used by anyone else...
    2614 //
    2615 if (Op1I->getOpcode() == Instruction::FSub) {
    2616 // Swap the two operands of the subexpr...
    2617 Value *IIOp0 = Op1I->getOperand(0), *IIOp1 = Op1I->getOperand(1);
    2618 Op1I->setOperand(0, IIOp1);
    2619 Op1I->setOperand(1, IIOp0);
    2620
    2621 // Create the new top level fadd instruction...
    2622 return BinaryOperator::CreateFAdd(Op0, Op1);
    2623 }
    2624 }
    2625 }
    2626
    25502627 return 0;
    25512628 }
    25522629
    26122689 return BinaryOperator::CreateShl(Op0,
    26132690 ConstantInt::get(Op0->getType(), Val.logBase2()));
    26142691 }
    2615 } else if (ConstantFP *Op1F = dyn_cast(Op1)) {
    2616 // TODO: If Op1 is zero and Op0 is finite, return zero.
    2617
    2618 // "In IEEE floating point, x*1 is not equivalent to x for nans. However,
    2619 // ANSI says we can drop signals, so we can do this anyway." (from GCC)
    2620 if (Op1F->isExactlyValue(1.0))
    2621 return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
    26222692 } else if (isa(Op1->getType())) {
    26232693 // TODO: If Op1 is all zeros and Op0 is all finite, return all zeros.
    26242694
    26282698
    26292699 // As above, vector X*splat(1.0) -> X in all defined cases.
    26302700 if (Constant *Splat = Op1V->getSplatValue()) {
    2631 if (ConstantFP *F = dyn_cast(Splat))
    2632 if (F->isExactlyValue(1.0))
    2633 return ReplaceInstUsesWith(I, Op0);
    26342701 if (ConstantInt *CI = dyn_cast(Splat))
    26352702 if (CI->equalsInt(1))
    26362703 return ReplaceInstUsesWith(I, Op0);
    27502817 }
    27512818 }
    27522819 }
    2820
    2821 return Changed ? &I : 0;
    2822 }
    2823
    2824 Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
    2825 bool Changed = SimplifyCommutative(I);
    2826 Value *Op0 = I.getOperand(0);
    2827
    2828 // Simplify mul instructions with a constant RHS...
    2829 if (Constant *Op1 = dyn_cast(I.getOperand(1))) {
    2830 if (ConstantFP *Op1F = dyn_cast(Op1)) {
    2831 // "In IEEE floating point, x*1 is not equivalent to x for nans. However,
    2832 // ANSI says we can drop signals, so we can do this anyway." (from GCC)
    2833 if (Op1F->isExactlyValue(1.0))
    2834 return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
    2835 } else if (isa(Op1->getType())) {
    2836 if (ConstantVector *Op1V = dyn_cast(Op1)) {
    2837 // As above, vector X*splat(1.0) -> X in all defined cases.
    2838 if (Constant *Splat = Op1V->getSplatValue()) {
    2839 if (ConstantFP *F = dyn_cast(Splat))
    2840 if (F->isExactlyValue(1.0))
    2841 return ReplaceInstUsesWith(I, Op0);
    2842 }
    2843 }
    2844 }
    2845
    2846 // Try to fold constant mul into select arguments.
    2847 if (SelectInst *SI = dyn_cast(Op0))
    2848 if (Instruction *R = FoldOpIntoSelect(I, SI, this))
    2849 return R;
    2850
    2851 if (isa(Op0))
    2852 if (Instruction *NV = FoldOpIntoPhi(I))
    2853 return NV;
    2854 }
    2855
    2856 if (Value *Op0v = dyn_castFNegVal(Op0)) // -X * -Y = X*Y
    2857 if (Value *Op1v = dyn_castFNegVal(I.getOperand(1)))
    2858 return BinaryOperator::CreateFMul(Op0v, Op1v);
    27532859
    27542860 return Changed ? &I : 0;
    27552861 }
    85618667 if (Instruction *I = commonCastTransforms(CI))
    85628668 return I;
    85638669
    8564 // If we have fptrunc(add (fpextend x), (fpextend y)), where x and y are
    8670 // If we have fptrunc(fadd (fpextend x), (fpextend y)), where x and y are
    85658671 // smaller than the destination type, we can eliminate the truncate by doing
    8566 // the add as the smaller type. This applies to add/sub/mul/div as well as
    8672 // the add as the smaller type. This applies to fadd/fsub/fmul/fdiv as well as
    85678673 // many builtins (sqrt, etc).
    85688674 BinaryOperator *OpI = dyn_cast(CI.getOperand(0));
    85698675 if (OpI && OpI->hasOneUse()) {
    85708676 switch (OpI->getOpcode()) {
    85718677 default: break;
    8572 case Instruction::Add:
    8573 case Instruction::Sub:
    8574 case Instruction::Mul:
    8678 case Instruction::FAdd:
    8679 case Instruction::FSub:
    8680 case Instruction::FMul:
    85758681 case Instruction::FDiv:
    85768682 case Instruction::FRem:
    85778683 const Type *SrcTy = OpI->getType();
    93219427
    93229428 // Turn select C, (X+Y), (X-Y) --> (X+(select C, Y, (-Y))). This is
    93239429 // even legal for FP.
    9324 if (TI->getOpcode() == Instruction::Sub &&
    9325 FI->getOpcode() == Instruction::Add) {
    9430 if ((TI->getOpcode() == Instruction::Sub &&
    9431 FI->getOpcode() == Instruction::Add) ||
    9432 (TI->getOpcode() == Instruction::FSub &&
    9433 FI->getOpcode() == Instruction::FAdd)) {
    93269434 AddOp = FI; SubOp = TI;
    9327 } else if (FI->getOpcode() == Instruction::Sub &&
    9328 TI->getOpcode() == Instruction::Add) {
    9435 } else if ((FI->getOpcode() == Instruction::Sub &&
    9436 TI->getOpcode() == Instruction::Add) ||
    9437 (FI->getOpcode() == Instruction::FSub &&
    9438 TI->getOpcode() == Instruction::FAdd)) {
    93299439 AddOp = TI; SubOp = FI;
    93309440 }
    93319441
    22672267 /* create new increment. '++d' in above example. */
    22682268 ConstantFP *CFP = ConstantFP::get(DestTy, C->getZExtValue());
    22692269 BinaryOperator *NewIncr =
    2270 BinaryOperator::Create(Incr->getOpcode(),
    2270 BinaryOperator::Create(Incr->getOpcode() == Instruction::Add ?
    2271 Instruction::FAdd : Instruction::FSub,
    22712272 NewPH, CFP, "IV.S.next.", Incr);
    22722273
    22732274 NewPH->addIncoming(NewInit, PH->getIncomingBlock(Entry));
    10081008 if (Op2C->isExactlyValue(1.0)) // pow(x, 1.0) -> x
    10091009 return Op1;
    10101010 if (Op2C->isExactlyValue(2.0)) // pow(x, 2.0) -> x*x
    1011 return B.CreateMul(Op1, Op1, "pow2");
    1011 return B.CreateFMul(Op1, Op1, "pow2");
    10121012 if (Op2C->isExactlyValue(-1.0)) // pow(x, -1.0) -> 1.0/x
    10131013 return B.CreateFDiv(ConstantFP::get(CI->getType(), 1.0), Op1, "powrecip");
    10141014 return 0;
    418418 case Instruction::LShr:
    419419 case Instruction::AShr:
    420420 case Instruction::ICmp:
    421 case Instruction::FCmp:
    422 if (I->getOperand(0)->getType()->isFPOrFPVector())
    423 return false; // FP arithmetic might trap.
    424421 break; // These are all cheap and non-trapping instructions.
    425422 }
    426423
    10111008 default: return false; // Not safe / profitable to hoist.
    10121009 case Instruction::Add:
    10131010 case Instruction::Sub:
    1014 // FP arithmetic might trap. Not worth doing for vector ops.
    1015 if (HInst->getType()->isFloatingPoint()
    1016 || isa(HInst->getType()))
    1011 // Not worth doing for vector ops.
    1012 if (isa(HInst->getType()))
    10171013 return false;
    10181014 break;
    10191015 case Instruction::And:
    601601 return Constant::getNullValue(C1->getType());
    602602 case Instruction::UDiv:
    603603 case Instruction::SDiv:
    604 case Instruction::FDiv:
    605604 case Instruction::URem:
    606605 case Instruction::SRem:
    607 case Instruction::FRem:
    608606 if (!isa(C2)) // undef / X -> 0
    609607 return Constant::getNullValue(C1->getType());
    610608 return const_cast(C2); // X / undef -> undef
    782780 switch (Opcode) {
    783781 default:
    784782 break;
    785 case Instruction::Add:
    783 case Instruction::FAdd:
    786784 (void)C3V.add(C2V, APFloat::rmNearestTiesToEven);
    787785 return ConstantFP::get(C3V);
    788 case Instruction::Sub:
    786 case Instruction::FSub:
    789787 (void)C3V.subtract(C2V, APFloat::rmNearestTiesToEven);
    790788 return ConstantFP::get(C3V);
    791 case Instruction::Mul:
    789 case Instruction::FMul:
    792790 (void)C3V.multiply(C2V, APFloat::rmNearestTiesToEven);
    793791 return ConstantFP::get(C3V);
    794792 case Instruction::FDiv:
    807805 switch (Opcode) {
    808806 default:
    809807 break;
    810 case Instruction::Add:
    808 case Instruction::Add:
    811809 return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getAdd);
    812 case Instruction::Sub:
    810 case Instruction::FAdd:
    811 return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFAdd);
    812 case Instruction::Sub:
    813813 return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getSub);
    814 case Instruction::Mul:
    814 case Instruction::FSub:
    815 return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFSub);
    816 case Instruction::Mul:
    815817 return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getMul);
    818 case Instruction::FMul:
    819 return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFMul);
    816820 case Instruction::UDiv:
    817821 return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getUDiv);
    818822 case Instruction::SDiv:
    850854 // other way if possible.
    851855 switch (Opcode) {
    852856 case Instruction::Add:
    857 case Instruction::FAdd:
    853858 case Instruction::Mul:
    859 case Instruction::FMul:
    854860 case Instruction::And:
    855861 case Instruction::Or:
    856862 case Instruction::Xor:
    861867 case Instruction::LShr:
    862868 case Instruction::AShr:
    863869 case Instruction::Sub:
    870 case Instruction::FSub:
    864871 case Instruction::SDiv:
    865872 case Instruction::UDiv:
    866873 case Instruction::FDiv:
    774774 /// specify the full Instruction::OPCODE identifier.
    775775 ///
    776776 Constant *ConstantExpr::getNeg(Constant *C) {
    777 // API compatibility: Adjust integer opcodes to floating-point opcodes.
    778 if (C->getType()->isFPOrFPVector())
    779 return getFNeg(C);
    780 assert(C->getType()->isIntOrIntVector() &&
    781 "Cannot NEG a nonintegral value!");
    777782 return get(Instruction::Sub,
    778783 ConstantExpr::getZeroValueForNegationExpr(C->getType()),
    779784 C);
    780785 }
    786 Constant *ConstantExpr::getFNeg(Constant *C) {
    787 assert(C->getType()->isFPOrFPVector() &&
    788 "Cannot FNEG a non-floating-point value!");
    789 return get(Instruction::FSub,
    790 ConstantExpr::getZeroValueForNegationExpr(C->getType()),
    791 C);
    792 }
    781793 Constant *ConstantExpr::getNot(Constant *C) {
    782 assert((isa(C->getType()) ||
    783 cast(C->getType())->getElementType()->isInteger()) &&
    784 "Cannot NOT a nonintegral value!");
    794 assert(C->getType()->isIntOrIntVector() &&
    795 "Cannot NOT a nonintegral value!");
    785796 return get(Instruction::Xor, C,
    786797 Constant::getAllOnesValue(C->getType()));
    787798 }
    788799 Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2) {
    789800 return get(Instruction::Add, C1, C2);
    790801 }
    802 Constant *ConstantExpr::getFAdd(Constant *C1, Constant *C2) {
    803 return get(Instruction::FAdd, C1, C2);
    804 }
    791805 Constant *ConstantExpr::getSub(Constant *C1, Constant *C2) {
    792806 return get(Instruction::Sub, C1, C2);
    793807 }
    808 Constant *ConstantExpr::getFSub(Constant *C1, Constant *C2) {
    809 return get(Instruction::FSub, C1, C2);
    810 }
    794811 Constant *ConstantExpr::getMul(Constant *C1, Constant *C2) {
    795812 return get(Instruction::Mul, C1, C2);
    813 }
    814 Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2) {
    815 return get(Instruction::FMul, C1, C2);
    796816 }
    797817 Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2) {
    798818 return get(Instruction::UDiv, C1, C2);
    21412161 }
    21422162
    21432163 Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
    2164 // API compatibility: Adjust integer opcodes to floating-point opcodes.
    2165 if (C1->getType()->isFPOrFPVector()) {
    2166 if (Opcode == Instruction::Add) Opcode = Instruction::FAdd;
    2167 else if (Opcode == Instruction::Sub) Opcode = Instruction::FSub;
    2168 else if (Opcode == Instruction::Mul) Opcode = Instruction::FMul;
    2169 }
    21442170 #ifndef NDEBUG
    21452171 switch (Opcode) {
    2146 case Instruction::Add:
    2172 case Instruction::Add:
    21472173 case Instruction::Sub:
    2148 case Instruction::Mul:
    2174 case Instruction::Mul:
    21492175 assert(C1->getType() == C2->getType() && "Op types should be identical!");
    2150 assert((C1->getType()->isInteger() || C1->getType()->isFloatingPoint() ||
    2151 isa(C1->getType())) &&
    2152 "Tried to create an arithmetic operation on a non-arithmetic type!");
    2176 assert(C1->getType()->isIntOrIntVector() &&
    2177 "Tried to create an integer operation on a non-integer type!");
    2178 break;
    2179 case Instruction::FAdd:
    2180 case Instruction::FSub:
    2181 case Instruction::FMul:
    2182 assert(C1->getType() == C2->getType() && "Op types should be identical!");
    2183 assert(C1->getType()->isFPOrFPVector() &&
    2184 "Tried to create a floating-point operation on a "
    2185 "non-floating-point type!");
    21532186 break;
    21542187 case Instruction::UDiv:
    21552188 case Instruction::SDiv:
    100100
    101101 // Standard binary operators...
    102102 case Add: return "add";
    103 case FAdd: return "fadd";
    103104 case Sub: return "sub";
    105 case FSub: return "fsub";
    104106 case Mul: return "mul";
    107 case FMul: return "fmul";
    105108 case UDiv: return "udiv";
    106109 case SDiv: return "sdiv";
    107110 case FDiv: return "fdiv";
    329332
    330333 /// isAssociative - Return true if the instruction is associative:
    331334 ///
    332 /// Associative operators satisfy: x op (y op z) === (x op y) op z)
    333 ///
    334 /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative, when not
    335 /// applied to floating point types.
    335 /// Associative operators satisfy: x op (y op z) === (x op y) op z
    336 ///
    337 /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
    336338 ///
    337339 bool Instruction::isAssociative(unsigned Opcode, const Type *Ty) {
    338 if (Opcode == And || Opcode == Or || Opcode == Xor)
    339 return true;
    340
    341 // Add/Mul reassociate unless they are FP or FP vectors.
    342 if (Opcode == Add || Opcode == Mul)
    343 return !Ty->isFPOrFPVector();
    344 return 0;
    340 return Opcode == And || Opcode == Or || Opcode == Xor ||
    341 Opcode == Add || Opcode == Mul;
    345342 }
    346343
    347344 /// isCommutative - Return true if the instruction is commutative:
    354351 bool Instruction::isCommutative(unsigned op) {
    355352 switch (op) {
    356353 case Add:
    354 case FAdd:
    357355 case Mul:
    356 case FMul:
    358357 case And:
    359358 case Or:
    360359 case Xor:
    15011501 // BinaryOperator Class
    15021502 //===----------------------------------------------------------------------===//
    15031503
    1504 /// AdjustIType - Map Add, Sub, and Mul to FAdd, FSub, and FMul when the
    1505 /// type is floating-point, to help provide compatibility with an older API.
    1506 ///
    1507 static BinaryOperator::BinaryOps AdjustIType(BinaryOperator::BinaryOps iType,
    1508 const Type *Ty) {
    1509 // API compatibility: Adjust integer opcodes to floating-point opcodes.
    1510 if (Ty->isFPOrFPVector()) {
    1511 if (iType == BinaryOperator::Add) iType = BinaryOperator::FAdd;
    1512 else if (iType == BinaryOperator::Sub) iType = BinaryOperator::FSub;
    1513 else if (iType == BinaryOperator::Mul) iType = BinaryOperator::FMul;
    1514 }
    1515 return iType;
    1516 }
    1517
    15041518 BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
    15051519 const Type *Ty, const std::string &Name,
    15061520 Instruction *InsertBefore)
    1507 : Instruction(Ty, iType,
    1521 : Instruction(Ty, AdjustIType(iType, Ty),
    15081522 OperandTraits::op_begin(this),
    15091523 OperandTraits::operands(this),
    15101524 InsertBefore) {
    15111525 Op<0>() = S1;
    15121526 Op<1>() = S2;
    1513 init(iType);
    1527 init(AdjustIType(iType, Ty));
    15141528 setName(Name);
    15151529 }
    15161530
    15171531 BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
    15181532 const Type *Ty, const std::string &Name,
    15191533 BasicBlock *InsertAtEnd)
    1520 : Instruction(Ty, iType,
    1534 : Instruction(Ty, AdjustIType(iType, Ty),
    15211535 OperandTraits::op_begin(this),
    15221536 OperandTraits::operands(this),
    15231537 InsertAtEnd) {
    15241538 Op<0>() = S1;
    15251539 Op<1>() = S2;
    1526 init(iType);
    1540 init(AdjustIType(iType, Ty));
    15271541 setName(Name);
    15281542 }
    15291543
    15361550 #ifndef NDEBUG
    15371551 switch (iType) {
    15381552 case Add: case Sub:
    1539 case Mul:
    1553 case Mul:
    15401554 assert(getType() == LHS->getType() &&
    15411555 "Arithmetic operation should return same type as operands!");
    1542 assert((getType()->isInteger() || getType()->isFloatingPoint() ||
    1543 isa(getType())) &&
    1544 "Tried to create an arithmetic operation on a non-arithmetic type!");
    1556 assert(getType()->isIntOrIntVector() &&
    1557 "Tried to create an integer operation on a non-integer type!");
    1558 break;
    1559 case FAdd: case FSub:
    1560 case FMul:
    1561 assert(getType() == LHS->getType() &&
    1562 "Arithmetic operation should return same type as operands!");
    1563 assert(getType()->isFPOrFPVector() &&
    1564 "Tried to create a floating-point operation on a "
    1565 "non-floating-point type!");
    15451566 break;
    15461567 case UDiv:
    15471568 case SDiv:
    16301651 Op->getType(), Name, InsertAtEnd);
    16311652 }
    16321653
    1654 BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const std::string &Name,
    1655 Instruction *InsertBefore) {
    1656 Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
    1657 return new BinaryOperator(Instruction::FSub,
    1658 zero, Op,
    1659 Op->getType(), Name, InsertBefore);
    1660 }
    1661
    1662 BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const std::string &Name,
    1663 BasicBlock *InsertAtEnd) {
    1664 Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
    1665 return new BinaryOperator(Instruction::FSub,
    1666 zero, Op,
    1667 Op->getType(), Name, InsertAtEnd);
    1668 }
    1669
    16331670 BinaryOperator *BinaryOperator::CreateNot(Value *Op, const std::string &Name,
    16341671 Instruction *InsertBefore) {
    16351672 Constant *C;
    16781715 return false;
    16791716 }
    16801717
    1718 bool BinaryOperator::isFNeg(const Value *V) {
    1719 if (const BinaryOperator *Bop = dyn_cast(V))
    1720 if (Bop->getOpcode() == Instruction::FSub)
    1721 return Bop->getOperand(0) ==
    1722 ConstantExpr::getZeroValueForNegationExpr(Bop->getType());
    1723 return false;
    1724 }
    1725
    16811726 bool BinaryOperator::isNot(const Value *V) {
    16821727 if (const BinaryOperator *Bop = dyn_cast(V))
    16831728 return (Bop->getOpcode() == Instruction::Xor &&
    16931738
    16941739 const Value *BinaryOperator::getNegArgument(const Value *BinOp) {
    16951740 return getNegArgument(const_cast(BinOp));
    1741 }
    1742
    1743 Value *BinaryOperator::getFNegArgument(Value *BinOp) {
    1744 assert(isFNeg(BinOp) && "getFNegArgument from non-'fneg' instruction!");
    1745 return cast(BinOp)->getOperand(1);
    1746 }
    1747
    1748 const Value *BinaryOperator::getFNegArgument(const Value *BinOp) {
    1749 return getFNegArgument(const_cast(BinOp));
    16961750 }
    16971751
    16981752 Value *BinaryOperator::getNotArgument(Value *BinOp) {
    1717 %2 = sext i9 %1 to i64 ; [#uses=1]
    1818 %3 = getelementptr double* %x, i64 %2 ; [#uses=1]
    1919 %4 = load double* %3, align 8 ; [#uses=1]
    20 %5 = mul double %4, 3.900000e+00 ; [#uses=1]
    20 %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
    2121 %6 = sext i8 %0 to i64 ; [#uses=1]
    2222 %7 = getelementptr double* %x, i64 %6 ; [#uses=1]
    2323 store double %5, double* %7, align 8
    1717 %2 = sext i9 %1 to i64 ; [#uses=1]
    1818 %3 = getelementptr double* %x, i64 %2 ; [#uses=1]
    1919 %4 = load double* %3, align 8 ; [#uses=1]
    20 %5 = mul double %4, 3.900000e+00 ; [#uses=1]
    20 %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
    2121 %6 = sext i7 %0 to i64 ; [#uses=1]
    2222 %7 = getelementptr double* %x, i64 %6 ; [#uses=1]
    2323 store double %5, double* %7, align 8
    4040 %2 = sext i9 %1 to i64 ; [#uses=1]
    4141 %3 = getelementptr double* %x, i64 %2 ; [#uses=1]
    4242 %4 = load double* %3, align 8 ; [#uses=1]
    43 %5 = mul double %4, 3.900000e+00 ; [#uses=1]
    43 %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
    4444 %6 = sext i8 %0 to i64 ; [#uses=1]
    4545 %7 = getelementptr double* %x, i64 %6 ; [#uses=1]
    4646 store double %5, double* %7, align 8
    6363 %2 = sext i9 %1 to i64 ; [#uses=1]
    6464 %3 = getelementptr double* %x, i64 %2 ; [#uses=1]
    6565 %4 = load double* %3, align 8 ; [#uses=1]
    66 %5 = mul double %4, 3.900000e+00 ; [#uses=1]
    66 %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
    6767 %6 = sext i8 %0 to i64 ; [#uses=1]
    6868 %7 = getelementptr double* %x, i64 %6 ; [#uses=1]
    6969 store double %5, double* %7, align 8
    8686 %2 = sext i9 %1 to i64 ; [#uses=1]
    8787 %3 = getelementptr double* %x, i64 %2 ; [#uses=1]
    8888 %4 = load double* %3, align 8 ; [#uses=1]
    89 %5 = mul double %4, 3.900000e+00 ; [#uses=1]
    89 %5 = fmul double %4, 3.900000e+00 ; [#uses=1]
    9090 %6 = sext i8 %0 to i64 ; [#uses=1]
    9191 %7 = getelementptr double* %x, i64 %6 ; [#uses=1]
    9292 store double %5, double* %7, align 8
    1212 %indvar.i8 = ashr i64 %s0, 8 ; [#uses=1]
    1313 %t0 = getelementptr double* %d, i64 %indvar.i8 ; [#uses=2]
    1414 %t1 = load double* %t0 ; [#uses=1]
    15 %t2 = mul double %t1, 1.000000e-01 ; [#uses=1]
    15 %t2 = fmul double %t1, 1.000000e-01 ; [#uses=1]
    1616 store double %t2, double* %t0
    1717 %indvar.next = sub i64 %indvar, 1 ; [#uses=2]
    1818 %exitcond = icmp eq i64 %indvar.next, 10 ; [#uses=1]
    1010 ; RUN: diff %t.1 %t.2
    1111
    1212 define double @test() {
    13 %tmp = mul double 7.200000e+101, 0x427F4000 ; [#uses=1]
    13 %tmp = fmul double 7.200000e+101, 0x427F4000 ; [#uses=1]
    1414 ret double %tmp
    1515 }
    22 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep 0x7FF0000000000000
    33
    44 define float @test() {
    5 %tmp = mul float 0x7FF0000000000000, 1.000000e+01 ; [#uses=1]
    5 %tmp = fmul float 0x7FF0000000000000, 1.000000e+01 ; [#uses=1]
    66 ret float %tmp
    77 }
    88
    3434 %tmp612 = load i32* null ; [#uses=1]
    3535 %tmp629 = load i32* null ; [#uses=1]
    3636 %tmp629a = sitofp i32 %tmp629 to double ; [#uses=1]
    37 %tmp631 = mul double %tmp629a, 0.000000e+00 ; [#uses=1]
    38 %tmp632 = add double 0.000000e+00, %tmp631 ; [#uses=1]
    37 %tmp631 = fmul double %tmp629a, 0.000000e+00 ; [#uses=1]
    38 %tmp632 = fadd double 0.000000e+00, %tmp631 ; [#uses=1]
    3939 %tmp642 = call fastcc i32 @sign( i32 %tmp576, i32 %tmp561 ) ; [#uses=1]
    4040 %tmp650 = mul i32 %tmp606, %tmp642 ; [#uses=1]
    4141 %tmp656 = mul i32 %tmp650, %tmp612 ; [#uses=1]
    4545 %tmp666 = sub i32 %tmp660, %tmp496 ; [#uses=1]
    4646 %tmp667 = sitofp i32 %tmp666 to double ; [#uses=2]
    4747 call void @levrun_linfo_inter( i32 %tmp576, i32 0, i32* null, i32* null )
    48 %tmp671 = mul double %tmp667, %tmp667 ; [#uses=1]
    49 %tmp675 = add double %tmp671, 0.000000e+00 ; [#uses=1]
    48 %tmp671 = fmul double %tmp667, %tmp667 ; [#uses=1]
    49 %tmp675 = fadd double %tmp671, 0.000000e+00 ; [#uses=1]
    5050 %tmp678 = fcmp oeq double %tmp632, %tmp675 ; [#uses=1]
    5151 br i1 %tmp678, label %cond_true679, label %cond_false693
    5252
    1010 br label %bb52
    1111
    1212 bb32: ; preds = %bb52
    13 %0 = add double 0.000000e+00, 0.000000e+00 ; [#uses=1]
    13 %0 = fadd double 0.000000e+00, 0.000000e+00 ; [#uses=1]
    1414 %1 = add i32 %j.1, 1 ; [#uses=1]
    1515 br label %bb52
    1616
    2828
    2929 bb55: ; preds = %bb53
    3030 %4 = load double* @a, align 4 ; [#uses=10]
    31 %5 = add double %4, 0.000000e+00 ; [#uses=16]
    31 %5 = fadd double %4, 0.000000e+00 ; [#uses=16]
    3232 %6 = fcmp ogt double %k.4, 0.000000e+00 ; [#uses=1]
    33 %.pn404 = mul double %4, %4 ; [#uses=4]
    34 %.pn402 = mul double %5, %5 ; [#uses=5]
    33 %.pn404 = fmul double %4, %4 ; [#uses=4]
    34 %.pn402 = fmul double %5, %5 ; [#uses=5]
    3535 %.pn165.in = load double* @N ; [#uses=5]
    36 %.pn198 = mul double 0.000000e+00, %5 ; [#uses=1]
    37 %.pn185 = sub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
    38 %.pn147 = sub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
    36 %.pn198 = fmul double 0.000000e+00, %5 ; [#uses=1]
    37 %.pn185 = fsub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
    38 %.pn147 = fsub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
    3939 %.pn141 = fdiv double 0.000000e+00, %4 ; [#uses=1]
    4040 %.pn142 = fdiv double 0.000000e+00, %5 ; [#uses=1]
    4141 %.pn136 = fdiv double 0.000000e+00, 0.000000e+00 ; [#uses=1]
    4646 %.pn117 = fdiv double 0.000000e+00, %4 ; [#uses=1]
    4747 %.pn118 = fdiv double %.pn185, %5 ; [#uses=1]
    4848 %.pn88 = fdiv double %.pn147, %5 ; [#uses=1]
    49 %.pn81 = sub double %.pn141, %.pn142 ; [#uses=1]
    50 %.pn77 = sub double 0.000000e+00, %.pn136 ; [#uses=1]
    51 %.pn75 = sub double 0.000000e+00, %.pn132 ; [#uses=1]
    52 %.pn69 = sub double %.pn123, %.pn124 ; [#uses=1]
    53 %.pn67 = sub double 0.000000e+00, %.pn120 ; [#uses=1]
    54 %.pn56 = sub double %.pn117, %.pn118 ; [#uses=1]
    55 %.pn42 = sub double 0.000000e+00, %.pn88 ; [#uses=1]
    56 %.pn60 = mul double %.pn81, 0.000000e+00 ; [#uses=1]
    57 %.pn57 = add double %.pn77, 0.000000e+00 ; [#uses=1]
    58 %.pn58 = mul double %.pn75, %.pn165.in ; [#uses=1]
    59 %.pn32 = add double %.pn69, 0.000000e+00 ; [#uses=1]
    60 %.pn33 = mul double %.pn67, %.pn165.in ; [#uses=1]
    61 %.pn17 = sub double 0.000000e+00, %.pn60 ; [#uses=1]
    62 %.pn9 = add double %.pn57, %.pn58 ; [#uses=1]
    63 %.pn30 = mul double 0.000000e+00, %.pn56 ; [#uses=1]
    64 %.pn24 = mul double 0.000000e+00, %.pn42 ; [#uses=1]
    65 %.pn1 = add double %.pn32, %.pn33 ; [#uses=1]
    66 %.pn28 = sub double %.pn30, 0.000000e+00 ; [#uses=1]
    67 %.pn26 = add double %.pn28, 0.000000e+00 ; [#uses=1]
    68 %.pn22 = sub double %.pn26, 0.000000e+00 ; [#uses=1]
    69 %.pn20 = sub double %.pn24, 0.000000e+00 ; [#uses=1]
    70 %.pn18 = add double %.pn22, 0.000000e+00 ; [#uses=1]
    71 %.pn16 = add double %.pn20, 0.000000e+00 ; [#uses=1]
    72 %.pn14 = sub double %.pn18, 0.000000e+00 ; [#uses=1]
    73 %.pn12 = sub double %.pn16, %.pn17 ; [#uses=1]
    74 %.pn10 = add double %.pn14, 0.000000e+00 ; [#uses=1]
    75 %.pn8 = add double %.pn12, 0.000000e+00 ; [#uses=1]
    76 %.pn6 = sub double %.pn10, 0.000000e+00 ; [#uses=1]
    77 %.pn4 = sub double %.pn8, %.pn9 ; [#uses=1]
    78 %.pn2 = add double %.pn6, 0.000000e+00 ; [#uses=1]
    79 %.pn = add double %.pn4, 0.000000e+00 ; [#uses=1]
    80 %N1.0 = sub double %.pn2, 0.000000e+00 ; [#uses=2]
    81 %D1.0 = sub double %.pn, %.pn1 ; [#uses=2]
    49 %.pn81 = fsub double %.pn141, %.pn142 ; [#uses=1]
    50 %.pn77 = fsub double 0.000000e+00, %.pn136 ; [#uses=1]
    51 %.pn75 = fsub double 0.000000e+00, %.pn132 ; [#uses=1]
    52 %.pn69 = fsub double %.pn123, %.pn124 ; [#uses=1]
    53 %.pn67 = fsub double 0.000000e+00, %.pn120 ; [#uses=1]
    54 %.pn56 = fsub double %.pn117, %.pn118 ; [#uses=1]
    55 %.pn42 = fsub double 0.000000e+00, %.pn88 ; [#uses=1]
    56 %.pn60 = fmul double %.pn81, 0.000000e+00 ; [#uses=1]
    57 %.pn57 = fadd double %.pn77, 0.000000e+00 ; [#uses=1]
    58 %.pn58 = fmul double %.pn75, %.pn165.in ; [#uses=1]
    59 %.pn32 = fadd double %.pn69, 0.000000e+00 ; [#uses=1]
    60 %.pn33 = fmul double %.pn67, %.pn165.in ; [#uses=1]
    61 %.pn17 = fsub double 0.000000e+00, %.pn60 ; [#uses=1]
    62 %.pn9 = fadd double %.pn57, %.pn58 ; [#uses=1]
    63 %.pn30 = fmul double 0.000000e+00, %.pn56 ; [#uses=1]
    64 %.pn24 = fmul double 0.000000e+00, %.pn42 ; [#uses=1]
    65 %.pn1 = fadd double %.pn32, %.pn33 ; [#uses=1]
    66 %.pn28 = fsub double %.pn30, 0.000000e+00 ; [#uses=1]
    67 %.pn26 = fadd double %.pn28, 0.000000e+00 ; [#uses=1]
    68 %.pn22 = fsub double %.pn26, 0.000000e+00 ; [#uses=1]
    69 %.pn20 = fsub double %.pn24, 0.000000e+00 ; [#uses=1]
    70 %.pn18 = fadd double %.pn22, 0.000000e+00 ; [#uses=1]
    71 %.pn16 = fadd double %.pn20, 0.000000e+00 ; [#uses=1]
    72 %.pn14 = fsub double %.pn18, 0.000000e+00 ; [#uses=1]
    73 %.pn12 = fsub double %.pn16, %.pn17 ; [#uses=1]
    74 %.pn10 = fadd double %.pn14, 0.000000e+00 ; [#uses=1]
    75 %.pn8 = fadd double %.pn12, 0.000000e+00 ; [#uses=1]
    76 %.pn6 = fsub double %.pn10, 0.000000e+00 ; [#uses=1]
    77 %.pn4 = fsub double %.pn8, %.pn9 ; [#uses=1]
    78 %.pn2 = fadd double %.pn6, 0.000000e+00 ; [#uses=1]
    79 %.pn = fadd double %.pn4, 0.000000e+00 ; [#uses=1]
    80 %N1.0 = fsub double %.pn2, 0.000000e+00 ; [#uses=2]
    81 %D1.0 = fsub double %.pn, %.pn1 ; [#uses=2]
    8282 br i1 %6, label %bb62, label %bb64
    8383
    8484 bb62: ; preds = %bb55
    85 %7 = mul double 0.000000e+00, %4 ; [#uses=1]
    86 %8 = sub double -0.000000e+00, %7 ; [#uses=3]
    87 %9 = mul double 0.000000e+00, %5 ; [#uses=1]
    88 %10 = sub double -0.000000e+00, %9 ; [#uses=3]
    89 %11 = mul double %.pn404, %4 ; [#uses=5]
    90 %12 = mul double %.pn402, %5 ; [#uses=5]
    91 %13 = mul double 0.000000e+00, -2.000000e+00 ; [#uses=1]
    85 %7 = fmul double 0.000000e+00, %4 ; [#uses=1]
    86 %8 = fsub double -0.000000e+00, %7 ; [#uses=3]
    87 %9 = fmul double 0.000000e+00, %5 ; [#uses=1]
    88 %10 = fsub double -0.000000e+00, %9 ; [#uses=3]
    89 %11 = fmul double %.pn404, %4 ; [#uses=5]
    90 %12 = fmul double %.pn402, %5 ; [#uses=5]
    91 %13 = fmul double 0.000000e+00, -2.000000e+00 ; [#uses=1]
    9292 %14 = fdiv double 0.000000e+00, %.pn402 ; [#uses=1]
    93 %15 = sub double 0.000000e+00, %14 ; [#uses=1]
    94 %16 = mul double 0.000000e+00, %15 ; [#uses=1]
    95 %17 = add double %13, %16 ; [#uses=1]
    96 %18 = mul double %.pn165.in, -2.000000e+00 ; [#uses=5]
    97 %19 = mul double %18, 0.000000e+00 ; [#uses=1]
    98 %20 = add double %17, %19 ; [#uses=1]
    99 %21 = mul double 0.000000e+00, %20 ; [#uses=1]
    100 %22 = add double 0.000000e+00, %21 ; [#uses=1]
    93 %15 = fsub double 0.000000e+00, %14 ; [#uses=1]
    94 %16 = fmul double 0.000000e+00, %15 ; [#uses=1]
    95 %17 = fadd double %13, %16 ; [#uses=1]
    96 %18 = fmul double %.pn165.in, -2.000000e+00 ; [#uses=5]
    97 %19 = fmul double %18, 0.000000e+00 ; [#uses=1]
    98 %20 = fadd double %17, %19 ; [#uses=1]
    99 %21 = fmul double 0.000000e+00, %20 ; [#uses=1]
    100 %22 = fadd double 0.000000e+00, %21 ; [#uses=1]
    101101 %23 = fdiv double 0.000000e+00, %12 ; [#uses=1]
    102 %24 = sub double 0.000000e+00, %23 ; [#uses=0]
    103 %25 = mul double %18, 0.000000e+00 ; [#uses=1]
    104 %26 = add double 0.000000e+00, %25 ; [#uses=1]
    105 %27 = mul double 0.000000e+00, %26 ; [#uses=1]
    106 %28 = sub double %22, %27 ; [#uses=1]
    107 %29 = mul double %11, %4 ; [#uses=1]
    108 %30 = mul double %12, %5 ; [#uses=3]
    109 %31 = mul double %.pn165.in, -4.000000e+00 ; [#uses=1]
    110 %32 = mul double %.pn165.in, 0x3FF5555555555555 ; [#uses=1]
    111 %33 = mul double %32, 0.000000e+00 ; [#uses=2]
    112 %34 = add double %28, 0.000000e+00 ; [#uses=1]
    113 %35 = sub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
    102 %24 = fsub double 0.000000e+00, %23 ; [#uses=0]
    103 %25 = fmul double %18, 0.000000e+00 ; [#uses=1]
    104 %26 = fadd double 0.000000e+00, %25 ; [#uses=1]
    105 %27 = fmul double 0.000000e+00, %26 ; [#uses=1]
    106 %28 = fsub double %22, %27 ; [#uses=1]
    107 %29 = fmul double %11, %4 ; [#uses=1]
    108 %30 = fmul double %12, %5 ; [#uses=3]
    109 %31 = fmul double %.pn165.in, -4.000000e+00 ; [#uses=1]
    110 %32 = fmul double %.pn165.in, 0x3FF5555555555555 ; [#uses=1]
    111 %33 = fmul double %32, 0.000000e+00 ; [#uses=2]
    112 %34 = fadd double %28, 0.000000e+00 ; [#uses=1]
    113 %35 = fsub double -0.000000e+00, 0.000000e+00 ; [#uses=1]
    114114 %36 = fdiv double %35, %11 ; [#uses=1]
    115115 %37 = fdiv double 0.000000e+00, %12 ; [#uses=1]
    116 %38 = sub double %36, %37 ; [#uses=1]
    117 %39 = mul double 0.000000e+00, %38 ; [#uses=1]
    118 %40 = add double 0.000000e+00, %39 ; [#uses=1]
    119 %41 = add double %40, 0.000000e+00 ; [#uses=1]
    120 %42 = add double %41, 0.000000e+00 ; [#uses=1]
    121 %43 = mul double %42, 0.000000e+00 ; [#uses=1]
    122 %44 = sub double %34, %43 ; [#uses=1]
    116 %38 = fsub double %36, %37 ; [#uses=1]
    117 %39 = fmul double 0.000000e+00, %38 ; [#uses=1]
    118 %40 = fadd double 0.000000e+00, %39 ; [#uses=1]
    119 %41 = fadd double %40, 0.000000e+00 ; [#uses=1]
    120 %42 = fadd double %41, 0.000000e+00 ; [#uses=1]
    121 %43 = fmul double %42, 0.000000e+00 ; [#uses=1]
    122 %44 = fsub double %34, %43 ; [#uses=1]
    123123 %45 = tail call double @llvm.exp.f64(double %8) nounwind ; [#uses=1]
    124 %46 = sub double -0.000000e+00, %45 ; [#uses=2]
    124 %46 = fsub double -0.000000e+00, %45 ; [#uses=2]
    125125 %47 = fdiv double %46, 0.000000e+00 ; [#uses=1]
    126 %48 = mul double %30, %5 ; [#uses=1]
    126 %48 = fmul double %30, %5 ; [#uses=1]
    127127 %49 = fdiv double 0.000000e+00, %48 ; [#uses=1]
    128 %50 = sub double %47, %49 ; [#uses=1]
    129 %51 = mul double %50, -4.000000e+00 ; [#uses=1]
    130 %52 = add double %51, 0.000000e+00 ; [#uses=1]
    128 %50 = fsub double %47, %49 ; [#uses=1]
    129 %51 = fmul double %50, -4.000000e+00 ; [#uses=1]
    130 %52 = fadd double %51, 0.000000e+00 ; [#uses=1]
    131131 %53 = fdiv double %46, %11 ; [#uses=1]
    132 %54 = sub double %53, 0.000000e+00 ; [#uses=1]
    133 %55 = mul double %31, %54 ; [#uses=1]
    134 %56 = add double %52, %55 ; [#uses=1]
    135 %57 = add double %56, 0.000000e+00 ; [#uses=1]
    136 %58 = add double %44, %57 ; [#uses=1]
    137 %59 = sub double %58, 0.000000e+00 ; [#uses=1]
    132 %54 = fsub double %53, 0.000000e+00 ; [#uses=1]
    133 %55 = fmul double %31, %54 ; [#uses=1]
    134 %56 = fadd double %52, %55 ; [#uses=1]
    135 %57 = fadd double %56, 0.000000e+00 ; [#uses=1]
    136 %58 = fadd double %44, %57 ; [#uses=1]
    137 %59 = fsub double %58, 0.000000e+00 ; [#uses=1]
    138138 %60 = tail call double @llvm.exp.f64(double 0.000000e+00) nounwind ; [#uses=1]
    139 %61 = sub double -0.000000e+00, %60 ; [#uses=1]
    139 %61 = fsub double -0.000000e+00, %60 ; [#uses=1]
    140140 %62 = fdiv double 0.000000e+00, -6.000000e+00 ; [#uses=1]
    141141 %63 = fdiv double %61, %5 ; [#uses=1]
    142 %64 = sub double 0.000000e+00, %63 ; [#uses=1]
    143 %65 = mul double %62, %64 ; [#uses=1]
    144 %66 = sub double 0.000000e+00, %65 ; [#uses=1]
    145 %67 = sub double -0.000000e+00, 0.000000e+00 ; [#uses=2]
    142 %64 = fsub double 0.000000e+00, %63 ; [#uses=1]
    143 %65 = fmul double %62, %64 ; [#uses=1]
    144 %66 = fsub double 0.000000e+00, %65 ; [#uses=1]
    145 %67 = fsub double -0.000000e+00, 0.000000e+00 ; [#uses=2]
    146146 %68 = tail call double @llvm.exp.f64(double %10) nounwind ; [#uses=1]
    147 %69 = sub double -0.000000e+00, %68 ; [#uses=2]
    147 %69 = fsub double -0.000000e+00, %68 ; [#uses=2]
    148148 %70 = fdiv double %67, %.pn404 ; [#uses=1]
    149149 %71 = fdiv double %69, %.pn402 ; [#uses=1]
    150 %72 = sub double %70, %71 ; [#uses=1]
    151 %73 = mul double %72, -5.000000e-01 ; [#uses=1]
    150 %72 = fsub double %70, %71 ; [#uses=1]
    151 %73 = fmul double %72, -5.000000e-01 ; [#uses=1]
    152152 %74 = fdiv double %67, %4 ; [#uses=1]
    153153 %75 = fdiv double %69, %5 ; [#uses=1]
    154 %76 = sub double %74, %75 ; [#uses=1]
    155 %77 = mul double %76, 0.000000e+00 ; [#uses=1]
    156 %78 = add double %73, %77 ; [#uses=1]
    157 %79 = mul double 0.000000e+00, %78 ; [#uses=1]
    158 %80 = add double %66, %79 ; [#uses=1]
    154 %76 = fsub double %74, %75 ; [#uses=1]
    155 %77 = fmul double %76, 0.000000e+00 ; [#uses=1]
    156 %78 = fadd double %73, %77 ; [#uses=1]
    157 %79 = fmul double 0.000000e+00, %78 ; [#uses=1]
    158 %80 = fadd double %66, %79 ; [#uses=1]
    159159 %81 = fdiv double 0.000000e+00, %.pn404 ; [#uses=1]
    160160 %82 = fdiv double 0.000000e+00, %.pn402 ; [#uses=1]
    161 %83 = sub double %81, %82 ; [#uses=1]
    162 %84 = mul double %83, -5.000000e-01 ; [#uses=1]
    161 %83 = fsub double %81, %82 ; [#uses=1]
    162 %84 = fmul double %83, -5.000000e-01 ; [#uses=1]
    163163 %85 = fdiv double 0.000000e+00, %4 ; [#uses=1]
    164164 %86 = fdiv double 0.000000e+00, %5 ; [#uses=1]
    165 %87 = sub double %85, %86 ; [#uses=1]
    166 %88 = mul double %87, 0.000000e+00 ; [#uses=1]
    167 %89 = add double %84, %88 ; [#uses=1]
    168 %90 = mul double 0.000000e+00, %89 ; [#uses=1]
    169 %91 = sub double %80, %90 ; [#uses=1]
    165 %87 = fsub double %85, %86 ; [#uses=1]
    166 %88 = fmul double %87, 0.000000e+00 ; [#uses=1]
    167 %89 = fadd double %84, %88 ; [#uses=1]
    168 %90 = fmul double 0.000000e+00, %89 ; [#uses=1]
    169 %91 = fsub double %80, %90 ; [#uses=1]
    170170 %92 = tail call double @llvm.exp.f64(double %8) nounwind ; [#uses=1]
    171 %93 = sub double -0.000000e+00, %92 ; [#uses=1]
    171 %93 = fsub double -0.000000e+00, %92 ; [#uses=1]
    172172 %94 = tail call double @llvm.exp.f64(double %10) nounwind ; [#uses=1]
    173 %95 = sub double -0.000000e+00, %94 ; [#uses=3]
    173 %95 = fsub double -0.000000e+00, %94 ; [#uses=3]
    174174 %96 = fdiv double %95, %.pn402 ; [#uses=1]
    175 %97 = sub double 0.000000e+00, %96 ; [#uses=1]
    176 %98 = mul double 0.000000e+00, %97 ; [#uses=1]
    175 %97 = fsub double 0.000000e+00, %96 ; [#uses=1]
    176 %98 = fmul double 0.000000e+00, %97 ; [#uses=1]
    177177 %99 = fdiv double %93, %11 ; [#uses=1]
    178178 %100 = fdiv double %95, %12 ; [#uses=1]
    179 %101 = sub double %99, %100 ; [#uses=1]
    180 %102 = sub double %98, %101 ; [#uses=1]
    179 %101 = fsub double %99, %100 ; [#uses=1]
    180 %102 = fsub double %98, %101 ; [#uses=1]
    181181 %103 = fdiv double %95, %5 ; [#uses=1]
    182 %104 = sub double 0.000000e+00, %103 ; [#uses=1]
    183 %105 = mul double %18, %104 ; [#uses=1]
    184 %106 = add double %102, %105 ; [#uses=1]
    185 %107 = mul double %106, %k.4 ; [#uses=1]
    186 %108 = add double %91, %107 ; [#uses=1]
    187 %109 = sub double %108, 0.000000e+00 ; [#uses=1]
    182 %104 = fsub double 0.000000e+00, %103 ; [#uses=1]
    183 %105 = fmul double %18, %104 ; [#uses=1]
    184 %106 = fadd double %102, %105 ; [#uses=1]
    185 %107 = fmul double %106, %k.4 ; [#uses=1]
    186 %108 = fadd double %91, %107 ; [#uses=1]
    187 %109 = fsub double %108, 0.000000e+00 ; [#uses=1]
    188188 %110 = tail call double @llvm.exp.f64(double %8) nounwind ; [#uses=1]
    189 %111 = sub double -0.000000e+00, %110 ; [#uses=2]
    189 %111 = fsub double -0.000000e+00, %110 ; [#uses=2]
    190190 %112 = tail call double @llvm.exp.f64(double %10) nounwind ; [#uses=1]
    191 %113 = sub double -0.000000e+00, %112 ; [#uses=2]
    191 %113 = fsub double -0.000000e+00, %112 ; [#uses=2]
    192192 %114 = fdiv double %111, %11 ; [#uses=1]
    193193 %115 = fdiv double %113, %12 ; [#uses=1]
    194 %116 = sub double %114, %115 ; [#uses=1]
    195 %117 = mul double 0.000000e+00, %116 ; [#uses=1]
    194 %116 = fsub double %114, %115 ; [#uses=1]
    195 %117 = fmul double 0.000000e+00, %116 ; [#uses=1]
    196196 %118 = fdiv double %111, %29 ; [#uses=1]
    197197 %119 = fdiv double %113, %30 ; [#uses=1]
    198 %120 = sub double %118, %119 ; [#uses=1]
    199 %121 = sub double %117, %120 ; [#uses=1]
    200 %122 = mul double %18, 0.000000e+00 ; [#uses=1]
    201 %123 = add double %121, %122 ; [#uses=1]
    202 %124 = mul double %33, 0.000000e+00 ; [#uses=1]
    203 %125 = add double %123, %124 ; [#uses=1]
    204 %126 = add double %109, %125 ; [#uses=1]
    198 %120 = fsub double %118, %119 ; [#uses=1]
    199 %121 = fsub double %117, %120 ; [#uses=1]
    200 %122 = fmul double %18, 0.000000e+00 ; [#uses=1]
    201 %123 = fadd double %121, %122 ; [#uses=1]
    202 %124 = fmul double %33, 0.000000e+00 ; [#uses=1]
    203 %125 = fadd double %123, %124 ; [#uses=1]
    204 %126 = fadd double %109, %125 ; [#uses=1]
    205205 %127 = tail call double @llvm.exp.f64(double 0.000000e+00) nounwind ; [#uses=1]
    206 %128 = sub double -0.000000e+00, %127 ; [#uses=2]
    206 %128 = fsub double -0.000000e+00, %127 ; [#uses=2]
    207207 %129 = fdiv double %128, %30 ; [#uses=1]
    208 %130 = sub double 0.000000e+00, %129 ; [#uses=1]
    209 %131 = sub double 0.000000e+00, %130 ; [#uses=1]
    208 %130 = fsub double 0.000000e+00, %129 ; [#uses=1]
    209 %131 = fsub double 0.000000e+00, %130 ; [#uses=1]
    210210 %132 = fdiv double 0.000000e+00, %.pn404 ; [#uses=1]
    211 %133 = sub double %132, 0.000000e+00 ; [#uses=1]
    212 %134 = mul double %18, %133 ; [#uses=1]
    213 %135 = add double %131, %134 ; [#uses=1]
    211 %133 = fsub double %132, 0.000000e+00 ; [#uses=1]
    212 %134 = fmul double %18, %133 ; [#uses=1]
    213 %135 = fadd double %131, %134 ; [#uses=1]
    214214 %136 = fdiv double %128, %5 ; [#uses=1]
    215 %137 = sub double 0.000000e+00, %136 ; [#uses=1]
    216 %138 = mul double %33, %137 ; [#uses=1]
    217 %139 = add double %135, %138 ; [#uses=1]
    218 %140 = sub double %126, %139 ; [#uses=1]
    219 %141 = add double %N1.0, %59 ; [#uses=1]
    220 %142 = add double %D1.0, %140 ; [#uses=1]
    215 %137 = fsub double 0.000000e+00, %136 ; [#uses=1]
    216 %138 = fmul double %33, %137 ; [#uses=1]
    217 %139 = fadd double %135, %138 ; [#uses=1]
    218 %140 = fsub double %126, %139 ; [#uses=1]
    219 %141 = fadd double %N1.0, %59 ; [#uses=1]
    220 %142 = fadd double %D1.0, %140 ; [#uses=1]
    221221 br label %bb64
    222222
    223223 bb64: ; preds = %bb62, %bb55
    2525
    2626 bb3: ; preds = %entry
    2727 %2 = fdiv double 1.000000e+00, 0.000000e+00 ; [#uses=1]
    28 %3 = mul double 0.000000e+00, %2 ; [#uses=2]
    28 %3 = fmul double 0.000000e+00, %2 ; [#uses=2]
    2929 %4 = call double @llvm.sqrt.f64(double 0.000000e+00) nounwind ; [#uses=1]
    3030 %5 = fdiv double 1.000000e+00, %4 ; [#uses=2]
    31 %6 = mul double %3, %5 ; [#uses=2]
    32 %7 = mul double 0.000000e+00, %5 ; [#uses=2]
    33 %8 = mul double %3, %7 ; [#uses=1]
    34 %9 = sub double %8, 0.000000e+00 ; [#uses=1]
    35 %10 = mul double 0.000000e+00, %6 ; [#uses=1]
    36 %11 = sub double 0.000000e+00, %10 ; [#uses=1]
    37 %12 = sub double -0.000000e+00, %11 ; [#uses=1]
    38 %13 = mul double %0, %0 ; [#uses=2]
    39 %14 = sub double %13, 0.000000e+00 ; [#uses=1]
    31 %6 = fmul double %3, %5 ; [#uses=2]
    32 %7 = fmul double 0.000000e+00, %5 ; [#uses=2]
    33 %8 = fmul double %3, %7 ; [#uses=1]
    34 %9 = fsub double %8, 0.000000e+00 ; [#uses=1]
    35 %10 = fmul double 0.000000e+00, %6 ; [#uses=1]
    36 %11 = fsub double 0.000000e+00, %10 ; [#uses=1]
    37 %12 = fsub double -0.000000e+00, %11 ; [#uses=1]
    38 %13 = fmul double %0, %0 ; [#uses=2]
    39 %14 = fsub double %13, 0.000000e+00 ; [#uses=1]
    4040 %15 = call double @llvm.sqrt.f64(double %14) ; [#uses=1]
    41 %16 = mul double 0.000000e+00, %15 ; [#uses=1]
    41 %16 = fmul double 0.000000e+00, %15 ; [#uses=1]
    4242 %17 = fdiv double %16, %0 ; [#uses=1]
    43 %18 = add double 0.000000e+00, %17 ; [#uses=1]
    43 %18 = fadd double 0.000000e+00, %17 ; [#uses=1]
    4444 %19 = call double @acos(double %18) nounwind readonly ; [#uses=1]
    4545 %20 = load double* null, align 4 ; [#uses=1]
    46 %21 = mul double %20, 0x401921FB54442D18 ; [#uses=1]
    46 %21 = fmul double %20, 0x401921FB54442D18 ; [#uses=1]
    4747 %22 = call double @sin(double %19) nounwind readonly ; [#uses=2]
    48 %23 = mul double %22, 0.000000e+00 ; [#uses=2]
    49 %24 = mul double %6, %23 ; [#uses=1]
    50 %25 = mul double %7, %23 ; [#uses=1]
    48 %23 = fmul double %22, 0.000000e+00 ; [#uses=2]
    49 %24 = fmul double %6, %23 ; [#uses=1]
    50 %25 = fmul double %7, %23 ; [#uses=1]
    5151 %26 = call double @sin(double %21) nounwind readonly ; [#uses=1]
    52 %27 = mul double %22, %26 ; [#uses=2]
    53 %28 = mul double %9, %27 ; [#uses=1]
    54 %29 = mul double %27, %12 ; [#uses=1]
    55 %30 = add double %24, %28 ; [#uses=1]
    56 %31 = add double 0.000000e+00, %29 ; [#uses=1]
    57 %32 = add double %25, 0.000000e+00 ; [#uses=1]
    58 %33 = add double %30, 0.000000e+00 ; [#uses=1]
    59 %34 = add double %31, 0.000000e+00 ; [#uses=1]
    60 %35 = add double %32, 0.000000e+00 ; [#uses=1]
    52 %27 = fmul double %22, %26 ; [#uses=2]
    53 %28 = fmul double %9, %27 ; [#uses=1]
    54 %29 = fmul double %27, %12 ; [#uses=1]
    55 %30 = fadd double %24, %28 ; [#uses=1]
    56 %31 = fadd double 0.000000e+00, %29 ; [#uses=1]
    57 %32 = fadd double %25, 0.000000e+00 ; [#uses=1]
    58 %33 = fadd double %30, 0.000000e+00 ; [#uses=1]
    59 %34 = fadd double %31, 0.000000e+00 ; [#uses=1]
    60 %35 = fadd double %32, 0.000000e+00 ; [#uses=1]
    6161 %36 = bitcast %struct.ggPoint3* %x to i8* ; [#uses=1]
    6262 call void @llvm.memcpy.i32(i8* null, i8* %36, i32 24, i32 4) nounwind
    6363 store double %33, double* null, align 8
    6767 unreachable
    6868
    6969 _Z20ggRaySphereIntersectRK6ggRay3RK8ggSphereddRd.exit: ; preds = %bb3
    70 %37 = sub double %13, 0.000000e+00 ; [#uses=0]
    71 %38 = sub double -0.000000e+00, %34 ; [#uses=0]
    72 %39 = sub double -0.000000e+00, %35 ; [#uses=0]
    70 %37 = fsub double %13, 0.000000e+00 ; [#uses=0]
    71 %38 = fsub double -0.000000e+00, %34 ; [#uses=0]
    72 %39 = fsub double -0.000000e+00, %35 ; [#uses=0]
    7373 ret i32 1
    7474
    7575 bb7: ; preds = %entry
    33 entry:
    44 %input2 = load <4 x float>* null, align 16 ; <<4 x float>> [#uses=2]
    55 %shuffle7 = shufflevector <4 x float> %input2, <4 x float> , <4 x i32> ; <<4 x float>> [#uses=1]
    6 %mul1 = mul <4 x float> %shuffle7, zeroinitializer ; <<4 x float>> [#uses=1]
    7 %add2 = add <4 x float> %mul1, %input2 ; <<4 x float>> [#uses=1]
    6 %mul1 = fmul <4 x float> %shuffle7, zeroinitializer ; <<4 x float>> [#uses=1]
    7 %add2 = fadd <4 x float> %mul1, %input2 ; <<4 x float>> [#uses=1]
    88 store <4 x float> %add2, <4 x float>* null, align 16
    99 ret void
    1010 }
    1515 br i1 false, label %bb502.loopexit.i, label %bb28.i
    1616
    1717 bb.nph53.i: ; preds = %bb502.loopexit.i
    18 %tmp354.i = sub double -0.000000e+00, %tmp10.i4 ; [#uses=0]
    18 %tmp354.i = fsub double -0.000000e+00, %tmp10.i4 ; [#uses=0]
    1919 br label %bb244.i
    2020
    2121 bb244.i: ; preds = %bb244.i, %bb.nph53.i
    1212 %u.in.mask = and i64 %x14, -4294967296 ; [#uses=1]
    1313 %.ins = or i64 0, %u.in.mask ; [#uses=1]
    1414 %0 = bitcast i64 %.ins to double ; [#uses=1]
    15 %1 = sub double %x, %0 ; [#uses=1]
    15 %1 = fsub double %x, %0 ; [#uses=1]
    1616 %2 = fptosi double %1 to i32 ; [#uses=1]
    1717 %3 = add i32 %2, 0 ; [#uses=1]
    1818 %4 = zext i32 %3 to i64 ; [#uses=1]
    33
    44 define double @t1(double %a, double %b) {
    55 entry:
    6 %tmp2 = sub double -0.000000e+00, %a ; [#uses=1]
    7 %tmp4 = mul double %tmp2, %b ; [#uses=1]
    6 %tmp2 = fsub double -0.000000e+00, %a ; [#uses=1]
    7 %tmp4 = fmul double %tmp2, %b ; [#uses=1]
    88 ret double %tmp4
    99 }
    1010
    99
    1010 define float @f1(float %a, float %b) {
    1111 entry:
    12 %tmp = add float %a, %b ; [#uses=1]
    12 %tmp = fadd float %a, %b ; [#uses=1]
    1313 ret float %tmp
    1414 }
    1515
    1616 define double @f2(double %a, double %b) {
    1717 entry:
    18 %tmp = add double %a, %b ; [#uses=1]
    18 %tmp = fadd double %a, %b ; [#uses=1]
    1919 ret double %tmp
    2020 }
    2121
    2222 define float @f3(float %a, float %b) {
    2323 entry:
    24 %tmp = mul float %a, %b ; [#uses=1]
    24 %tmp = fmul float %a, %b ; [#uses=1]
    2525 ret float %tmp
    2626 }
    2727
    2828 define double @f4(double %a, double %b) {
    2929 entry:
    30 %tmp = mul double %a, %b ; [#uses=1]
    30 %tmp = fmul double %a, %b ; [#uses=1]
    3131 ret double %tmp
    3232 }
    3333
    3434 define float @f5(float %a, float %b) {
    3535 entry:
    36 %tmp = sub float %a, %b ; [#uses=1]
    36 %tmp = fsub float %a, %b ; [#uses=1]
    3737 ret float %tmp
    3838 }
    3939
    4040 define double @f6(double %a, double %b) {
    4141 entry:
    42 %tmp = sub double %a, %b ; [#uses=1]
    42 %tmp = fsub double %a, %b ; [#uses=1]
    4343 ret double %tmp
    4444 }
    4545
    4646 define float @f7(float %a) {
    4747 entry:
    48 %tmp1 = sub float -0.000000e+00, %a ; [#uses=1]
    48 %tmp1 = fsub float -0.000000e+00, %a ; [#uses=1]
    4949 ret float %tmp1
    5050 }
    5151
    5252 define double @f8(double %a) {
    5353 entry:
    54 %tmp1 = sub double -0.000000e+00, %a ; [#uses=1]
    54 %tmp1 = fsub double -0.000000e+00, %a ; [#uses=1]
    5555 ret double %tmp1
    5656 }
    5757
    1010
    1111 define float @f2(float* %v, float %u) {
    1212 %tmp = load float* %v ; [#uses=1]
    13 %tmp1 = add float %tmp, %u ; [#uses=1]
    13 %tmp1 = fadd float %tmp, %u ; [#uses=1]
    1414 ret float %tmp1
    1515 }
    1616
    1717 define void @f3(float %a, float %b, float* %v) {
    18 %tmp = add float %a, %b ; [#uses=1]
    18 %tmp = fadd float %a, %b ; [#uses=1]
    1919 store float %tmp, float* %v
    2020 ret void
    2121 }
    22 define void @foo(<8 x float>* %f, <8 x float>* %g, <4 x i64>* %y)
    33 {
    44 %h = load <8 x float>* %f
    5 %i = mul <8 x float> %h,
    5 %i = fmul <8 x float> %h,
    66 %m = bitcast <8 x float> %i to <4 x i64>
    77 %z = load <4 x i64>* %y
    88 %n = mul <4 x i64> %z, %m
    3838
    3939 define void @test_add(float* %P, double* %D) {
    4040 %a = load float* %P ; [#uses=2]
    41 %b = add float %a, %a ; [#uses=1]
    41 %b = fadd float %a, %a ; [#uses=1]
    4242 store float %b, float* %P
    4343 %A = load double* %D ; [#uses=2]
    44 %B = add double %A, %A ; [#uses=1]
    44 %B = fadd double %A, %A ; [#uses=1]
    4545 store double %B, double* %D
    4646 ret void
    4747 }
    6060 %a1 = load float* %P1 ; [#uses=1]
    6161 %a2 = load float* %P2 ; [#uses=1]
    6262 %a3 = load float* %P3 ; [#uses=1]
    63 %X = mul float %a1, %a2 ; [#uses=1]
    64 %Y = sub float %X, %a3 ; [#uses=1]
    63 %X = fmul float %a1, %a2 ; [#uses=1]
    64 %Y = fsub float %X, %a3 ; [#uses=1]
    6565 store float %Y, float* %P1
    6666 ret void
    6767 }
    2222
    2323 define double @test5(double %D) {
    2424 %X = bitcast double %D to double ; [#uses=1]
    25 %Y = add double %X, 2.000000e+00 ; [#uses=1]
    25 %Y = fadd double %X, 2.000000e+00 ; [#uses=1]
    2626 %Z = bitcast double %Y to i64 ; [#uses=1]
    2727 %res = bitcast i64 %Z to double ; [#uses=1]
    2828 ret double %res
    3030
    3131 define float @test6(float %F) {
    3232 %X = bitcast float %F to float ; [#uses=1]
    33 %Y = add float %X, 2.000000e+00 ; [#uses=1]
    33 %Y = fadd float %X, 2.000000e+00 ; [#uses=1]
    3434 %Z = bitcast float %Y to i32 ; [#uses=1]
    3535 %res = bitcast i32 %Z to float ; [#uses=1]
    3636 ret float %res
    1919 br label %bb4
    2020
    2121 bb4: ; preds = %bb5.split, %bb4, %entry
    22 %0 = fcmp ogt ppc_fp128 0xM00000000000000000000000000000000, select (i1 fcmp olt (ppc_fp128 fpext (double 0x3C447AE147AE147B to ppc_fp128), ppc_fp128 mul (ppc_fp128 0xM00000000000000010000000000000000, ppc_fp128 0xM40140000000000000000000000000000)), ppc_fp128 mul (ppc_fp128 0xM00000000000000010000000000000000, ppc_fp128 0xM40140000000000000000000000000000), ppc_fp128 fpext (double 0x3C447AE147AE147B to ppc_fp128)) ; [#uses=1]
    22 %0 = fcmp ogt ppc_fp128 0xM00000000000000000000000000000000, select (i1 fcmp olt (ppc_fp128 fpext (double 0x3C447AE147AE147B to ppc_fp128), ppc_fp128 fmul (ppc_fp128 0xM00000000000000010000000000000000, ppc_fp128 0xM40140000000000000000000000000000)), ppc_fp128 fmul (ppc_fp128 0xM00000000000000010000000000000000, ppc_fp128 0xM40140000000000000000000000000000), ppc_fp128 fpext (double 0x3C447AE147AE147B to ppc_fp128)) ; [#uses=1]
    2323 br i1 %0, label %bb4, label %bb5.split
    2424
    2525 bb5.split: ; preds = %bb4
    1313 }
    1414
    1515 define <4 x float> @test3(<4 x float> %Y) {
    16 %Z = add <4 x float> %Y, %Y
    16 %Z = fadd <4 x float> %Y, %Y
    1717 %X = shufflevector <4 x float> zeroinitializer, <4 x float> %Z, <4 x i32> < i32 0, i32 5, i32 6, i32 7 >
    1818 ret <4 x float> %X
    1919 }
    1010 target triple = "spu"
    1111
    1212 define double @fadd(double %arg1, double %arg2) {
    13 %A = add double %arg1, %arg2
    13 %A = fadd double %arg1, %arg2
    1414 ret double %A
    1515 }
    1616
    1717 define <2 x double> @fadd_vec(<2 x double> %arg1, <2 x double> %arg2) {
    18 %A = add <2 x double> %arg1, %arg2
    18 %A = fadd <2 x double> %arg1, %arg2
    1919 ret <2 x double> %A
    2020 }
    2121
    2222 define double @fsub(double %arg1, double %arg2) {
    23 %A = sub double %arg1, %arg2
    23 %A = fsub double %arg1, %arg2
    2424 ret double %A
    2525 }
    2626
    2727 define <2 x double> @fsub_vec(<2 x double> %arg1, <2 x double> %arg2) {
    28 %A = sub <2 x double> %arg1, %arg2
    28 %A = fsub <2 x double> %arg1, %arg2
    2929 ret <2 x double> %A
    3030 }
    3131
    3232 define double @fmul(double %arg1, double %arg2) {
    33 %A = mul double %arg1, %arg2
    33 %A = fmul double %arg1, %arg2
    3434 ret double %A
    3535 }
    3636
    3737 define <2 x double> @fmul_vec(<2 x double> %arg1, <2 x double> %arg2) {
    38 %A = mul <2 x double> %arg1, %arg2
    38 %A = fmul <2 x double> %arg1, %arg2
    3939 ret <2 x double> %A
    4040 }
    4141
    4242 define double @fma(double %arg1, double %arg2, double %arg3) {
    43 %A = mul double %arg1, %arg2
    44 %B = add double %A, %arg3
    43 %A = fmul double %arg1, %arg2
    44 %B = fadd double %A, %arg3
    4545 ret double %B
    4646 }
    4747
    4848 define <2 x double> @fma_vec(<2 x double> %arg1, <2 x double> %arg2, <2 x double> %arg3) {
    49 %A = mul <2 x double> %arg1, %arg2
    50 %B = add <2 x double> %A, %arg3
    49 %A = fmul <2 x double> %arg1, %arg2
    50 %B = fadd <2 x double> %A, %arg3
    5151 ret <2 x double> %B
    5252 }
    5353
    5454 define double @fms(double %arg1, double %arg2, double %arg3) {
    55 %A = mul double %arg1, %arg2
    56 %B = sub double %A, %arg3
    55 %A = fmul double %arg1, %arg2
    56 %B = fsub double %A, %arg3
    5757 ret double %B
    5858 }
    5959
    6060 define <2 x double> @fms_vec(<2 x double> %arg1, <2 x double> %arg2, <2 x double> %arg3) {
    61 %A = mul <2 x double> %arg1, %arg2
    62 %B = sub <2 x double> %A, %arg3
    61 %A = fmul <2 x double> %arg1, %arg2
    62 %B = fsub <2 x double> %A, %arg3
    6363 ret <2 x double> %B
    6464 }
    6565
    6666 ; - (a * b - c)
    6767 define double @d_fnms_1(double %arg1, double %arg2, double %arg3) {
    68 %A = mul double %arg1, %arg2
    69 %B = sub double %A, %arg3
    70 %C = sub double -0.000000e+00, %B ; [#uses=1]
    68 %A = fmul double %arg1, %arg2
    69 %B = fsub double %A, %arg3
    70 %C = fsub double -0.000000e+00, %B ; [#uses=1]
    7171 ret double %C
    7272 }
    7373
    7474 ; Annother way of getting fnms
    7575 ; - ( a * b ) + c => c - (a * b)
    7676 define double @d_fnms_2(double %arg1, double %arg2, double %arg3) {
    77 %A = mul double %arg1, %arg2
    78 %B = sub double %arg3, %A
    77 %A = fmul double %arg1, %arg2
    78 %B = fsub double %arg3, %A
    7979 ret double %B
    8080 }
    8181
    8282 ; FNMS: - (a * b - c) => c - (a * b)
    8383 define <2 x double> @d_fnms_vec_1(<2 x double> %arg1, <2 x double> %arg2, <2 x double> %arg3) {
    84 %A = mul <2 x double> %arg1, %arg2
    85 %B = sub <2 x double> %arg3, %A ;
    84 %A = fmul <2 x double> %arg1, %arg2
    85 %B = fsub <2 x double> %arg3, %A ;
    8686 ret <2 x double> %B
    8787 }
    8888
    8989 ; Another way to get fnms using a constant vector
    9090 ; - ( a * b - c)
    9191 define <2 x double> @d_fnms_vec_2(<2 x double> %arg1, <2 x double> %arg2, <2 x double> %arg3) {
    92 %A = mul <2 x double> %arg1, %arg2 ; <<2 x double>> [#uses=1]
    93 %B = sub <2 x double> %A, %arg3 ; <<2 x double>> [#uses=1]
    94 %C = sub <2 x double> < double -0.00000e+00, double -0.00000e+00 >, %B
    92 %A = fmul <2 x double> %arg1, %arg2 ; <<2 x double>> [#uses=1]
    93 %B = fsub <2 x double> %A, %arg3 ; <<2 x double>> [#uses=1]
    94 %C = fsub <2 x double> < double -0.00000e+00, double -0.00000e+00 >, %B
    9595 ret <2 x double> %C
    9696 }
    9797
    66 target triple = "spu"
    77
    88 define double @fneg_dp(double %X) {
    9 %Y = sub double -0.000000e+00, %X
    9 %Y = fsub double -0.000000e+00, %X
    1010 ret double %Y
    1111 }
    1212
    1313 define <2 x double> @fneg_dp_vec(<2 x double> %X) {
    14 %Y = sub <2 x double> < double -0.0000e+00, double -0.0000e+00 >, %X
    14 %Y = fsub <2 x double> < double -0.0000e+00, double -0.0000e+00 >, %X
    1515 ret <2 x double> %Y
    1616 }
    1717
    1818 define float @fneg_sp(float %X) {
    19 %Y = sub float -0.000000e+00, %X
    19 %Y = fsub float -0.000000e+00, %X
    2020 ret float %Y
    2121 }
    2222
    2323 define <4 x float> @fneg_sp_vec(<4 x float> %X) {
    24 %Y = sub <4 x float>
    24 %Y = fsub <4 x float>
    2525 float -0.000000e+00, float -0.000000e+00>, %X
    2626 ret <4 x float> %Y
    2727 }
    1111 target triple = "spu"
    1212
    1313 define float @fp_add(float %arg1, float %arg2) {
    14 %A = add float %arg1, %arg2 ; [#uses=1]
    14 %A = fadd float %arg1, %arg2 ; [#uses=1]
    1515 ret float %A
    1616 }
    1717
    1818 define <4 x float> @fp_add_vec(<4 x float> %arg1, <4 x float> %arg2) {
    19 %A = add <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    19 %A = fadd <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    2020 ret <4 x float> %A
    2121 }
    2222
    2323 define float @fp_sub(float %arg1, float %arg2) {
    24 %A = sub float %arg1, %arg2 ; [#uses=1]
    24 %A = fsub float %arg1, %arg2 ; [#uses=1]
    2525 ret float %A
    2626 }
    2727
    2828 define <4 x float> @fp_sub_vec(<4 x float> %arg1, <4 x float> %arg2) {
    29 %A = sub <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    29 %A = fsub <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    3030 ret <4 x float> %A
    3131 }
    3232
    3333 define float @fp_mul(float %arg1, float %arg2) {
    34 %A = mul float %arg1, %arg2 ; [#uses=1]
    34 %A = fmul float %arg1, %arg2 ; [#uses=1]
    3535 ret float %A
    3636 }
    3737
    3838 define <4 x float> @fp_mul_vec(<4 x float> %arg1, <4 x float> %arg2) {
    39 %A = mul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    39 %A = fmul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    4040 ret <4 x float> %A
    4141 }
    4242
    4343 define float @fp_mul_add(float %arg1, float %arg2, float %arg3) {
    44 %A = mul float %arg1, %arg2 ; [#uses=1]
    45 %B = add float %A, %arg3 ; [#uses=1]
    44 %A = fmul float %arg1, %arg2 ; [#uses=1]
    45 %B = fadd float %A, %arg3 ; [#uses=1]
    4646 ret float %B
    4747 }
    4848
    4949 define <4 x float> @fp_mul_add_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) {
    50 %A = mul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    51 %B = add <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1]
    50 %A = fmul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    51 %B = fadd <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1]
    5252 ret <4 x float> %B
    5353 }
    5454
    5555 define float @fp_mul_sub(float %arg1, float %arg2, float %arg3) {
    56 %A = mul float %arg1, %arg2 ; [#uses=1]
    57 %B = sub float %A, %arg3 ; [#uses=1]
    56 %A = fmul float %arg1, %arg2 ; [#uses=1]
    57 %B = fsub float %A, %arg3 ; [#uses=1]
    5858 ret float %B
    5959 }
    6060
    6161 define <4 x float> @fp_mul_sub_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) {
    62 %A = mul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    63 %B = sub <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1]
    62 %A = fmul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1]
    63 %B = fsub <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1]
    6464 ret <4 x float> %B
    6565 }
    6666
    6767 ; Test the straightforward way of getting fnms
    6868 ; c - a * b
    6969 define float @fp_neg_mul_sub_1(float %arg1, float %arg2, float %arg3) {
    70 %A = mul float %arg1, %arg2
    71 %B = sub float %arg3, %A
    70 %A = fmul float %arg1, %arg2
    71 %B = fsub float %arg3, %A
    7272 ret float %B
    7373 }
    7474
    7575 ; Test another way of getting fnms
    7676 ; - ( a *b -c ) = c - a * b
    7777 define float @fp_neg_mul_sub_2(float %arg1, float %arg2, float %arg3) {
    78 %A = mul float %arg1, %arg2
    79 %B = sub float %A, %arg3
    80 %C = sub float -0.0, %B
    78 %A = fmul float %arg1, %arg2
    79 %B = fsub float %A, %arg3
    80 %C = fsub float -0.0, %B
    8181 ret float %C
    8282 }
    8383
    8484 define <4 x float> @fp_neg_mul_sub_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) {
    85 %A = mul <4 x float> %arg1, %arg2
    86 %B = sub <4 x float> %A, %arg3
    87 %D = sub <4 x float> < float -0.0, float -0.0, float -0.0, float -0.0 >, %B
    85 %A = fmul <4 x float> %arg1, %arg2
    86 %B = fsub <4 x float> %A, %arg3
    87 %D = fsub <4 x float> < float -0.0, float -0.0, float -0.0, float -0.0 >, %B
    8888 ret <4 x float> %D
    8989 }
    1111 br label %bb1
    1212
    1313 bb1: ; preds = %bb1, %0
    14 %x1 = mul float %x, %y ; [#uses=1]
    15 %y1 = mul float %y, 7.500000e-01 ; [#uses=1]
    16 %z1 = add float %x1, %y1 ; [#uses=1]
    17 %x2 = mul float %x, 5.000000e-01 ; [#uses=1]
    18 %y2 = mul float %y, 0x3FECCCCCC0000000 ; [#uses=1]
    19 %z2 = add float %x2, %y2 ; [#uses=1]
    20 %z3 = add float %z1, %z2 ; [#uses=1]
    14 %x1 = fmul float %x, %y ; [#uses=1]
    15 %y1 = fmul float %y, 7.500000e-01 ; [#uses=1]
    16 %z1 = fadd float %x1, %y1 ; [#uses=1]
    17 %x2 = fmul float %x, 5.000000e-01 ; [#uses=1]
    18 %y2 = fmul float %y, 0x3FECCCCCC0000000 ; [#uses=1]
    19 %z2 = fadd float %x2, %y2 ; [#uses=1]
    20 %z3 = fadd float %z1, %z2 ; [#uses=1]
    2121 %i1 = shl i32 %i, 3 ; [#uses=1]
    2222 %j1 = add i32 %i, 7 ; [#uses=1]
    2323 %m1 = add i32 %i1, %j1 ; [#uses=2]
    7070 %tmp178.i = add i32 %tmp116117.i, -128 ; [#uses=2]
    7171 %tmp181.i = mul i32 %tmp178.i, %tmp178.i ; [#uses=1]
    7272 %tmp181182.i = sitofp i32 %tmp181.i to float ; [#uses=1]
    73 %tmp199200.pn.in.i = mul float %tmp181182.i, 0.000000e+00 ; [#uses=1]
    73 %tmp199200.pn.in.i = fmul float %tmp181182.i, 0.000000e+00 ; [#uses=1]
    7474 %tmp199200.pn.i = fpext float %tmp199200.pn.in.i to double ; [#uses=1]
    75 %tmp201.pn.i = sub double 1.000000e+00, %tmp199200.pn.i ; [#uses=1]
    76 %factor.2.in.i = mul double 0.000000e+00, %tmp201.pn.i ; [#uses=1]
    75 %tmp201.pn.i = fsub double 1.000000e+00, %tmp199200.pn.i ; [#uses=1]
    76 %factor.2.in.i = fmul double 0.000000e+00, %tmp201.pn.i ; [#uses=1]
    7777 %factor.2.i = fptrunc double %factor.2.in.i to float ; [#uses=1]
    7878 br i1 false, label %cond_next312.i, label %cond_false222.i
    7979
    44 br label %bb15
    55
    66 bb15: ; preds = %bb15, %entry
    7 %tmp21 = add <8 x double> zeroinitializer, zeroinitializer ; <<8 x double>> [#uses=1]
    7 %tmp21 = fadd <8 x double> zeroinitializer, zeroinitializer ; <<8 x double>> [#uses=1]
    88 br i1 false, label %bb30, label %bb15
    99
    1010 bb30: ; preds = %bb15
    44 entry:
    55 %tmp98 = load float* null, align 4 ; [#uses=1]
    66 %tmp106 = load float* null, align 4 ; [#uses=1]
    7 %tmp113 = add float %tmp98, %tmp106 ; [#uses=1]
    8 %tmp119 = sub float %tmp113, 0.000000e+00 ; [#uses=1]
    7 %tmp113 = fadd float %tmp98, %tmp106 ; [#uses=1]
    8 %tmp119 = fsub float %tmp113, 0.000000e+00 ; [#uses=1]
    99 call void (i32, ...)* @foo( i32 0, float 0.000000e+00, float %tmp119 ) nounwind
    1010 ret void
    1111 }
    2929 br i1 false, label %bb471, label %bb505
    3030
    3131 bb471: ; preds = %bb471, %bb.nph1770
    32 %tmp487 = add double 0.000000e+00, 0.000000e+00 ; [#uses=1]
    32 %tmp487 = fadd double 0.000000e+00, 0.000000e+00 ; [#uses=1]
    3333 br i1 false, label %bb505, label %bb471
    3434
    3535 bb505: ; preds = %bb471, %bb.nph1770
    3636 %xy.0.lcssa = phi double [ 0.000000e+00, %bb.nph1770 ], [ %tmp487, %bb471 ] ; [#uses=1]
    37 %tmp507 = sub double -0.000000e+00, %xy.0.lcssa ; [#uses=1]
    37 %tmp507 = fsub double -0.000000e+00, %xy.0.lcssa ; [#uses=1]
    3838 %tmp509 = fdiv double %tmp507, 0.000000e+00 ; [#uses=1]
    39 %tmp510 = mul double %tmp509, 1.024000e+03 ; [#uses=1]
    39 %tmp510 = fmul double %tmp509, 1.024000e+03 ; [#uses=1]
    4040 %tmp516 = fdiv double %tmp510, 0.000000e+00 ; [#uses=1]
    41 %tmp517 = add double %tmp516, 5.000000e-01 ; [#uses=1]
    41 %tmp517 = fadd double %tmp516, 5.000000e-01 ; [#uses=1]
    4242 %tmp518 = tail call double @floor( double %tmp517 ) nounwind readnone ; [#uses=0]
    4343 ret i32 0
    4444
    0 ; RUN: llvm-as < %s | llc
    11
    22 define double @fneg(double %X) {
    3 %Y = sub double -0.000000e+00, %X ; [#uses=1]
    3 %Y = fsub double -0.000000e+00, %X ; [#uses=1]
    44 ret double %Y
    55 }
    66
    77 define float @fnegf(float %X) {
    8 %Y = sub float -0.000000e+00, %X ; [#uses=1]
    8 %Y = fsub float -0.000000e+00, %X ; [#uses=1]
    99 ret float %Y
    1010 }
    1111
    2323 %b_s = getelementptr [8 x i8]* @b_str, i64 0, i64 0 ; [#uses=1]
    2424 call i32 (i8*, ...)* @printf( i8* %a_s, double %a ) ; :1 [#uses=0]
    2525 call i32 (i8*, ...)* @printf( i8* %b_s, double %b ) ; :2 [#uses=0]
    26 %add_r = add double %a, %b ; [#uses=1]
    27 %sub_r = sub double %a, %b ; [#uses=1]
    28 %mul_r = mul double %a, %b ; [#uses=1]
    26 %add_r = fadd double %a, %b ; [#uses=1]
    27 %sub_r = fsub double %a, %b ; [#uses=1]
    28 %mul_r = fmul double %a, %b ; [#uses=1]
    2929 %div_r = fdiv double %b, %a ; [#uses=1]
    3030 %rem_r = frem double %b, %a ; [#uses=1]
    3131 %add_s = getelementptr [12 x i8]* @add_str, i64 0, i64 0 ; [#uses=1]
    88 %a = add i32 %N, 1 ; [#uses=0]
    99 %i = add i32 %N, 12345678 ; [#uses=0]
    1010 %b = add i16 4, 3 ; [#uses=0]
    11 %c = add float %X, 0.000000e+00 ; [#uses=0]
    12 %d = add float %X, 0x400921CAC0000000 ; [#uses=0]
    11 %c = fadd float %X, 0.000000e+00 ; [#uses=0]
    12 %d = fadd float %X, 0x400921CAC0000000 ; [#uses=0]
    1313 %f = add i32 -1, 10 ; [#uses=0]
    1414 %g = add i16 20, -1 ; [#uses=0]
    1515 %j = add i16 -1, 30 ; [#uses=0]
    125125 br label %Top
    126126
    127127 Top: ; preds = %Top, %0
    128 %p = add float %x, %y ; [#uses=1]
    129 %z = sub float %x, %y ; [#uses=1]
    128 %p = fadd float %x, %y ; [#uses=1]
    129 %z = fsub float %x, %y ; [#uses=1]
    130130 %b = fcmp ole float %p, %z ; [#uses=2]
    131131 %c = xor i1 %b, true ; [#uses=0]
    132132 br i1 %b, label %Top, label %goon
    0 ; RUN: llvm-as < %s | llc
    11
    22 define void @foo(double %a, double %b, float* %fp) {
    3 %c = add double %a, %b
    3 %c = fadd double %a, %b
    44 %d = fptrunc double %c to float
    55 store float %d, float* %fp
    66 ret void
    33 define void @test_f8(%f8 *%P, %f8* %Q, %f8 *%S) {
    44 %p = load %f8* %P
    55 %q = load %f8* %Q
    6 %R = add %f8 %p, %q
    6 %R = fadd %f8 %p, %q
    77 store %f8 %R, %f8 *%S
    88 ret void
    99 }
    1313 define void @test_f1(%f1* %P, %f1* %Q, %f1* %S) {
    1414 %p = load %f1* %P ; <%f1> [#uses=1]
    1515 %q = load %f1* %Q ; <%f1> [#uses=1]
    16 %R = add %f1 %p, %q ; <%f1> [#uses=1]
    16 %R = fadd %f1 %p, %q ; <%f1> [#uses=1]
    1717 store %f1 %R, %f1* %S
    1818 ret void
    1919 }
    2121 define void @test_f2(%f2* %P, %f2* %Q, %f2* %S) {
    2222 %p = load %f2* %P ; <%f2> [#uses=1]
    2323 %q = load %f2* %Q ; <%f2> [#uses=1]
    24 %R = add %f2 %p, %q ; <%f2> [#uses=1]
    24 %R = fadd %f2 %p, %q ; <%f2> [#uses=1]
    2525 store %f2 %R, %f2* %S
    2626 ret void
    2727 }
    2929 define void @test_f4(%f4* %P, %f4* %Q, %f4* %S) {
    3030 %p = load %f4* %P ; <%f4> [#uses=1]
    3131 %q = load %f4* %Q ; <%f4> [#uses=1]
    32 %R = add %f4 %p, %q ; <%f4> [#uses=1]
    32 %R = fadd %f4 %p, %q ; <%f4> [#uses=1]
    3333 store %f4 %R, %f4* %S
    3434 ret void
    3535 }
    3737 define void @test_f8(%f8* %P, %f8* %Q, %f8* %S) {
    3838 %p = load %f8* %P ; <%f8> [#uses=1]
    3939 %q = load %f8* %Q ; <%f8> [#uses=1]
    40 %R = add %f8 %p, %q ; <%f8> [#uses=1]
    40 %R = fadd %f8 %p, %q ; <%f8> [#uses=1]
    4141 store %f8 %R, %f8* %S
    4242 ret void
    4343 }
    4545 define void @test_fmul(%f8* %P, %f8* %Q, %f8* %S) {
    4646 %p = load %f8* %P ; <%f8> [#uses=1]
    4747 %q = load %f8* %Q ; <%f8> [#uses=1]
    48 %R = mul %f8 %p, %q ; <%f8> [#uses=1]
    48 %R = fmul %f8 %p, %q ; <%f8> [#uses=1]
    4949 store %f8 %R, %f8* %S
    5050 ret void
    5151 }
    6363
    6464 define void @test_cst(%f4* %P, %f4* %S) {
    6565 %p = load %f4* %P ; <%f4> [#uses=1]
    66 %R = add %f4 %p, < float 0x3FB99999A0000000, float 1.000000e+00, float 2.000000e+00, float 4.500000e+00 > ; <%f4> [#uses=1]
    66 %R = fadd %f4 %p, < float 0x3FB99999A0000000, float 1.000000e+00, float 2.000000e+00, float 4.500000e+00 > ; <%f4> [#uses=1]
    6767 store %f4 %R, %f4* %S
    6868 ret void
    6969 }
    7070
    7171 define void @test_zero(%f4* %P, %f4* %S) {
    7272 %p = load %f4* %P ; <%f4> [#uses=1]
    73 %R = add %f4 %p, zeroinitializer ; <%f4> [#uses=1]
    73 %R = fadd %f4 %p, zeroinitializer ; <%f4> [#uses=1]
    7474 store %f4 %R, %f4* %S
    7575 ret void
    7676 }
    7777
    7878 define void @test_undef(%f4* %P, %f4* %S) {
    7979 %p = load %f4* %P ; <%f4> [#uses=1]
    80 %R = add %f4 %p, undef ; <%f4> [#uses=1]
    80 %R = fadd %f4 %p, undef ; <%f4> [#uses=1]
    8181 store %f4 %R, %f4* %S
    8282 ret void
    8383 }
    114114
    115115 define void @test_cast_1(%f4* %b, %i4* %a) {
    116116 %tmp = load %f4* %b ; <%f4> [#uses=1]
    117 %tmp2 = add %f4 %tmp, < float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00 > ; <%f4> [#uses=1]
    117 %tmp2 = fadd %f4 %tmp, < float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00 > ; <%f4> [#uses=1]
    118118 %tmp3 = bitcast %f4 %tmp2 to %i4 ; <%i4> [#uses=1]
    119119 %tmp4 = add %i4 %tmp3, < i32 1, i32 2, i32 3, i32 4 > ; <%i4> [#uses=1]
    120120 store %i4 %tmp4, %i4* %a
    136136 %tmp4 = insertelement %f4 %tmp2, float %X, i32 2 ; <%f4> [#uses=1]
    137137 %tmp6 = insertelement %f4 %tmp4, float %X, i32 3 ; <%f4> [#uses=1]
    138138 %q = load %f4* %Q ; <%f4> [#uses=1]
    139 %R = add %f4 %q, %tmp6 ; <%f4> [#uses=1]
    139 %R = fadd %f4 %q, %tmp6 ; <%f4> [#uses=1]
    140140 store %f4 %R, %f4* %P
    141141 ret void
    142142 }
    11
    22 define i16 @test(double %d) nounwind {
    33 entry:
    4 %add = add double %d, 1.000000e+00
    4 %add = fadd double %d, 1.000000e+00
    55 %call = tail call i16 @funct(double %add) nounwind
    66 ret i16 %call
    77 }
    44
    55 define double @dofloat(double %a, double %b) nounwind {
    66 entry:
    7 add double %a, %b ; :0 [#uses=1]
    7 fadd double %a, %b ; :0 [#uses=1]
    88 ret double %0
    99 }
    55
    66 define float @F(float %a) nounwind {
    77 entry:
    8 add float %a, 0x4011333340000000 ; :0 [#uses=1]
    9 add float %0, 0x4010666660000000 ; :1 [#uses=1]
    8 fadd float %a, 0x4011333340000000 ; :0 [#uses=1]
    9 fadd float %0, 0x4010666660000000 ; :1 [#uses=1]
    1010 ret float %1
    1111 }
    1010 br i1 %0, label %bb, label %bb2
    1111
    1212 bb: ; preds = %entry
    13 add float %a, 1.000000e+00 ; :1 [#uses=1]
    13 fadd float %a, 1.000000e+00 ; :1 [#uses=1]
    1414 ret float %1
    1515
    1616 bb2: ; preds = %entry
    88 entry:
    99 tail call double @fabs( double %c ) nounwind readnone ; :0 [#uses=1]
    1010 tail call double @fabs( double %d ) nounwind readnone ; :0 [#uses=1]
    11 add double %0, %1
    11 fadd double %0, %1
    1212 ret double %2
    1313 }
    1414
    2020 load i16* %3, align 2 ; :4 [#uses=1]
    2121 uitofp i16 %4 to double ; :5 [#uses=1]
    2222 tail call double @ldexp( double %5, i32 -32 ) nounwind ; :6 [#uses=1]
    23 add double %2, %6 ; :7 [#uses=1]
    23 fadd double %2, %6 ; :7 [#uses=1]
    2424 getelementptr i16* %xseed, i32 2 ; :8 [#uses=1]
    2525 load i16* %8, align 2 ; :9 [#uses=1]
    2626 uitofp i16 %9 to double ; :10 [#uses=1]
    2727 tail call double @ldexp( double %10, i32 -16 ) nounwind ; :11 [#uses=1]
    28 add double %7, %11 ; :12 [#uses=1]
    28 fadd double %7, %11 ; :12 [#uses=1]
    2929 ret double %12
    3030 }
    3131
    4444 load i16* %4, align 2 ; :5 [#uses=1]
    4545 uitofp i16 %5 to double ; :6 [#uses=1]
    4646 tail call double @ldexp( double %6, i32 -32 ) nounwind ; :7 [#uses=1]
    47 add double %3, %7 ; :8 [#uses=1]
    47 fadd double %3, %7 ; :8 [#uses=1]
    4848 getelementptr i16* %xseed, i32 2 ; :9 [#uses=1]
    4949 load i16* %9, align 2 ; :10 [#uses=1]
    5050 uitofp i16 %10 to double ; :11 [#uses=1]
    5151 tail call double @ldexp( double %11, i32 -16 ) nounwind ; :12 [#uses=1]
    52 add double %8, %12 ; :13 [#uses=1]
    52 fadd double %8, %12 ; :13 [#uses=1]
    5353 ret double %13
    5454 }
    44
    55 ; Dead argument should reserve an FP register.
    66 define double @bar(double %DEAD, double %X, double %Y) {
    7 %tmp.2 = add double %X, %Y ; [#uses=1]
    7 %tmp.2 = fadd double %X, %Y ; [#uses=1]
    88 ret double %tmp.2