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 @@ -2042,11 +2042,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()) @@ -2054,6 +2049,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/Transforms/InstSimplify/ConstProp/vscale.ll b/llvm/test/Transforms/InstSimplify/ConstProp/vscale.ll --- a/llvm/test/Transforms/InstSimplify/ConstProp/vscale.ll +++ b/llvm/test/Transforms/InstSimplify/ConstProp/vscale.ll @@ -208,7 +208,7 @@ define @load() { ; CHECK-LABEL: @load( -; CHECK-NEXT: [[R:%.*]] = load , * getelementptr (, * null, i64 1) +; CHECK-NEXT: [[R:%.*]] = load , * getelementptr (, * null, i64 1), align 16 ; CHECK-NEXT: ret [[R]] ; %r = load , * getelementptr (, * null, i64 1) @@ -262,7 +262,7 @@ define @icmp_zero() { ; CHECK-LABEL: @icmp_zero( -; CHECK-NEXT: ret icmp eq ( zeroinitializer, zeroinitializer) +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) ; %r = icmp eq zeroinitializer, zeroinitializer ret %r diff --git a/llvm/test/Transforms/InstSimplify/cmp-vec-fast-path.ll b/llvm/test/Transforms/InstSimplify/cmp-vec-fast-path.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/InstSimplify/cmp-vec-fast-path.ll @@ -0,0 +1,837 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; Check that cmp's of scalable vector splats are simplified + +; RUN: opt -instsimplify -S < %s | FileCheck %s + +define <2 x i1> @i32cmp_eq_fixed_zero() { +; CHECK-LABEL: @i32cmp_eq_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp eq <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_eq_scalable_zero() { +; CHECK-LABEL: @i32cmp_eq_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp eq zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_eq_fixed_one() { +; CHECK-LABEL: @i32cmp_eq_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp eq <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_eq_scalable_one() { +; CHECK-LABEL: @i32cmp_eq_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp eq shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @i32cmp_ne_fixed_zero() { +; CHECK-LABEL: @i32cmp_ne_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp ne <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_ne_scalable_zero() { +; CHECK-LABEL: @i32cmp_ne_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp ne zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_ne_fixed_one() { +; CHECK-LABEL: @i32cmp_ne_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp ne <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_ne_scalable_one() { +; CHECK-LABEL: @i32cmp_ne_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp ne shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @i32cmp_ugt_fixed_zero() { +; CHECK-LABEL: @i32cmp_ugt_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp ugt <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_ugt_scalable_zero() { +; CHECK-LABEL: @i32cmp_ugt_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp ugt zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_ugt_fixed_one() { +; CHECK-LABEL: @i32cmp_ugt_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp ugt <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_ugt_scalable_one() { +; CHECK-LABEL: @i32cmp_ugt_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp ugt shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @i32cmp_uge_fixed_zero() { +; CHECK-LABEL: @i32cmp_uge_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp uge <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_uge_scalable_zero() { +; CHECK-LABEL: @i32cmp_uge_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp uge zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_uge_fixed_one() { +; CHECK-LABEL: @i32cmp_uge_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp uge <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_uge_scalable_one() { +; CHECK-LABEL: @i32cmp_uge_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp uge shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @i32cmp_ult_fixed_zero() { +; CHECK-LABEL: @i32cmp_ult_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp ult <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_ult_scalable_zero() { +; CHECK-LABEL: @i32cmp_ult_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp ult zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_ult_fixed_one() { +; CHECK-LABEL: @i32cmp_ult_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp ult <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_ult_scalable_one() { +; CHECK-LABEL: @i32cmp_ult_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp ult shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @i32cmp_ule_fixed_zero() { +; CHECK-LABEL: @i32cmp_ule_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp ule <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_ule_scalable_zero() { +; CHECK-LABEL: @i32cmp_ule_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp ule zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_ule_fixed_one() { +; CHECK-LABEL: @i32cmp_ule_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp ule <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_ule_scalable_one() { +; CHECK-LABEL: @i32cmp_ule_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp ule shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @i32cmp_sgt_fixed_zero() { +; CHECK-LABEL: @i32cmp_sgt_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp sgt <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_sgt_scalable_zero() { +; CHECK-LABEL: @i32cmp_sgt_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp sgt zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_sgt_fixed_one() { +; CHECK-LABEL: @i32cmp_sgt_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp sgt <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_sgt_scalable_one() { +; CHECK-LABEL: @i32cmp_sgt_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp sgt shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @i32cmp_sge_fixed_zero() { +; CHECK-LABEL: @i32cmp_sge_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp sge <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_sge_scalable_zero() { +; CHECK-LABEL: @i32cmp_sge_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp sge zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_sge_fixed_one() { +; CHECK-LABEL: @i32cmp_sge_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp sge <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_sge_scalable_one() { +; CHECK-LABEL: @i32cmp_sge_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp sge shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @i32cmp_slt_fixed_zero() { +; CHECK-LABEL: @i32cmp_slt_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp slt <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_slt_scalable_zero() { +; CHECK-LABEL: @i32cmp_slt_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp slt zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_slt_fixed_one() { +; CHECK-LABEL: @i32cmp_slt_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = icmp slt <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_slt_scalable_one() { +; CHECK-LABEL: @i32cmp_slt_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %res = icmp slt shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @i32cmp_sle_fixed_zero() { +; CHECK-LABEL: @i32cmp_sle_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp sle <2 x i32> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @i32cmp_sle_scalable_zero() { +; CHECK-LABEL: @i32cmp_sle_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp sle zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @i32cmp_sle_fixed_one() { +; CHECK-LABEL: @i32cmp_sle_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = icmp sle <2 x i32> , + ret <2 x i1> %res +} + +define @i32cmp_sle_scalable_one() { +; CHECK-LABEL: @i32cmp_sle_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = icmp sle shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer), shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %res +} + +define <2 x i1> @floatcmp_false_fixed_zero() { +; CHECK-LABEL: @floatcmp_false_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp false <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_false_scalable_zero() { +; CHECK-LABEL: @floatcmp_false_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = fcmp false zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_false_fixed_one() { +; CHECK-LABEL: @floatcmp_false_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp false <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_false_scalable_one() { +; CHECK-LABEL: @floatcmp_false_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %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 +} + +define <2 x i1> @floatcmp_oeq_fixed_zero() { +; CHECK-LABEL: @floatcmp_oeq_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp oeq <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_oeq_scalable_zero() { +; CHECK-LABEL: @floatcmp_oeq_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = fcmp oeq zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_oeq_fixed_one() { +; CHECK-LABEL: @floatcmp_oeq_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp oeq <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_oeq_scalable_one() { +; CHECK-LABEL: @floatcmp_oeq_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %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 +} + +define <2 x i1> @floatcmp_ogt_fixed_zero() { +; CHECK-LABEL: @floatcmp_ogt_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp ogt <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_ogt_scalable_zero() { +; CHECK-LABEL: @floatcmp_ogt_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = fcmp ogt zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_ogt_fixed_one() { +; CHECK-LABEL: @floatcmp_ogt_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp ogt <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_ogt_scalable_one() { +; CHECK-LABEL: @floatcmp_ogt_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %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 +} + +define <2 x i1> @floatcmp_oge_fixed_zero() { +; CHECK-LABEL: @floatcmp_oge_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp oge <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_oge_scalable_zero() { +; CHECK-LABEL: @floatcmp_oge_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = fcmp oge zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_oge_fixed_one() { +; CHECK-LABEL: @floatcmp_oge_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp oge <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_oge_scalable_one() { +; CHECK-LABEL: @floatcmp_oge_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %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 +} + +define <2 x i1> @floatcmp_olt_fixed_zero() { +; CHECK-LABEL: @floatcmp_olt_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp olt <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_olt_scalable_zero() { +; CHECK-LABEL: @floatcmp_olt_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = fcmp olt zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_olt_fixed_one() { +; CHECK-LABEL: @floatcmp_olt_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp olt <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_olt_scalable_one() { +; CHECK-LABEL: @floatcmp_olt_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %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 +} + +define <2 x i1> @floatcmp_ole_fixed_zero() { +; CHECK-LABEL: @floatcmp_ole_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp ole <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_ole_scalable_zero() { +; CHECK-LABEL: @floatcmp_ole_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = fcmp ole zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_ole_fixed_one() { +; CHECK-LABEL: @floatcmp_ole_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp ole <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_ole_scalable_one() { +; CHECK-LABEL: @floatcmp_ole_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %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 +} + +define <2 x i1> @floatcmp_one_fixed_zero() { +; CHECK-LABEL: @floatcmp_one_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp one <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_one_scalable_zero() { +; CHECK-LABEL: @floatcmp_one_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = fcmp one zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_one_fixed_one() { +; CHECK-LABEL: @floatcmp_one_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp one <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_one_scalable_one() { +; CHECK-LABEL: @floatcmp_one_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %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 +} + +define <2 x i1> @floatcmp_ord_fixed_zero() { +; CHECK-LABEL: @floatcmp_ord_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp ord <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_ord_scalable_zero() { +; CHECK-LABEL: @floatcmp_ord_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = fcmp ord zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_ord_fixed_one() { +; CHECK-LABEL: @floatcmp_ord_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp ord <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_ord_scalable_one() { +; CHECK-LABEL: @floatcmp_ord_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %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 +} + +define <2 x i1> @floatcmp_ueq_fixed_zero() { +; CHECK-LABEL: @floatcmp_ueq_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp ueq <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_ueq_scalable_zero() { +; CHECK-LABEL: @floatcmp_ueq_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = fcmp ueq zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_ueq_fixed_one() { +; CHECK-LABEL: @floatcmp_ueq_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp ueq <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_ueq_scalable_one() { +; CHECK-LABEL: @floatcmp_ueq_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %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 +} + +define <2 x i1> @floatcmp_ugt_fixed_zero() { +; CHECK-LABEL: @floatcmp_ugt_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp ugt <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_ugt_scalable_zero() { +; CHECK-LABEL: @floatcmp_ugt_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = fcmp ugt zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_ugt_fixed_one() { +; CHECK-LABEL: @floatcmp_ugt_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp ugt <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_ugt_scalable_one() { +; CHECK-LABEL: @floatcmp_ugt_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %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 +} + +define <2 x i1> @floatcmp_uge_fixed_zero() { +; CHECK-LABEL: @floatcmp_uge_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp uge <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_uge_scalable_zero() { +; CHECK-LABEL: @floatcmp_uge_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = fcmp uge zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_uge_fixed_one() { +; CHECK-LABEL: @floatcmp_uge_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp uge <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_uge_scalable_one() { +; CHECK-LABEL: @floatcmp_uge_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %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 +} + +define <2 x i1> @floatcmp_ult_fixed_zero() { +; CHECK-LABEL: @floatcmp_ult_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp ult <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_ult_scalable_zero() { +; CHECK-LABEL: @floatcmp_ult_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = fcmp ult zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_ult_fixed_one() { +; CHECK-LABEL: @floatcmp_ult_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp ult <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_ult_scalable_one() { +; CHECK-LABEL: @floatcmp_ult_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %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 +} + +define <2 x i1> @floatcmp_ule_fixed_zero() { +; CHECK-LABEL: @floatcmp_ule_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp ule <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_ule_scalable_zero() { +; CHECK-LABEL: @floatcmp_ule_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = fcmp ule zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_ule_fixed_one() { +; CHECK-LABEL: @floatcmp_ule_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp ule <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_ule_scalable_one() { +; CHECK-LABEL: @floatcmp_ule_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %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 +} + +define <2 x i1> @floatcmp_une_fixed_zero() { +; CHECK-LABEL: @floatcmp_une_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp une <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_une_scalable_zero() { +; CHECK-LABEL: @floatcmp_une_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = fcmp une zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_une_fixed_one() { +; CHECK-LABEL: @floatcmp_une_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp une <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_une_scalable_one() { +; CHECK-LABEL: @floatcmp_une_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %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 +} + +define <2 x i1> @floatcmp_uno_fixed_zero() { +; CHECK-LABEL: @floatcmp_uno_fixed_zero( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp uno <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_uno_scalable_zero() { +; CHECK-LABEL: @floatcmp_uno_scalable_zero( +; CHECK-NEXT: ret zeroinitializer +; + %res = fcmp uno zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_uno_fixed_one() { +; CHECK-LABEL: @floatcmp_uno_fixed_one( +; CHECK-NEXT: ret <2 x i1> zeroinitializer +; + %res = fcmp uno <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_uno_scalable_one() { +; CHECK-LABEL: @floatcmp_uno_scalable_one( +; CHECK-NEXT: ret zeroinitializer +; + %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 +} + +define <2 x i1> @floatcmp_true_fixed_zero() { +; CHECK-LABEL: @floatcmp_true_fixed_zero( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp true <2 x float> zeroinitializer, zeroinitializer + ret <2 x i1> %res +} + +define @floatcmp_true_scalable_zero() { +; CHECK-LABEL: @floatcmp_true_scalable_zero( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %res = fcmp true zeroinitializer, zeroinitializer + ret %res +} + +define <2 x i1> @floatcmp_true_fixed_one() { +; CHECK-LABEL: @floatcmp_true_fixed_one( +; CHECK-NEXT: ret <2 x i1> +; + %res = fcmp true <2 x float> , + ret <2 x i1> %res +} + +define @floatcmp_true_scalable_one() { +; CHECK-LABEL: @floatcmp_true_scalable_one( +; CHECK-NEXT: ret shufflevector ( insertelement ( undef, i1 true, i32 0), undef, zeroinitializer) +; + %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 +} +