diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -2009,11 +2009,6 @@ } } else if (auto *C1VTy = dyn_cast(C1->getType())) { - // Do not iterate on scalable vector. The number of elements is unknown at - // compile-time. - if (isa(C1VTy)) - return nullptr; - // Fast path for splatted constants. if (Constant *C1Splat = C1->getSplatValue()) if (Constant *C2Splat = C2->getSplatValue()) @@ -2021,6 +2016,11 @@ C1VTy->getElementCount(), ConstantExpr::getCompare(pred, C1Splat, C2Splat)); + // Do not iterate on scalable vector. The number of elements is unknown at + // compile-time. + if (isa(C1VTy)) + return nullptr; + // If we can constant fold the comparison of each element, constant fold // the whole vector comparison. SmallVector ResElts; diff --git a/llvm/test/Analysis/ConstantFolding/cmp-vec-fast-path.ll b/llvm/test/Analysis/ConstantFolding/cmp-vec-fast-path.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Analysis/ConstantFolding/cmp-vec-fast-path.ll @@ -0,0 +1,840 @@ + +; Check that cmp's of scalable vector splats are constant folded +; FIXME: Constant::getSplatValue() only knows how to get the splat value of +; ConstantAggregateZero values with scalable vector type. Once it is +; extended to support arbitrary splats, this test should be updated + +; RUN: opt -constprop -S < %s | FileCheck %s + + +; CHECK-LABEL: i32cmp_eq_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_eq_fixed_zero() { + %res = icmp eq <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_eq_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_eq_scalable_zero() { + %res = icmp eq zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_eq_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_eq_fixed_one() { + %res = icmp eq <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_eq_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_eq_scalable_one() { + %res = icmp eq shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: i32cmp_ne_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_ne_fixed_zero() { + %res = icmp ne <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_ne_scalable_zero +; CHECK: ret zeroinitializer +define @i32cmp_ne_scalable_zero() { + %res = icmp ne zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_ne_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_ne_fixed_one() { + %res = icmp ne <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_ne_scalable_one +; CHECK: ret zeroinitializer +define @i32cmp_ne_scalable_one() { + %res = icmp ne shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: i32cmp_ugt_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_ugt_fixed_zero() { + %res = icmp ugt <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_ugt_scalable_zero +; CHECK: ret zeroinitializer +define @i32cmp_ugt_scalable_zero() { + %res = icmp ugt zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_ugt_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_ugt_fixed_one() { + %res = icmp ugt <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_ugt_scalable_one +; CHECK: ret zeroinitializer +define @i32cmp_ugt_scalable_one() { + %res = icmp ugt shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: i32cmp_uge_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_uge_fixed_zero() { + %res = icmp uge <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_uge_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_uge_scalable_zero() { + %res = icmp uge zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_uge_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_uge_fixed_one() { + %res = icmp uge <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_uge_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_uge_scalable_one() { + %res = icmp uge shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: i32cmp_ult_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_ult_fixed_zero() { + %res = icmp ult <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_ult_scalable_zero +; CHECK: ret zeroinitializer +define @i32cmp_ult_scalable_zero() { + %res = icmp ult zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_ult_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_ult_fixed_one() { + %res = icmp ult <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_ult_scalable_one +; CHECK: ret zeroinitializer +define @i32cmp_ult_scalable_one() { + %res = icmp ult shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: i32cmp_ule_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_ule_fixed_zero() { + %res = icmp ule <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_ule_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_ule_scalable_zero() { + %res = icmp ule zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_ule_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_ule_fixed_one() { + %res = icmp ule <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_ule_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_ule_scalable_one() { + %res = icmp ule shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: i32cmp_sgt_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_sgt_fixed_zero() { + %res = icmp sgt <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_sgt_scalable_zero +; CHECK: ret zeroinitializer +define @i32cmp_sgt_scalable_zero() { + %res = icmp sgt zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_sgt_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_sgt_fixed_one() { + %res = icmp sgt <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_sgt_scalable_one +; CHECK: ret zeroinitializer +define @i32cmp_sgt_scalable_one() { + %res = icmp sgt shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: i32cmp_sge_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_sge_fixed_zero() { + %res = icmp sge <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_sge_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_sge_scalable_zero() { + %res = icmp sge zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_sge_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_sge_fixed_one() { + %res = icmp sge <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_sge_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_sge_scalable_one() { + %res = icmp sge shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: i32cmp_slt_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_slt_fixed_zero() { + %res = icmp slt <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_slt_scalable_zero +; CHECK: ret zeroinitializer +define @i32cmp_slt_scalable_zero() { + %res = icmp slt zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_slt_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @i32cmp_slt_fixed_one() { + %res = icmp slt <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_slt_scalable_one +; CHECK: ret zeroinitializer +define @i32cmp_slt_scalable_one() { + %res = icmp slt shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: i32cmp_sle_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_sle_fixed_zero() { + %res = icmp sle <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_sle_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_sle_scalable_zero() { + %res = icmp sle zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: i32cmp_sle_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @i32cmp_sle_fixed_one() { + %res = icmp sle <2 x i32> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: i32cmp_sle_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @i32cmp_sle_scalable_one() { + %res = icmp sle shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_false_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_false_fixed_zero() { + %res = fcmp false <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_false_scalable_zero +; CHECK: ret zeroinitializer +define @floatcmp_false_scalable_zero() { + %res = fcmp false zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_false_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_false_fixed_one() { + %res = fcmp false <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_false_scalable_one +; CHECK: ret zeroinitializer +define @floatcmp_false_scalable_one() { + %res = fcmp false shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_oeq_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_oeq_fixed_zero() { + %res = fcmp oeq <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_oeq_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_oeq_scalable_zero() { + %res = fcmp oeq zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_oeq_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_oeq_fixed_one() { + %res = fcmp oeq <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_oeq_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_oeq_scalable_one() { + %res = fcmp oeq shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_ogt_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_ogt_fixed_zero() { + %res = fcmp ogt <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ogt_scalable_zero +; CHECK: ret zeroinitializer +define @floatcmp_ogt_scalable_zero() { + %res = fcmp ogt zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_ogt_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_ogt_fixed_one() { + %res = fcmp ogt <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ogt_scalable_one +; CHECK: ret zeroinitializer +define @floatcmp_ogt_scalable_one() { + %res = fcmp ogt shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_oge_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_oge_fixed_zero() { + %res = fcmp oge <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_oge_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_oge_scalable_zero() { + %res = fcmp oge zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_oge_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_oge_fixed_one() { + %res = fcmp oge <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_oge_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_oge_scalable_one() { + %res = fcmp oge shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_olt_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_olt_fixed_zero() { + %res = fcmp olt <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_olt_scalable_zero +; CHECK: ret zeroinitializer +define @floatcmp_olt_scalable_zero() { + %res = fcmp olt zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_olt_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_olt_fixed_one() { + %res = fcmp olt <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_olt_scalable_one +; CHECK: ret zeroinitializer +define @floatcmp_olt_scalable_one() { + %res = fcmp olt shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_ole_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_ole_fixed_zero() { + %res = fcmp ole <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ole_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_ole_scalable_zero() { + %res = fcmp ole zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_ole_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_ole_fixed_one() { + %res = fcmp ole <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ole_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_ole_scalable_one() { + %res = fcmp ole shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_one_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_one_fixed_zero() { + %res = fcmp one <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_one_scalable_zero +; CHECK: ret zeroinitializer +define @floatcmp_one_scalable_zero() { + %res = fcmp one zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_one_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_one_fixed_one() { + %res = fcmp one <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_one_scalable_one +; CHECK: ret zeroinitializer +define @floatcmp_one_scalable_one() { + %res = fcmp one shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_ord_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_ord_fixed_zero() { + %res = fcmp ord <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ord_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_ord_scalable_zero() { + %res = fcmp ord zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_ord_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_ord_fixed_one() { + %res = fcmp ord <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ord_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_ord_scalable_one() { + %res = fcmp ord shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_ueq_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_ueq_fixed_zero() { + %res = fcmp ueq <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ueq_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_ueq_scalable_zero() { + %res = fcmp ueq zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_ueq_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_ueq_fixed_one() { + %res = fcmp ueq <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ueq_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_ueq_scalable_one() { + %res = fcmp ueq shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_ugt_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_ugt_fixed_zero() { + %res = fcmp ugt <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ugt_scalable_zero +; CHECK: ret zeroinitializer +define @floatcmp_ugt_scalable_zero() { + %res = fcmp ugt zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_ugt_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_ugt_fixed_one() { + %res = fcmp ugt <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ugt_scalable_one +; CHECK: ret zeroinitializer +define @floatcmp_ugt_scalable_one() { + %res = fcmp ugt shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_uge_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_uge_fixed_zero() { + %res = fcmp uge <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_uge_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_uge_scalable_zero() { + %res = fcmp uge zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_uge_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_uge_fixed_one() { + %res = fcmp uge <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_uge_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_uge_scalable_one() { + %res = fcmp uge shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_ult_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_ult_fixed_zero() { + %res = fcmp ult <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ult_scalable_zero +; CHECK: ret zeroinitializer +define @floatcmp_ult_scalable_zero() { + %res = fcmp ult zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_ult_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_ult_fixed_one() { + %res = fcmp ult <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ult_scalable_one +; CHECK: ret zeroinitializer +define @floatcmp_ult_scalable_one() { + %res = fcmp ult shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_ule_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_ule_fixed_zero() { + %res = fcmp ule <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ule_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_ule_scalable_zero() { + %res = fcmp ule zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_ule_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_ule_fixed_one() { + %res = fcmp ule <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_ule_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_ule_scalable_one() { + %res = fcmp ule shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_une_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_une_fixed_zero() { + %res = fcmp une <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_une_scalable_zero +; CHECK: ret zeroinitializer +define @floatcmp_une_scalable_zero() { + %res = fcmp une zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_une_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_une_fixed_one() { + %res = fcmp une <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_une_scalable_one +; CHECK: ret zeroinitializer +define @floatcmp_une_scalable_one() { + %res = fcmp une shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_uno_fixed_zero +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_uno_fixed_zero() { + %res = fcmp uno <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_uno_scalable_zero +; CHECK: ret zeroinitializer +define @floatcmp_uno_scalable_zero() { + %res = fcmp uno zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_uno_fixed_one +; CHECK: ret <2 x i1> zeroinitializer +define <2 x i1> @floatcmp_uno_fixed_one() { + %res = fcmp uno <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_uno_scalable_one +; CHECK: ret zeroinitializer +define @floatcmp_uno_scalable_one() { + %res = fcmp uno shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} + + +; CHECK-LABEL: floatcmp_true_fixed_zero +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_true_fixed_zero() { + %res = fcmp true <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_true_scalable_zero +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_true_scalable_zero() { + %res = fcmp true zeroinitializer, zeroinitializer + ret %res +} + + +; CHECK-LABEL: floatcmp_true_fixed_one +; CHECK: ret <2 x i1> +define <2 x i1> @floatcmp_true_fixed_one() { + %res = fcmp true <2 x float> , + ret <2 x i1> %res +} + + +; CHECK-LABEL: floatcmp_true_scalable_one +; CHECK: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +define @floatcmp_true_scalable_one() { + %res = fcmp true shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, float 1.0, i32 0), undef, zeroinitializer) + ret %res +} +