llvm.org GIT mirror llvm / 06362e2
Merging r181586: ------------------------------------------------------------------------ r181586 | d0k | 2013-05-10 02:16:52 -0700 (Fri, 10 May 2013) | 3 lines InstCombine: Verify the type before transforming uitofp into select. PR15952. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_33@181813 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 7 years ago
2 changed file(s) with 41 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
524524 }
525525
526526 // B * (uitofp i1 C) -> select C, B, 0
527 if(I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) {
528 Value *LHS=Op0, *RHS=Op1;
529 Value *B, *C;
530 if (!match(RHS, m_UIToFp(m_Value(C))))
531 std::swap(LHS, RHS);
532
533 if (match(RHS, m_UIToFp(m_Value(C)))) {
534 B=LHS;
535 Value *Zero = ConstantFP::getNegativeZero(B->getType());
536 return SelectInst::Create(C, B, Zero);
537 }
527 if (I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) {
528 Value *LHS = Op0, *RHS = Op1;
529 Value *B, *C;
530 if (!match(RHS, m_UIToFp(m_Value(C))))
531 std::swap(LHS, RHS);
532
533 if (match(RHS, m_UIToFp(m_Value(C))) && C->getType()->isIntegerTy(1)) {
534 B = LHS;
535 Value *Zero = ConstantFP::getNegativeZero(B->getType());
536 return SelectInst::Create(C, B, Zero);
537 }
538538 }
539539
540540 // A * (1 - uitofp i1 C) -> select C, 0, A
541 if(I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) {
542 Value *LHS=Op0, *RHS=Op1;
543 Value *A, *C;
544 if (!match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C)))))
545 std::swap(LHS, RHS);
546
547 if (match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C))))) {
548 A=LHS;
549 Value *Zero = ConstantFP::getNegativeZero(A->getType());
550 return SelectInst::Create(C, Zero, A);
551 }
541 if (I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) {
542 Value *LHS = Op0, *RHS = Op1;
543 Value *A, *C;
544 if (!match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C)))))
545 std::swap(LHS, RHS);
546
547 if (match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C)))) &&
548 C->getType()->isIntegerTy(1)) {
549 A = LHS;
550 Value *Zero = ConstantFP::getNegativeZero(A->getType());
551 return SelectInst::Create(C, Zero, A);
552 }
552553 }
553554
554555 if (!isa(Op1))
3737 ; CHECK: select i1 %C, float %B, float %A
3838 }
3939
40 ; PR15952
41 define float @test4(float %A, float %B, i32 %C) {
42 %cf = uitofp i32 %C to float
43 %mc = fsub float 1.000000e+00, %cf
44 %p1 = fmul fast float %A, %mc
45 ret float %p1
46 ; CHECK: @test4
47 ; CHECK: uitofp
48 }
49
50 define float @test5(float %A, float %B, i32 %C) {
51 %cf = uitofp i32 %C to float
52 %p2 = fmul fast float %B, %cf
53 ret float %p2
54 ; CHECK: @test5
55 ; CHECK: uitofp
56 }
57