From b98e71a227d508afa7fb68305abfb0076e490355 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 14 Aug 2015 22:46:49 +0000 Subject: [PATCH] Fix a crash where a utility function wasn't aware of fcmp vectors and created a value with the wrong type. Fixes PR24458! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245119 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 3 ++- test/Transforms/InstCombine/vector-casts.ll | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index ee21c81fa26..15e0889b51b 100644 --- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -93,7 +93,8 @@ static Value *getFCmpValue(bool isordered, unsigned code, case 5: Pred = isordered ? FCmpInst::FCMP_ONE : FCmpInst::FCMP_UNE; break; case 6: Pred = isordered ? FCmpInst::FCMP_OLE : FCmpInst::FCMP_ULE; break; case 7: - if (!isordered) return ConstantInt::getTrue(LHS->getContext()); + if (!isordered) + return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 1); Pred = FCmpInst::FCMP_ORD; break; } return Builder->CreateFCmp(Pred, LHS, RHS); diff --git a/test/Transforms/InstCombine/vector-casts.ll b/test/Transforms/InstCombine/vector-casts.ll index 727eb4ebb4c..af18b4cfbdd 100644 --- a/test/Transforms/InstCombine/vector-casts.ll +++ b/test/Transforms/InstCombine/vector-casts.ll @@ -150,3 +150,14 @@ entry: ret <4 x float> undef } +define <8 x i32> @pr24458(<8 x float> %n) { +; CHECK-LABEL: @pr24458 + %notequal_b_load_.i = fcmp une <8 x float> %n, zeroinitializer + %equal_a_load72_.i = fcmp ueq <8 x float> %n, zeroinitializer + %notequal_b_load__to_boolvec.i = sext <8 x i1> %notequal_b_load_.i to <8 x i32> + %equal_a_load72__to_boolvec.i = sext <8 x i1> %equal_a_load72_.i to <8 x i32> + %wrong = or <8 x i32> %notequal_b_load__to_boolvec.i, %equal_a_load72__to_boolvec.i + ret <8 x i32> %wrong +; CHECK-NEXT: ret <8 x i32> +} + -- 2.11.0