From: Sanjay Patel Date: Tue, 24 Nov 2015 17:51:20 +0000 (+0000) Subject: [InstCombine] fix propagation of fast-math-flags X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4da18f10ae054091f7e6f355d63919ebcabe8a46;p=oota-llvm.git [InstCombine] fix propagation of fast-math-flags Noticed while working on D4583: http://reviews.llvm.org/D4583 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253997 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index 10a517af42e..e95a65510ec 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1245,16 +1245,11 @@ Value *InstCombiner::Descale(Value *Val, APInt Scale, bool &NoSignedWrap) { /// specified one but with other operands. static Value *CreateBinOpAsGiven(BinaryOperator &Inst, Value *LHS, Value *RHS, InstCombiner::BuilderTy *B) { - Value *BORes = B->CreateBinOp(Inst.getOpcode(), LHS, RHS); - if (BinaryOperator *NewBO = dyn_cast(BORes)) { - if (isa(NewBO)) { - NewBO->setHasNoSignedWrap(Inst.hasNoSignedWrap()); - NewBO->setHasNoUnsignedWrap(Inst.hasNoUnsignedWrap()); - } - if (isa(NewBO)) - NewBO->setIsExact(Inst.isExact()); - } - return BORes; + Value *BO = B->CreateBinOp(Inst.getOpcode(), LHS, RHS); + // If LHS and RHS are constant, BO won't be a binary operator. + if (BinaryOperator *NewBO = dyn_cast(BO)) + NewBO->copyIRFlags(&Inst); + return BO; } /// \brief Makes transformation of binary operation specific for vector types. diff --git a/test/Transforms/InstCombine/vec_shuffle.ll b/test/Transforms/InstCombine/vec_shuffle.ll index 8db13b67e2f..d2cd2b90abc 100644 --- a/test/Transforms/InstCombine/vec_shuffle.ll +++ b/test/Transforms/InstCombine/vec_shuffle.ll @@ -310,16 +310,16 @@ define <4 x i32> @shuffle_17addnuw(<4 x i32> %v1, <4 x i32> %v2) nounwind uwtabl ret <4 x i32> %r } -define <4 x float> @shuffle_17fsub(<4 x float> %v1, <4 x float> %v2) nounwind uwtable { -; CHECK-LABEL: @shuffle_17fsub( -; CHECK-NOT: shufflevector -; CHECK: fsub <4 x float> %v1, %v2 -; CHECK: shufflevector +define <4 x float> @shuffle_17fsub_fast(<4 x float> %v1, <4 x float> %v2) nounwind uwtable { +; CHECK-LABEL: @shuffle_17fsub_fast( +; CHECK-NEXT: [[VAR1:%[a-zA-Z0-9.]+]] = fsub fast <4 x float> %v1, %v2 +; CHECK-NEXT: shufflevector <4 x float> [[VAR1]], <4 x float> undef, <4 x i32> +; CHECK-NEXT: ret <4 x float> %t1 = shufflevector <4 x float> %v1, <4 x float> zeroinitializer, <4 x i32> %t2 = shufflevector <4 x float> %v2, <4 x float> zeroinitializer, <4 x i32> - %r = fsub <4 x float> %t1, %t2 + %r = fsub fast <4 x float> %t1, %t2 ret <4 x float> %r }