[clang] [CIR][X86] Add support for cmpps/cmppd* builtins (PR #228491)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 9 05:59:56 PST 2026


https://github.com/Fznamznon updated https://github.com/llvm/llvm-project/pull/228491

>From 273704459c02e8c085b9461791851c24f6141ddb Mon Sep 17 00:00:00 2001
From: Mariya Podchishchaeva <Mariya.Podchishchaeva at amd.com>
Date: Fri, 2 Oct 2026 10:12:22 -0500
Subject: [PATCH 1/5] [CIR][X86] Add support for cmpps/cmppd* builtins

This basically ports corresponding OGCG code with a following notes:
- CIR doesn't have unordered comparison kinds so the existing workaround
with inversion of ordered result is applied.
- Optional signaling attribute is added to veccmp op. Previously
signaling behavior was only derived from comparison kind, however the
builtins I'm adding have signaling and non signaling version for same
comparison kind.
- There is no TRUE/FALSE in CIR, so they are worked around which also
causes small mismatch with OGCG.
- There is a bit of a disrepancy in definition/doc of veccmp op doc, it
used to say that result is a vector of integers of the same width as the
operand, however that was already not the case for some other already
implemented cmp builtins since there was a creation of veccmp op with
vector of i1 result. I had to do that at some point too so I updated the
doc.

I used claude to help with testing and mechanical code changes.
---
 .../CIR/Dialect/Builder/CIRBaseBuilder.h      |   2 +-
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  17 +-
 clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp    | 188 +++++++-
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp       |   3 +
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp |   9 +-
 .../CIR/CodeGen/target-features-error-2.c     |   2 -
 .../CodeGenBuiltins/X86/cmp-bf16-builtins.c   |  43 ++
 .../CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c | 441 ++++++++++++++++++
 .../X86/cmp-fp16-512-builtins.c               | 117 +++++
 clang/test/CIR/IR/fenv.cir                    |   4 +
 clang/test/CIR/IR/invalid-cmp.cir             |  14 +
 clang/test/CIR/Lowering/fenv.cir              |  10 +
 12 files changed, 839 insertions(+), 11 deletions(-)
 create mode 100644 clang/test/CIR/CodeGenBuiltins/X86/cmp-bf16-builtins.c
 create mode 100644 clang/test/CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c
 create mode 100644 clang/test/CIR/CodeGenBuiltins/X86/cmp-fp16-512-builtins.c

diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index 36d583cfe9fbed..636e1f1a971772 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -917,7 +917,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
     if (cir::isFPOrVectorOfFPType(lhs.getType()))
       fenv = getConstrainedFPAttr();
     return cir::VecCmpOp::create(*this, loc, integralVecTy, kind, lhs, rhs,
-                                 fenv);
+                                 fenv, mlir::BoolAttr{});
   }
 
   mlir::Value createIsNaN(mlir::Location loc, mlir::Value operand) {
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 89e93a716424dd..b82f5f6c53f47b 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -6172,12 +6172,19 @@ def CIR_VecCmpOp : CIR_Op<"vec.cmp",
     The `cir.vec.cmp` operation does an element-wise comparison of two vectors
     of the same type. The result is a vector of the same size as the operands
     whose element type is the signed integral type that is the same size as the
-    element type of the operands. The values in the result are 0 or -1.
+    element type of the operands or a vector of one bit signed integers.
+    The values in the result are 0 or -1.
 
     The optional `fenv` attribute describes constraints on the floating-point
     handling of the operation. It is only valid for floating-point vector
     comparisons.
 
+    The optional `signaling` attribute overrides whether a floating-point
+    comparison raises an invalid exception for quiet NaN operands if fenv
+    attribute is present.
+    If `signaling` attribute is absent, the signaling behavior is determined by
+    the comparison kind.
+
     ```
     %eq = cir.vec.cmp(eq, %vec_a, %vec_b) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>
     %lt = cir.vec.cmp(lt, %vec_a, %vec_b) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>
@@ -6189,20 +6196,22 @@ def CIR_VecCmpOp : CIR_Op<"vec.cmp",
     CIR_CmpOpKindAttr:$kind,
     CIR_VectorType:$lhs,
     CIR_VectorType:$rhs,
-    OptionalAttr<CIR_FenvAttr>:$fenv
+    OptionalAttr<CIR_FenvAttr>:$fenv,
+    OptionalAttr<BoolAttr>:$signaling
   );
 
   let results = (outs CIR_VectorType:$result);
 
   let assemblyFormat = [{
     `(` enum($kind) `,` $lhs `,` $rhs `)` `:` qualified(type($lhs)) `,`
-    qualified(type($result)) (`fenv` `` $fenv^)? attr-dict
+    qualified(type($result)) (`fenv` `` $fenv^)? (`signaling` $signaling^)? attr-dict
   }];
 
   let builders = [
     OpBuilder<(ins "mlir::Type":$result, "cir::CmpOpKind":$kind,
                    "mlir::Value":$lhs, "mlir::Value":$rhs), [{
-      build($_builder, $_state, result, kind, lhs, rhs, cir::FenvAttr{});
+      build($_builder, $_state, result, kind, lhs, rhs, cir::FenvAttr{},
+            mlir::BoolAttr{});
     }]>
   ];
 
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index bc376e4aaab616..122cc72870727f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -1095,6 +1095,7 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
 
   // The operands of the builtin call
   llvm::SmallVector<mlir::Value> ops;
+  bool isMaskFCmp = false;
 
   // `ICEArguments` is a bitmap indicating whether the argument at the i-th bit
   // is required to be a constant integer expression.
@@ -2637,10 +2638,195 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
   case X86::BI__builtin_ia32_vcmpbf16512_mask:
   case X86::BI__builtin_ia32_vcmpbf16256_mask:
   case X86::BI__builtin_ia32_vcmpbf16128_mask:
+    isMaskFCmp = true;
+    [[fallthrough]];
   case X86::BI__builtin_ia32_cmpps:
   case X86::BI__builtin_ia32_cmpps256:
   case X86::BI__builtin_ia32_cmppd:
-  case X86::BI__builtin_ia32_cmppd256:
+  case X86::BI__builtin_ia32_cmppd256: {
+    mlir::Location loc = getLoc(expr->getExprLoc());
+
+    // The third argument is the comparison condition, an integer in the range
+    // [0, 31]. Predicates for 16-31 repeat the 0-15 predicates and differ only
+    // in signalling behavior.
+    unsigned cc =
+        ops[2].getDefiningOp<cir::ConstantOp>().getIntValue().getZExtValue() &
+        0x1f;
+
+    // CIR has no unordered predicates, so they are expressed as the inverse of
+    // the corresponding ordered predicate, e.g. ULT is !OGE.
+    cir::CmpOpKind pred = cir::CmpOpKind::eq;
+    bool shouldInvert = false;
+    bool isTrue = false;
+    bool isFalse = false;
+    bool isSignaling = false;
+    switch (cc & 0xf) {
+    case 0x00:
+      pred = cir::CmpOpKind::eq;
+      isSignaling = false;
+      break;
+    case 0x01:
+      pred = cir::CmpOpKind::lt;
+      isSignaling = true;
+      break;
+    case 0x02:
+      pred = cir::CmpOpKind::le;
+      isSignaling = true;
+      break;
+    case 0x03:
+      pred = cir::CmpOpKind::uno;
+      isSignaling = false;
+      break;
+    case 0x04:
+      pred = cir::CmpOpKind::ne;
+      isSignaling = false;
+      break;
+    case 0x05: // UGE = !LT
+      pred = cir::CmpOpKind::lt;
+      shouldInvert = true;
+      isSignaling = true;
+      break;
+    case 0x06: // UGT = !LE
+      pred = cir::CmpOpKind::le;
+      shouldInvert = true;
+      isSignaling = true;
+      break;
+    case 0x07: // ORD = !UNO
+      pred = cir::CmpOpKind::uno;
+      shouldInvert = true;
+      isSignaling = false;
+      break;
+    case 0x08: // UEQ != ONE
+      pred = cir::CmpOpKind::one;
+      shouldInvert = true;
+      isSignaling = false;
+      break;
+    case 0x09: // ULT != GE
+      pred = cir::CmpOpKind::ge;
+      shouldInvert = true;
+      isSignaling = true;
+      break;
+    case 0x0a: // ULE != GT
+      pred = cir::CmpOpKind::gt;
+      shouldInvert = true;
+      isSignaling = true;
+      break;
+    case 0x0b: // FALSE
+      isFalse = true;
+      isSignaling = false;
+      break;
+    case 0x0c:
+      pred = cir::CmpOpKind::one;
+      isSignaling = false;
+      break;
+    case 0x0d:
+      pred = cir::CmpOpKind::ge;
+      isSignaling = true;
+      break;
+    case 0x0e: // GT
+      pred = cir::CmpOpKind::gt;
+      isSignaling = true;
+      break;
+    case 0x0f: // TRUE
+      isTrue = true;
+      isSignaling = false;
+      break;
+    default:
+      llvm_unreachable("Unhandled cc");
+    }
+
+    // Invert the signalling behavior for 16-31.
+    if (cc & 0x10)
+      isSignaling = !isSignaling;
+
+    auto opsTy = cast<cir::VectorType>(ops[0].getType());
+    unsigned numElts = opsTy.getSize();
+
+    // If the predicate is true or false, or the builtin is mask enabled, and
+    // we're using constrained intrinsics, there is no compare operation we can
+    // use. Just use the legacy X86 specific intrinsic.
+    if (builder.getIsFPConstrained() && (isTrue || isFalse || isMaskFCmp)) {
+      llvm::StringRef intrinsicName;
+      switch (builtinID) {
+      default: llvm_unreachable("Unexpected builtin");
+      case X86::BI__builtin_ia32_cmpps:
+        intrinsicName = "x86.sse.cmp.ps";
+        break;
+      case X86::BI__builtin_ia32_cmpps256:
+        intrinsicName = "x86.avx.cmp.ps.256";
+        break;
+      case X86::BI__builtin_ia32_cmppd:
+        intrinsicName = "x86.sse2.cmp.pd";
+        break;
+      case X86::BI__builtin_ia32_cmppd256:
+        intrinsicName = "x86.avx.cmp.pd.256";
+        break;
+      case X86::BI__builtin_ia32_cmpph128_mask:
+        intrinsicName = "x86.avx512fp16.mask.cmp.ph.128";
+        break;
+      case X86::BI__builtin_ia32_cmpph256_mask:
+        intrinsicName = "x86.avx512fp16.mask.cmp.ph.256";
+        break;
+      case X86::BI__builtin_ia32_cmpph512_mask:
+        intrinsicName = "x86.avx512fp16.mask.cmp.ph.512";
+        break;
+      case X86::BI__builtin_ia32_cmpps512_mask:
+        intrinsicName = "x86.avx512.mask.cmp.ps.512";
+        break;
+      case X86::BI__builtin_ia32_cmppd512_mask:
+        intrinsicName = "x86.avx512.mask.cmp.pd.512";
+        break;
+      case X86::BI__builtin_ia32_cmpps128_mask:
+        intrinsicName = "x86.avx512.mask.cmp.ps.128";
+        break;
+      case X86::BI__builtin_ia32_cmpps256_mask:
+        intrinsicName = "x86.avx512.mask.cmp.ps.256";
+        break;
+      case X86::BI__builtin_ia32_cmppd128_mask:
+        intrinsicName = "x86.avx512.mask.cmp.pd.128";
+        break;
+      case X86::BI__builtin_ia32_cmppd256_mask:
+        intrinsicName = "x86.avx512.mask.cmp.pd.256";
+        break;
+      }
+
+      if (isMaskFCmp) {
+        ops[3] = getMaskVecValue(builder, loc, ops[3], numElts);
+        mlir::Value cmp = builder.emitIntrinsicCallOp(
+            loc, intrinsicName,
+            cir::VectorType::get(builder.getSIntNTy(1), numElts), ops);
+        return emitX86MaskedCompareResult(builder, cmp, numElts, nullptr, loc);
+      }
+
+      return builder.emitIntrinsicCallOp(loc, intrinsicName, ops[0].getType(),
+                                         ops);
+    }
+
+    unsigned width = builder.getCIRIntOrFloatBitWidth(opsTy.getElementType());
+    cir::IntType cmpEltTy = builder.getSIntNTy(isMaskFCmp ? 1 : width);
+    auto cmpTy = cir::VectorType::get(cmpEltTy, numElts);
+
+    mlir::Value cmp;
+    if (isFalse) {
+      cmp = builder.getNullValue(cmpTy, loc);
+    } else if (isTrue) {
+      llvm::APInt allOnes = llvm::APInt::getAllOnes(cmpEltTy.getWidth());
+      cmp = cir::VecSplatOp::create(
+          builder, loc, cmpTy, builder.getConstAPInt(loc, cmpEltTy, allOnes));
+    } else {
+      CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, expr);
+      cmp = cir::VecCmpOp::create(builder, loc, cmpTy, pred, ops[0], ops[1],
+                                  builder.getConstrainedFPAttr(),
+                                  builder.getBoolAttr(isSignaling));
+      if (shouldInvert)
+        cmp = builder.createNot(cmp);
+    }
+
+    if (isMaskFCmp)
+      return emitX86MaskedCompareResult(builder, cmp, numElts, ops[3], loc);
+
+    return builder.createBitcast(cmp, opsTy);
+  }
   case X86::BI__builtin_ia32_cmpeqss:
   case X86::BI__builtin_ia32_cmpltss:
   case X86::BI__builtin_ia32_cmpless:
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index fd6cbcc717b439..d54782c5ad4dcf 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -4084,6 +4084,9 @@ LogicalResult cir::VecCmpOp::verify() {
   if (getFenvAttr() && !cir::isFPOrVectorOfFPType(getLhs().getType()))
     return emitOpError()
            << "'fenv' is only valid for floating-point comparisons";
+  if (getSignalingAttr() && !cir::isFPOrVectorOfFPType(getLhs().getType()))
+    return emitOpError()
+           << "'signaling' is only valid for floating-point comparisons";
   return success();
 }
 
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 007b6734190562..d4305f64ed2105 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -3622,14 +3622,16 @@ static mlir::LLVM::CallIntrinsicOp
 createConstrainedFCmpCall(mlir::ConversionPatternRewriter &rewriter,
                           mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
                           cir::CmpOpKind kind, cir::FenvAttr fenv,
-                          mlir::Type llvmResTy) {
+                          mlir::Type llvmResTy,
+                          std::optional<bool> signaling = std::nullopt) {
   llvm::SmallVector<mlir::Value, 4> callOperands = {
       lhs, rhs,
       createFenvMetadataValue(rewriter, loc,
                               convertCmpKindToConstrainedFCmpPredicate(kind)),
       createFenvMetadataValue(rewriter, loc,
                               getConstrainedExceptMetadata(fenv))};
-  llvm::StringRef intrinsicName = isSignalingConstrainedFCmp(kind)
+  bool isSignaling = signaling.value_or(isSignalingConstrainedFCmp(kind));
+  llvm::StringRef intrinsicName = isSignaling
                                       ? "llvm.experimental.constrained.fcmps"
                                       : "llvm.experimental.constrained.fcmp";
   return createCallLLVMIntrinsicOp(rewriter, loc, intrinsicName, llvmResTy,
@@ -5070,7 +5072,8 @@ mlir::LogicalResult CIRToLLVMVecCmpOpLowering::matchAndRewrite(
                                            rewriter.getI1Type());
       bitResult = createConstrainedFCmpCall(rewriter, op.getLoc(),
                                             adaptor.getLhs(), adaptor.getRhs(),
-                                            op.getKind(), fenv, i1VecTy)
+                                            op.getKind(), fenv, i1VecTy,
+                                            op.getSignaling())
                       .getResult(0);
     } else {
       bitResult = mlir::LLVM::FCmpOp::create(
diff --git a/clang/test/CIR/CodeGen/target-features-error-2.c b/clang/test/CIR/CodeGen/target-features-error-2.c
index 6891e6c73a4e20..a467c1891963b5 100644
--- a/clang/test/CIR/CodeGen/target-features-error-2.c
+++ b/clang/test/CIR/CodeGen/target-features-error-2.c
@@ -17,8 +17,6 @@ int baz(__m256i a) {
 
 #if NEED_AVX_2
 __m128 need_avx(__m128 a, __m128 b) {
-  // expected-error at +2{{unimplemented X86 builtin call:}}
-  // expected-error at +1{{unimplemented builtin call:}}
   return _mm_cmp_ps(a, b, 8); // expected-error {{'__builtin_ia32_cmpps' needs target feature avx}}
 }
 #endif
diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cmp-bf16-builtins.c b/clang/test/CIR/CodeGenBuiltins/X86/cmp-bf16-builtins.c
new file mode 100644
index 00000000000000..51ce3b03cc84f5
--- /dev/null
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cmp-bf16-builtins.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -target-feature +avx10.2 -fclangir -emit-cir -o %t.cir -Wall -Werror
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -target-feature +avx10.2 -fclangir -emit-llvm -o %t.ll -Wall -Werror
+// RUN: FileCheck --check-prefix=CHECK --input-file=%t.ll %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -target-feature +avx10.2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK
+
+// Strict FP is not tested: classic codegen hits an unreachable for the bf16
+// compare builtins under -ffp-exception-behavior=strict.
+
+#include <immintrin.h>
+
+__mmask8 test_mm_cmp_pbh_mask(__m128bh a, __m128bh b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm_cmp_pbh_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.bf16>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm_cmp_pbh_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <8 x bfloat> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <8 x i1> %[[CMP]] to i8
+  return _mm_cmp_pbh_mask(a, b, _CMP_LT_OS);
+}
+
+__mmask16 test_mm256_cmp_pbh_mask(__m256bh a, __m256bh b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm256_cmp_pbh_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.bf16>, !cir.vector<16 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm256_cmp_pbh_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <16 x bfloat> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <16 x i1> %[[CMP]] to i16
+  return _mm256_cmp_pbh_mask(a, b, _CMP_LT_OS);
+}
+
+__mmask32 test_mm512_cmp_pbh_mask(__m512bh a, __m512bh b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_pbh_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<32 x !cir.bf16>, !cir.vector<32 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm512_cmp_pbh_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <32 x bfloat> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <32 x i1> %[[CMP]] to i32
+  return _mm512_cmp_pbh_mask(a, b, _CMP_LT_OS);
+}
diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c b/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c
new file mode 100644
index 00000000000000..5129d0dca338f2
--- /dev/null
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c
@@ -0,0 +1,441 @@
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -fclangir -emit-cir -o %t.cir -Wall -Werror
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -fclangir -emit-llvm -o %t.ll -Wall -Werror
+// RUN: FileCheck --check-prefixes=CHECK,LLVM --input-file=%t.ll %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,OGCG
+
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -ffp-exception-behavior=strict -fexperimental-strict-floating-point -fclangir -emit-cir -o %t.strict.cir -Wall -Werror
+// RUN: FileCheck --check-prefix=CIR-STRICT --input-file=%t.strict.cir %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -ffp-exception-behavior=strict -fexperimental-strict-floating-point -fclangir -emit-llvm -o %t.strict.ll -Wall -Werror
+// RUN: FileCheck --check-prefixes=CHECK-STRICT,LLVM-STRICT --input-file=%t.strict.ll %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK-STRICT,OGCG-STRICT
+
+#include <immintrin.h>
+
+__m128 test_cmp_ps_eq_oq(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_eq_oq
+  // CIR: %[[CMP:.*]] = cir.vec.cmp(eq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_eq_oq
+  // CIR-STRICT: cir.vec.cmp(eq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling false
+
+  // CHECK-LABEL: @test_cmp_ps_eq_oq
+  // CHECK: %[[CMP:.*]] = fcmp oeq <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // CHECK: bitcast <4 x i32> %[[SEXT]] to <4 x float>
+
+  // CHECK-STRICT-LABEL: @test_cmp_ps_eq_oq
+  // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"oeq", metadata !"fpexcept.strict")
+  return _mm_cmp_ps(a, b, _CMP_EQ_OQ);
+}
+
+// EQ_OS is signaling although eq is quiet by default.
+__m128 test_cmp_ps_eq_os(__m128 a, __m128 b) {
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_eq_os
+  // CIR-STRICT: cir.vec.cmp(eq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling true
+
+  // CHECK-STRICT-LABEL: @test_cmp_ps_eq_os
+  // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"oeq", metadata !"fpexcept.strict")
+  return _mm_cmp_ps(a, b, _CMP_EQ_OS);
+}
+
+// LT_OQ is quiet although lt is signaling by default.
+__m256d test_cmp_pd_lt_oq(__m256d a, __m256d b) {
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_pd_lt_oq
+  // CIR-STRICT: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.double>, !cir.vector<4 x !s64i> fenv<{{.*}}strict_except = true> signaling false
+
+  // CHECK-STRICT-LABEL: @test_cmp_pd_lt_oq
+  // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmp.v4f64(<4 x double> %{{.*}}, <4 x double> %{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
+  return _mm256_cmp_pd(a, b, _CMP_LT_OQ);
+}
+
+// NLT is the unordered UGE. CIR expresses it as the inverse of OLT.
+__m128 test_cmp_ps_nlt_us(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_nlt_us
+  // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-LABEL: @test_cmp_ps_nlt_us
+  // LLVM: %[[CMP:.*]] = fcmp olt <4 x float> %{{.*}}, %{{.*}}
+  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
+  // OGCG: %[[CMP:.*]] = fcmp uge <4 x float> %{{.*}}, %{{.*}}
+  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+
+  // CHECK-STRICT-LABEL: @test_cmp_ps_nlt_us
+  // LLVM-STRICT: %[[CMP:.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
+  // LLVM-STRICT: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // LLVM-STRICT: xor <4 x i32> %[[SEXT]], splat (i32 -1)
+  // OGCG-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uge", metadata !"fpexcept.strict")
+  return _mm_cmp_ps(a, b, _CMP_NLT_US);
+}
+
+// FALSE and TRUE
+__m128 test_cmp_ps_false_oq(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_false_oq
+  // CIR: %[[ZERO:.*]] = cir.const #cir.zero : !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[ZERO]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-LABEL: @test_cmp_ps_false_oq
+  // LLVM: store <4 x float> zeroinitializer
+  // OGCG: fcmp false <4 x float> %{{.*}}, %{{.*}}
+
+  // Under strict FP there is no compare to use, so the target intrinsic is
+  // called.
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_false_oq
+  // CIR-STRICT: cir.call_llvm_intrinsic "x86.sse.cmp.ps"
+
+  // CHECK-STRICT-LABEL: @test_cmp_ps_false_oq
+  // CHECK-STRICT: call <4 x float> @llvm.x86.sse.cmp.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 11)
+  return _mm_cmp_ps(a, b, _CMP_FALSE_OQ);
+}
+
+__m128 test_cmp_ps_true_uq(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_true_uq
+  // CIR: %[[M1:.*]] = cir.const #cir.int<-1> : !s32i
+  // CIR: %[[ONES:.*]] = cir.vec.splat %[[M1]] : !s32i, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[ONES]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-LABEL: @test_cmp_ps_true_uq
+  // LLVM: store <4 x float> splat (float -nan(0x3FFFFF))
+  // OGCG: fcmp true <4 x float> %{{.*}}, %{{.*}}
+  return _mm_cmp_ps(a, b, _CMP_TRUE_UQ);
+}
+
+// Masked compares.
+__mmask8 test_mm256_mask_cmp_ps_mask(__mmask8 m, __m256 a, __m256 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask
+  // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.and
+
+  // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <8 x float> %{{.*}}, %{{.*}}
+  // CHECK: %[[MASK:.*]] = bitcast i8 %{{.*}} to <8 x i1>
+  // CHECK: and <8 x i1> %[[CMP]], %[[MASK]]
+
+  // CHECK-STRICT-LABEL: @test_mm256_mask_cmp_ps_mask
+  // CHECK-STRICT: call <8 x i1> @llvm.x86.avx512.mask.cmp.ps.256(<8 x float> %{{.*}}, <8 x float> %{{.*}}, i32 1, <8 x i1> %{{.*}})
+  return _mm256_mask_cmp_ps_mask(m, a, b, _CMP_LT_OS);
+}
+
+// Remaining non-signaling-flipped predicates. Unordered predicates are
+// expressed in CIR as the inverse of the ordered ones.
+__m128 test_cmp_ps_lt_os(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_lt_os
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+
+  // CHECK-LABEL: @test_cmp_ps_lt_os
+  // CHECK: fcmp olt <4 x float> %{{.*}}, %{{.*}}
+  return _mm_cmp_ps(a, b, _CMP_LT_OS);
+}
+
+__m128 test_cmp_ps_le_os(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_le_os
+  // CIR: cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+
+  // CHECK-LABEL: @test_cmp_ps_le_os
+  // CHECK: fcmp ole <4 x float> %{{.*}}, %{{.*}}
+  return _mm_cmp_ps(a, b, _CMP_LE_OS);
+}
+
+__m128 test_cmp_ps_unord_q(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_unord_q
+  // CIR: cir.vec.cmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+
+  // CHECK-LABEL: @test_cmp_ps_unord_q
+  // CHECK: fcmp uno <4 x float> %{{.*}}, %{{.*}}
+  return _mm_cmp_ps(a, b, _CMP_UNORD_Q);
+}
+
+__m128 test_cmp_ps_neq_uq(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_neq_uq
+  // CIR: cir.vec.cmp(ne, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+
+  // CHECK-LABEL: @test_cmp_ps_neq_uq
+  // CHECK: fcmp une <4 x float> %{{.*}}, %{{.*}}
+  return _mm_cmp_ps(a, b, _CMP_NEQ_UQ);
+}
+
+__m128 test_cmp_ps_nle_us(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_nle_us
+  // CIR: %[[CMP:.*]] = cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-LABEL: @test_cmp_ps_nle_us
+  // LLVM: %[[CMP:.*]] = fcmp ole <4 x float> %{{.*}}, %{{.*}}
+  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
+  // OGCG: %[[CMP:.*]] = fcmp ugt <4 x float> %{{.*}}, %{{.*}}
+  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  return _mm_cmp_ps(a, b, _CMP_NLE_US);
+}
+
+__m128 test_cmp_ps_ord_q(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_ord_q
+  // CIR: %[[CMP:.*]] = cir.vec.cmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-LABEL: @test_cmp_ps_ord_q
+  // LLVM: %[[CMP:.*]] = fcmp uno <4 x float> %{{.*}}, %{{.*}}
+  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
+  // OGCG: %[[CMP:.*]] = fcmp ord <4 x float> %{{.*}}, %{{.*}}
+  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  return _mm_cmp_ps(a, b, _CMP_ORD_Q);
+}
+
+__m128 test_cmp_ps_eq_uq(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_eq_uq
+  // CIR: %[[CMP:.*]] = cir.vec.cmp(one, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-LABEL: @test_cmp_ps_eq_uq
+  // LLVM: %[[CMP:.*]] = fcmp one <4 x float> %{{.*}}, %{{.*}}
+  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
+  // OGCG: %[[CMP:.*]] = fcmp ueq <4 x float> %{{.*}}, %{{.*}}
+  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  return _mm_cmp_ps(a, b, _CMP_EQ_UQ);
+}
+
+__m128 test_cmp_ps_nge_us(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_nge_us
+  // CIR: %[[CMP:.*]] = cir.vec.cmp(ge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-LABEL: @test_cmp_ps_nge_us
+  // LLVM: %[[CMP:.*]] = fcmp oge <4 x float> %{{.*}}, %{{.*}}
+  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
+  // OGCG: %[[CMP:.*]] = fcmp ult <4 x float> %{{.*}}, %{{.*}}
+  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  return _mm_cmp_ps(a, b, _CMP_NGE_US);
+}
+
+__m128 test_cmp_ps_ngt_us(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_ngt_us
+  // CIR: %[[CMP:.*]] = cir.vec.cmp(gt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-LABEL: @test_cmp_ps_ngt_us
+  // LLVM: %[[CMP:.*]] = fcmp ogt <4 x float> %{{.*}}, %{{.*}}
+  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
+  // OGCG: %[[CMP:.*]] = fcmp ule <4 x float> %{{.*}}, %{{.*}}
+  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  return _mm_cmp_ps(a, b, _CMP_NGT_US);
+}
+
+__m128 test_cmp_ps_neq_oq(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_neq_oq
+  // CIR: cir.vec.cmp(one, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+
+  // CHECK-LABEL: @test_cmp_ps_neq_oq
+  // CHECK: fcmp one <4 x float> %{{.*}}, %{{.*}}
+  return _mm_cmp_ps(a, b, _CMP_NEQ_OQ);
+}
+
+__m128 test_cmp_ps_ge_os(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_ge_os
+  // CIR: cir.vec.cmp(ge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+
+  // CHECK-LABEL: @test_cmp_ps_ge_os
+  // CHECK: fcmp oge <4 x float> %{{.*}}, %{{.*}}
+  return _mm_cmp_ps(a, b, _CMP_GE_OS);
+}
+
+__m128 test_cmp_ps_gt_os(__m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_gt_os
+  // CIR: cir.vec.cmp(gt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+
+  // CHECK-LABEL: @test_cmp_ps_gt_os
+  // CHECK: fcmp ogt <4 x float> %{{.*}}, %{{.*}}
+  return _mm_cmp_ps(a, b, _CMP_GT_OS);
+}
+
+// Predicates 16-31 flip the signaling behavior of predicates 0-15.
+__m128 test_cmp_ps_neq_us(__m128 a, __m128 b) {
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_neq_us
+  // CIR-STRICT: cir.vec.cmp(ne, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling true
+
+  // CHECK-STRICT-LABEL: @test_cmp_ps_neq_us
+  // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"une", metadata !"fpexcept.strict")
+  return _mm_cmp_ps(a, b, _CMP_NEQ_US);
+}
+
+__m128 test_cmp_ps_unord_s(__m128 a, __m128 b) {
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_unord_s
+  // CIR-STRICT: cir.vec.cmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling true
+
+  // CHECK-STRICT-LABEL: @test_cmp_ps_unord_s
+  // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uno", metadata !"fpexcept.strict")
+  return _mm_cmp_ps(a, b, _CMP_UNORD_S);
+}
+
+__m128 test_cmp_ps_ge_oq(__m128 a, __m128 b) {
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_ge_oq
+  // CIR-STRICT: cir.vec.cmp(ge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling false
+
+  // CHECK-STRICT-LABEL: @test_cmp_ps_ge_oq
+  // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"oge", metadata !"fpexcept.strict")
+  return _mm_cmp_ps(a, b, _CMP_GE_OQ);
+}
+
+__m128 test_cmp_ps_nge_uq(__m128 a, __m128 b) {
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_nge_uq
+  // CIR-STRICT: %[[CMP:.*]] = cir.vec.cmp(ge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling false
+  // CIR-STRICT: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
+  // CIR-STRICT: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-STRICT-LABEL: @test_cmp_ps_nge_uq
+  // LLVM-STRICT: %[[CMP:.*]] = call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"oge", metadata !"fpexcept.strict")
+  // LLVM-STRICT: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // LLVM-STRICT: xor <4 x i32> %[[SEXT]], splat (i32 -1)
+  // OGCG-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ult", metadata !"fpexcept.strict")
+  return _mm_cmp_ps(a, b, _CMP_NGE_UQ);
+}
+
+__m128 test_cmp_ps_ord_s(__m128 a, __m128 b) {
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_ord_s
+  // CIR-STRICT: %[[CMP:.*]] = cir.vec.cmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling true
+  // CIR-STRICT: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
+  // CIR-STRICT: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+
+  // CHECK-STRICT-LABEL: @test_cmp_ps_ord_s
+  // LLVM-STRICT: %[[CMP:.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uno", metadata !"fpexcept.strict")
+  // LLVM-STRICT: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+  // LLVM-STRICT: xor <4 x i32> %[[SEXT]], splat (i32 -1)
+  // OGCG-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ord", metadata !"fpexcept.strict")
+  return _mm_cmp_ps(a, b, _CMP_ORD_S);
+}
+
+__m128d test_cmp_pd_lt_os(__m128d a, __m128d b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_pd_lt_os
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<2 x !cir.double>, !cir.vector<2 x !s64i>
+  // CIR: cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !cir.double>
+
+  // CHECK-LABEL: @test_cmp_pd_lt_os
+  // CHECK: fcmp olt <2 x double> %{{.*}}, %{{.*}}
+  return _mm_cmp_pd(a, b, _CMP_LT_OS);
+}
+
+__m256 test_cmp_ps256_le_os(__m256 a, __m256 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_cmp_ps256_le_os
+  // CIR: cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !s32i>
+  // CIR: cir.cast bitcast %{{.*}} : !cir.vector<8 x !s32i> -> !cir.vector<8 x !cir.float>
+
+  // CHECK-LABEL: @test_cmp_ps256_le_os
+  // CHECK: fcmp ole <8 x float> %{{.*}}, %{{.*}}
+  return _mm256_cmp_ps(a, b, _CMP_LE_OS);
+}
+
+__m128d test_cmp_pd_true_us_strict(__m128d a, __m128d b) {
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_pd_true_us_strict
+  // CIR-STRICT: cir.call_llvm_intrinsic "x86.sse2.cmp.pd"
+
+  // CHECK-STRICT-LABEL: @test_cmp_pd_true_us_strict
+  // CHECK-STRICT: call <2 x double> @llvm.x86.sse2.cmp.pd(<2 x double> %{{.*}}, <2 x double> %{{.*}}, i8 31)
+  return _mm_cmp_pd(a, b, _CMP_TRUE_US);
+}
+
+__mmask8 test_mm_mask_cmp_ps_mask(__mmask8 m, __m128 a, __m128 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm_mask_cmp_ps_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !cir.int<s, 1>>
+  // CIR: cir.and
+  // CIR: cir.vec.shuffle
+
+  // CHECK-LABEL: @test_mm_mask_cmp_ps_mask
+  // CHECK: fcmp olt <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: and <4 x i1>
+  // CHECK: shufflevector <4 x i1>
+  return _mm_mask_cmp_ps_mask(m, a, b, _CMP_LT_OS);
+}
+
+__mmask8 test_mm_mask_cmp_pd_mask(__mmask8 m, __m128d a, __m128d b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm_mask_cmp_pd_mask
+  // CIR: cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<2 x !cir.double>, !cir.vector<2 x !cir.int<s, 1>>
+  // CIR: cir.and
+
+  // CHECK-LABEL: @test_mm_mask_cmp_pd_mask
+  // CHECK: fcmp ole <2 x double> %{{.*}}, %{{.*}}
+  // CHECK: and <2 x i1>
+  return _mm_mask_cmp_pd_mask(m, a, b, _CMP_LE_OS);
+}
+
+__mmask8 test_mm256_mask_cmp_pd_mask(__mmask8 m, __m256d a, __m256d b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_pd_mask
+  // CIR: cir.vec.cmp(gt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.double>, !cir.vector<4 x !cir.int<s, 1>>
+  // CIR: cir.and
+
+  // CHECK-LABEL: @test_mm256_mask_cmp_pd_mask
+  // CHECK: fcmp ogt <4 x double> %{{.*}}, %{{.*}}
+  // CHECK: and <4 x i1>
+  return _mm256_mask_cmp_pd_mask(m, a, b, _CMP_GT_OS);
+}
+
+__mmask8 test_mm256_cmp_ps_mask(__m256 a, __m256 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm256_cmp_ps_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm256_cmp_ps_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <8 x float> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <8 x i1> %[[CMP]] to i8
+  return _mm256_cmp_ps_mask(a, b, _CMP_LT_OS);
+}
+
+__mmask8 test_mm256_mask_cmp_ps_mask_false(__mmask8 m, __m256 a, __m256 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask_false
+  // CIR: %[[ZERO:.*]] = cir.const #cir.zero : !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.and %{{.*}}, %[[ZERO]]
+
+  // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask_false
+  // LLVM: and <8 x i1> %{{.*}}, zeroinitializer
+  // OGCG: %[[CMP:.*]] = fcmp false <8 x float> %{{.*}}, %{{.*}}
+  // OGCG: and <8 x i1> %[[CMP]], %{{.*}}
+  return _mm256_mask_cmp_ps_mask(m, a, b, _CMP_FALSE_OQ);
+}
+
+__mmask8 test_mm256_mask_cmp_ps_mask_true(__mmask8 m, __m256 a, __m256 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask_true
+  // CIR: cir.const #cir.int<-1> : !cir.int<s, 1>
+  // CIR: cir.vec.splat %{{.*}} : !cir.int<s, 1>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.and
+
+  // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask_true
+  // LLVM: and <8 x i1> splat (i1 true), %{{.*}}
+  // OGCG: %[[CMP:.*]] = fcmp true <8 x float> %{{.*}}, %{{.*}}
+  // OGCG: and <8 x i1> %[[CMP]], %{{.*}}
+
+  // Under strict FP the target intrinsic is called.
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask_true
+  // CIR-STRICT: cir.call_llvm_intrinsic "x86.avx512.mask.cmp.ps.256"
+
+  // CHECK-STRICT-LABEL: @test_mm256_mask_cmp_ps_mask_true
+  // CHECK-STRICT: call <8 x i1> @llvm.x86.avx512.mask.cmp.ps.256(<8 x float> %{{.*}}, <8 x float> %{{.*}}, i32 15, <8 x i1> %{{.*}})
+  return _mm256_mask_cmp_ps_mask(m, a, b, _CMP_TRUE_UQ);
+}
+
+// Inversion also applies to masked compares: the compare produces a vector of
+// i1, which is inverted before the mask is applied.
+__mmask8 test_mm256_mask_cmp_ps_mask_nlt_us(__mmask8 m, __m256 a, __m256 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask_nlt_us
+  // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.and %[[NOT]], %{{.*}}
+
+  // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask_nlt_us
+  // LLVM: %[[CMP:.*]] = fcmp olt <8 x float> %{{.*}}, %{{.*}}
+  // LLVM: %[[NOT:.*]] = xor <8 x i1> %[[CMP]], splat (i1 true)
+  // LLVM: and <8 x i1> %[[NOT]], %{{.*}}
+  // OGCG: %[[CMP:.*]] = fcmp uge <8 x float> %{{.*}}, %{{.*}}
+  // OGCG: and <8 x i1> %[[CMP]], %{{.*}}
+  return _mm256_mask_cmp_ps_mask(m, a, b, _CMP_NLT_US);
+}
diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp16-512-builtins.c b/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp16-512-builtins.c
new file mode 100644
index 00000000000000..2ca425e4e5b79d
--- /dev/null
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp16-512-builtins.c
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -target-feature +avx512fp16 -fclangir -emit-cir -o %t.cir -Wall -Werror
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -target-feature +avx512fp16 -fclangir -emit-llvm -o %t.ll -Wall -Werror
+// RUN: FileCheck --check-prefix=CHECK --input-file=%t.ll %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -target-feature +avx512fp16 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK
+
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -target-feature +avx512fp16 -ffp-exception-behavior=strict -fexperimental-strict-floating-point -fclangir -emit-cir -o %t.strict.cir -Wall -Werror
+// RUN: FileCheck --check-prefix=CIR-STRICT --input-file=%t.strict.cir %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -target-feature +avx512fp16 -ffp-exception-behavior=strict -fexperimental-strict-floating-point -fclangir -emit-llvm -o %t.strict.ll -Wall -Werror
+// RUN: FileCheck --check-prefix=CHECK-STRICT --input-file=%t.strict.ll %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -target-feature +avx512fp16 -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-STRICT
+
+#include <immintrin.h>
+
+__mmask8 test_mm_cmp_ph_mask(__m128h a, __m128h b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm_cmp_ph_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.f16>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm_cmp_ph_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <8 x half> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <8 x i1> %[[CMP]] to i8
+
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_mm_cmp_ph_mask
+  // CIR-STRICT: cir.call_llvm_intrinsic "x86.avx512fp16.mask.cmp.ph.128"
+
+  // CHECK-STRICT-LABEL: @test_mm_cmp_ph_mask
+  // CHECK-STRICT: call <8 x i1> @llvm.x86.avx512fp16.mask.cmp.ph.128(<8 x half> %{{.*}}, <8 x half> %{{.*}}, i32 1, <8 x i1> splat (i1 true))
+  return _mm_cmp_ph_mask(a, b, _CMP_LT_OS);
+}
+
+__mmask16 test_mm256_cmp_ph_mask(__m256h a, __m256h b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm256_cmp_ph_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.f16>, !cir.vector<16 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm256_cmp_ph_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <16 x half> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <16 x i1> %[[CMP]] to i16
+
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_mm256_cmp_ph_mask
+  // CIR-STRICT: cir.call_llvm_intrinsic "x86.avx512fp16.mask.cmp.ph.256"
+
+  // CHECK-STRICT-LABEL: @test_mm256_cmp_ph_mask
+  // CHECK-STRICT: call <16 x i1> @llvm.x86.avx512fp16.mask.cmp.ph.256(<16 x half> %{{.*}}, <16 x half> %{{.*}}, i32 1, <16 x i1> splat (i1 true))
+  return _mm256_cmp_ph_mask(a, b, _CMP_LT_OS);
+}
+
+__mmask32 test_mm512_cmp_ph_mask(__m512h a, __m512h b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_ph_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<32 x !cir.f16>, !cir.vector<32 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm512_cmp_ph_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <32 x half> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <32 x i1> %[[CMP]] to i32
+
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_mm512_cmp_ph_mask
+  // CIR-STRICT: cir.call_llvm_intrinsic "x86.avx512fp16.mask.cmp.ph.512"
+
+  // CHECK-STRICT-LABEL: @test_mm512_cmp_ph_mask
+  // CHECK-STRICT: call <32 x i1> @llvm.x86.avx512fp16.mask.cmp.ph.512(<32 x half> %{{.*}}, <32 x half> %{{.*}}, i32 1, <32 x i1> splat (i1 true), i32 4)
+  return _mm512_cmp_ph_mask(a, b, _CMP_LT_OS);
+}
+
+__mmask16 test_mm512_cmp_ps_mask(__m512 a, __m512 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_ps_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.float>, !cir.vector<16 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm512_cmp_ps_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <16 x float> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <16 x i1> %[[CMP]] to i16
+
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_mm512_cmp_ps_mask
+  // CIR-STRICT: cir.call_llvm_intrinsic "x86.avx512.mask.cmp.ps.512"
+
+  // CHECK-STRICT-LABEL: @test_mm512_cmp_ps_mask
+  // CHECK-STRICT: call <16 x i1> @llvm.x86.avx512.mask.cmp.ps.512(<16 x float> %{{.*}}, <16 x float> %{{.*}}, i32 1, <16 x i1> splat (i1 true), i32 4)
+  return _mm512_cmp_ps_mask(a, b, _CMP_LT_OS);
+}
+
+__mmask8 test_mm512_cmp_pd_mask(__m512d a, __m512d b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_pd_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.double>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm512_cmp_pd_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <8 x double> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <8 x i1> %[[CMP]] to i8
+
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_mm512_cmp_pd_mask
+  // CIR-STRICT: cir.call_llvm_intrinsic "x86.avx512.mask.cmp.pd.512"
+
+  // CHECK-STRICT-LABEL: @test_mm512_cmp_pd_mask
+  // CHECK-STRICT: call <8 x i1> @llvm.x86.avx512.mask.cmp.pd.512(<8 x double> %{{.*}}, <8 x double> %{{.*}}, i32 1, <8 x i1> splat (i1 true), i32 4)
+  return _mm512_cmp_pd_mask(a, b, _CMP_LT_OS);
+}
+
+// The explicit rounding/SAE argument is passed through to the intrinsic only
+// under strict FP.
+__mmask16 test_mm512_cmp_round_ps_mask(__m512 a, __m512 b) {
+  // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_round_ps_mask
+  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.float>, !cir.vector<16 x !cir.int<s, 1>>
+  // CIR: cir.cast bitcast
+
+  // CHECK-LABEL: @test_mm512_cmp_round_ps_mask
+  // CHECK: %[[CMP:.*]] = fcmp olt <16 x float> %{{.*}}, %{{.*}}
+  // CHECK: bitcast <16 x i1> %[[CMP]] to i16
+
+  // CIR-STRICT-LABEL: cir.func {{.*}}@test_mm512_cmp_round_ps_mask
+  // CIR-STRICT: cir.call_llvm_intrinsic "x86.avx512.mask.cmp.ps.512"
+
+  // CHECK-STRICT-LABEL: @test_mm512_cmp_round_ps_mask
+  // CHECK-STRICT: call <16 x i1> @llvm.x86.avx512.mask.cmp.ps.512(<16 x float> %{{.*}}, <16 x float> %{{.*}}, i32 1, <16 x i1> splat (i1 true), i32 8)
+  return _mm512_cmp_round_ps_mask(a, b, _CMP_LT_OS, _MM_FROUND_NO_EXC);
+}
diff --git a/clang/test/CIR/IR/fenv.cir b/clang/test/CIR/IR/fenv.cir
index 2c938c2c74c70b..afcb6510c56426 100644
--- a/clang/test/CIR/IR/fenv.cir
+++ b/clang/test/CIR/IR/fenv.cir
@@ -137,5 +137,9 @@ cir.func @cmp_fenv(%a: !cir.float, %b: !cir.float,
   // CHECK: cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
   // CHECK-NOT: fenv
   %4 = cir.vec.cmp(le, %va, %vb) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CHECK: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling false
+  %5 = cir.vec.cmp(lt, %va, %vb) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling false
+  // CHECK: cir.vec.cmp(eq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling true
+  %6 = cir.vec.cmp(eq, %va, %vb) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling true
   cir.return
 }
diff --git a/clang/test/CIR/IR/invalid-cmp.cir b/clang/test/CIR/IR/invalid-cmp.cir
index 25e09700c2d72f..80798d6259f76e 100644
--- a/clang/test/CIR/IR/invalid-cmp.cir
+++ b/clang/test/CIR/IR/invalid-cmp.cir
@@ -35,3 +35,17 @@ module {
     cir.return
   }
 }
+
+// -----
+
+!s32i = !cir.int<s, 32>
+
+module {
+  cir.func @signaling_on_int_vec_cmp(%a: !cir.vector<4 x !s32i>,
+                                     %b: !cir.vector<4 x !s32i>) {
+    // expected-error at +1 {{'signaling' is only valid for floating-point comparisons}}
+    %0 = cir.vec.cmp(eq, %a, %b) : !cir.vector<4 x !s32i>,
+                                   !cir.vector<4 x !s32i> signaling true
+    cir.return
+  }
+}
diff --git a/clang/test/CIR/Lowering/fenv.cir b/clang/test/CIR/Lowering/fenv.cir
index d7ce72eadebc63..173fe8a9af3b28 100644
--- a/clang/test/CIR/Lowering/fenv.cir
+++ b/clang/test/CIR/Lowering/fenv.cir
@@ -229,6 +229,16 @@ module {
     // CHECK: llvm.fcmp "olt" %{{.*}}, %{{.*}} : vector<4xf32>
     // CHECK: llvm.sext %{{.*}} : vector<4xi1> to vector<4xi32>
     %2 = cir.vec.cmp(lt, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+    // The `signaling` attribute overrides the behavior implied by the kind.
+    // CHECK: llvm.mlir.metadata_as_value #llvm.md_string<"oeq">
+    // CHECK: llvm.call_intrinsic "llvm.experimental.constrained.fcmps"
+    %3 = cir.vec.cmp(eq, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling true
+    // CHECK: llvm.mlir.metadata_as_value #llvm.md_string<"olt">
+    // CHECK: llvm.call_intrinsic "llvm.experimental.constrained.fcmp"
+    %4 = cir.vec.cmp(lt, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling false
+    // Without `fenv`, `signaling` has no effect.
+    // CHECK: llvm.fcmp "oeq" %{{.*}}, %{{.*}} : vector<4xf32>
+    %5 = cir.vec.cmp(eq, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling true
     cir.return
   }
 

>From 1cfbf391f994c40886e25d88e0a7db9f2fa1b3b4 Mon Sep 17 00:00:00 2001
From: Mariya Podchishchaeva <Mariya.Podchishchaeva at amd.com>
Date: Mon, 26 Oct 2026 06:55:42 -0500
Subject: [PATCH 2/5] Fix build

---
 clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index 1e94d9919c2aaa..489c650e43088e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -2897,7 +2897,7 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
       isSignaling = !isSignaling;
 
     auto opsTy = cast<cir::VectorType>(ops[0].getType());
-    unsigned numElts = opsTy.getSize();
+    unsigned numElts = opsTy.getFixedSize();
 
     // If the predicate is true or false, or the builtin is mask enabled, and
     // we're using constrained intrinsics, there is no compare operation we can
@@ -2951,7 +2951,7 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
         ops[3] = getMaskVecValue(builder, loc, ops[3], numElts);
         mlir::Value cmp = builder.emitIntrinsicCallOp(
             loc, intrinsicName,
-            cir::VectorType::get(builder.getSIntNTy(1), numElts), ops);
+            cir::VectorType::getFixed(builder.getSIntNTy(1), numElts), ops);
         return emitX86MaskedCompareResult(builder, cmp, numElts, nullptr, loc);
       }
 
@@ -2961,7 +2961,7 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
 
     unsigned width = builder.getCIRIntOrFloatBitWidth(opsTy.getElementType());
     cir::IntType cmpEltTy = builder.getSIntNTy(isMaskFCmp ? 1 : width);
-    auto cmpTy = cir::VectorType::get(cmpEltTy, numElts);
+    auto cmpTy = cir::VectorType::getFixed(cmpEltTy, numElts);
 
     mlir::Value cmp;
     if (isFalse) {

>From 515acfc87f69b7171dbdde13506872e41ca265ce Mon Sep 17 00:00:00 2001
From: Mariya Podchishchaeva <Mariya.Podchishchaeva at amd.com>
Date: Mon, 9 Nov 2026 07:41:11 -0600
Subject: [PATCH 3/5] Use vec.fcmp op, claude-assisted

---
 .../CIR/Dialect/Builder/CIRBaseBuilder.h      |   3 +-
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  17 +-
 clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp    |  84 +++-----
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp       |   3 -
 .../CodeGenBuiltins/X86/cmp-bf16-builtins.c   |   6 +-
 .../CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c | 199 +++++++-----------
 .../X86/cmp-fp16-512-builtins.c               |  12 +-
 clang/test/CIR/IR/fenv.cir                    |   8 +-
 clang/test/CIR/IR/invalid-cmp.cir             |  14 --
 clang/test/CIR/Lowering/fenv.cir              |  14 +-
 10 files changed, 127 insertions(+), 233 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index 6676b405595aed..610152ff9485eb 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -1006,8 +1006,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
     cir::FenvAttr fenv;
     if (cir::isFPOrVectorOfFPType(lhs.getType()))
       fenv = getConstrainedFPAttr();
-    return cir::VecCmpOp::create(*this, loc, resultTy, kind, lhs, rhs, fenv,
-                                 mlir::BoolAttr{});
+    return cir::VecCmpOp::create(*this, loc, resultTy, kind, lhs, rhs, fenv);
   }
 
   /// Compares \p lhs and \p rhs element-wise.  Each result element is a
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 45b4d5a11378ba..1d8324a5917ecc 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -6601,19 +6601,12 @@ def CIR_VecCmpOp : CIR_Op<"vec.cmp",
     The `cir.vec.cmp` operation does an element-wise comparison of two vectors
     of the same type. The result is a vector of the same size as the operands
     whose element type is the signed integral type that is the same size as the
-    element type of the operands or a vector of one bit signed integers.
-    The values in the result are 0 or -1.
+    element type of the operands. The values in the result are 0 or -1.
 
     The optional `fenv` attribute describes constraints on the floating-point
     handling of the operation. It is only valid for floating-point vector
     comparisons.
 
-    The optional `signaling` attribute overrides whether a floating-point
-    comparison raises an invalid exception for quiet NaN operands if fenv
-    attribute is present.
-    If `signaling` attribute is absent, the signaling behavior is determined by
-    the comparison kind.
-
     ```
     %eq = cir.vec.cmp(eq, %vec_a, %vec_b) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>
     %lt = cir.vec.cmp(lt, %vec_a, %vec_b) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>
@@ -6625,22 +6618,20 @@ def CIR_VecCmpOp : CIR_Op<"vec.cmp",
     CIR_CmpOpKindAttr:$kind,
     CIR_VectorType:$lhs,
     CIR_VectorType:$rhs,
-    OptionalAttr<CIR_FenvAttr>:$fenv,
-    OptionalAttr<BoolAttr>:$signaling
+    OptionalAttr<CIR_FenvAttr>:$fenv
   );
 
   let results = (outs CIR_VectorType:$result);
 
   let assemblyFormat = [{
     `(` enum($kind) `,` $lhs `,` $rhs `)` `:` qualified(type($lhs)) `,`
-    qualified(type($result)) (`fenv` `` $fenv^)? (`signaling` $signaling^)? attr-dict
+    qualified(type($result)) (`fenv` `` $fenv^)? attr-dict
   }];
 
   let builders = [
     OpBuilder<(ins "mlir::Type":$result, "cir::CmpOpKind":$kind,
                    "mlir::Value":$lhs, "mlir::Value":$rhs), [{
-      build($_builder, $_state, result, kind, lhs, rhs, cir::FenvAttr{},
-            mlir::BoolAttr{});
+      build($_builder, $_state, result, kind, lhs, rhs, cir::FenvAttr{});
     }]>
   ];
 
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index 88be484f89f908..419f78818061cc 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -2909,83 +2909,68 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
         ops[2].getDefiningOp<cir::ConstantOp>().getIntValue().getZExtValue() &
         0x1f;
 
-    // CIR has no unordered predicates, so they are expressed as the inverse of
-    // the corresponding ordered predicate, e.g. ULT is !OGE.
-    cir::CmpOpKind pred = cir::CmpOpKind::eq;
-    bool shouldInvert = false;
+    cir::FCmpOpKind pred = cir::FCmpOpKind::oeq;
     bool isTrue = false;
     bool isFalse = false;
     bool isSignaling = false;
     switch (cc & 0xf) {
     case 0x00:
-      pred = cir::CmpOpKind::eq;
-      isSignaling = false;
+      pred = cir::FCmpOpKind::oeq;
       break;
     case 0x01:
-      pred = cir::CmpOpKind::lt;
+      pred = cir::FCmpOpKind::olt;
       isSignaling = true;
       break;
     case 0x02:
-      pred = cir::CmpOpKind::le;
+      pred = cir::FCmpOpKind::ole;
       isSignaling = true;
       break;
     case 0x03:
-      pred = cir::CmpOpKind::uno;
-      isSignaling = false;
+      pred = cir::FCmpOpKind::uno;
       break;
     case 0x04:
-      pred = cir::CmpOpKind::ne;
-      isSignaling = false;
+      pred = cir::FCmpOpKind::une;
       break;
-    case 0x05: // UGE = !LT
-      pred = cir::CmpOpKind::lt;
-      shouldInvert = true;
+    case 0x05:
+      pred = cir::FCmpOpKind::uge;
       isSignaling = true;
       break;
-    case 0x06: // UGT = !LE
-      pred = cir::CmpOpKind::le;
-      shouldInvert = true;
+    case 0x06:
+      pred = cir::FCmpOpKind::ugt;
       isSignaling = true;
       break;
-    case 0x07: // ORD = !UNO
-      pred = cir::CmpOpKind::uno;
-      shouldInvert = true;
-      isSignaling = false;
+    case 0x07:
+      pred = cir::FCmpOpKind::ord;
       break;
-    case 0x08: // UEQ != ONE
-      pred = cir::CmpOpKind::one;
-      shouldInvert = true;
-      isSignaling = false;
+    case 0x08:
+      pred = cir::FCmpOpKind::ueq;
       break;
-    case 0x09: // ULT != GE
-      pred = cir::CmpOpKind::ge;
-      shouldInvert = true;
+    case 0x09:
+      pred = cir::FCmpOpKind::ult;
       isSignaling = true;
       break;
-    case 0x0a: // ULE != GT
-      pred = cir::CmpOpKind::gt;
-      shouldInvert = true;
+    case 0x0a:
+      pred = cir::FCmpOpKind::ule;
       isSignaling = true;
       break;
     case 0x0b: // FALSE
+      pred = cir::FCmpOpKind::_false;
       isFalse = true;
-      isSignaling = false;
       break;
     case 0x0c:
-      pred = cir::CmpOpKind::one;
-      isSignaling = false;
+      pred = cir::FCmpOpKind::one;
       break;
     case 0x0d:
-      pred = cir::CmpOpKind::ge;
+      pred = cir::FCmpOpKind::oge;
       isSignaling = true;
       break;
-    case 0x0e: // GT
-      pred = cir::CmpOpKind::gt;
+    case 0x0e:
+      pred = cir::FCmpOpKind::ogt;
       isSignaling = true;
       break;
     case 0x0f: // TRUE
+      pred = cir::FCmpOpKind::_true;
       isTrue = true;
-      isSignaling = false;
       break;
     default:
       llvm_unreachable("Unhandled cc");
@@ -3004,7 +2989,8 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
     if (builder.getIsFPConstrained() && (isTrue || isFalse || isMaskFCmp)) {
       llvm::StringRef intrinsicName;
       switch (builtinID) {
-      default: llvm_unreachable("Unexpected builtin");
+      default:
+        llvm_unreachable("Unexpected builtin");
       case X86::BI__builtin_ia32_cmpps:
         intrinsicName = "x86.sse.cmp.ps";
         break;
@@ -3062,21 +3048,9 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
     cir::IntType cmpEltTy = builder.getSIntNTy(isMaskFCmp ? 1 : width);
     auto cmpTy = cir::VectorType::getFixed(cmpEltTy, numElts);
 
-    mlir::Value cmp;
-    if (isFalse) {
-      cmp = builder.getNullValue(cmpTy, loc);
-    } else if (isTrue) {
-      llvm::APInt allOnes = llvm::APInt::getAllOnes(cmpEltTy.getWidth());
-      cmp = cir::VecSplatOp::create(
-          builder, loc, cmpTy, builder.getConstAPInt(loc, cmpEltTy, allOnes));
-    } else {
-      CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, expr);
-      cmp = cir::VecCmpOp::create(builder, loc, cmpTy, pred, ops[0], ops[1],
-                                  builder.getConstrainedFPAttr(),
-                                  builder.getBoolAttr(isSignaling));
-      if (shouldInvert)
-        cmp = builder.createNot(cmp);
-    }
+    CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, expr);
+    mlir::Value cmp = builder.createVecFCompare(loc, cmpTy, pred, ops[0],
+                                                ops[1], isSignaling);
 
     if (isMaskFCmp)
       return emitX86MaskedCompareResult(builder, cmp, numElts, ops[3], loc);
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index 72c903e377c426..31f8c142acb3c3 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -4341,9 +4341,6 @@ LogicalResult cir::VecCmpOp::verify() {
   if (getFenvAttr() && !cir::isFPOrVectorOfFPType(getLhs().getType()))
     return emitOpError()
            << "'fenv' is only valid for floating-point comparisons";
-  if (getSignalingAttr() && !cir::isFPOrVectorOfFPType(getLhs().getType()))
-    return emitOpError()
-           << "'signaling' is only valid for floating-point comparisons";
   return success();
 }
 
diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cmp-bf16-builtins.c b/clang/test/CIR/CodeGenBuiltins/X86/cmp-bf16-builtins.c
index 51ce3b03cc84f5..85b2f90ae7c996 100644
--- a/clang/test/CIR/CodeGenBuiltins/X86/cmp-bf16-builtins.c
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cmp-bf16-builtins.c
@@ -11,7 +11,7 @@
 
 __mmask8 test_mm_cmp_pbh_mask(__m128bh a, __m128bh b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm_cmp_pbh_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.bf16>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.bf16>, !cir.vector<8 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm_cmp_pbh_mask
@@ -22,7 +22,7 @@ __mmask8 test_mm_cmp_pbh_mask(__m128bh a, __m128bh b) {
 
 __mmask16 test_mm256_cmp_pbh_mask(__m256bh a, __m256bh b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm256_cmp_pbh_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.bf16>, !cir.vector<16 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.bf16>, !cir.vector<16 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm256_cmp_pbh_mask
@@ -33,7 +33,7 @@ __mmask16 test_mm256_cmp_pbh_mask(__m256bh a, __m256bh b) {
 
 __mmask32 test_mm512_cmp_pbh_mask(__m512bh a, __m512bh b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_pbh_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<32 x !cir.bf16>, !cir.vector<32 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<32 x !cir.bf16>, !cir.vector<32 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm512_cmp_pbh_mask
diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c b/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c
index 5129d0dca338f2..743ae34caa7175 100644
--- a/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp-builtins.c
@@ -1,24 +1,24 @@
 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -fclangir -emit-cir -o %t.cir -Wall -Werror
 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -fclangir -emit-llvm -o %t.ll -Wall -Werror
-// RUN: FileCheck --check-prefixes=CHECK,LLVM --input-file=%t.ll %s
-// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,OGCG
+// RUN: FileCheck --check-prefix=CHECK --input-file=%t.ll %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK
 
 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -ffp-exception-behavior=strict -fexperimental-strict-floating-point -fclangir -emit-cir -o %t.strict.cir -Wall -Werror
 // RUN: FileCheck --check-prefix=CIR-STRICT --input-file=%t.strict.cir %s
 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -ffp-exception-behavior=strict -fexperimental-strict-floating-point -fclangir -emit-llvm -o %t.strict.ll -Wall -Werror
-// RUN: FileCheck --check-prefixes=CHECK-STRICT,LLVM-STRICT --input-file=%t.strict.ll %s
-// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK-STRICT,OGCG-STRICT
+// RUN: FileCheck --check-prefix=CHECK-STRICT --input-file=%t.strict.ll %s
+// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-STRICT
 
 #include <immintrin.h>
 
 __m128 test_cmp_ps_eq_oq(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_eq_oq
-  // CIR: %[[CMP:.*]] = cir.vec.cmp(eq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(oeq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
   // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_eq_oq
-  // CIR-STRICT: cir.vec.cmp(eq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling false
+  // CIR-STRICT: cir.vec.fcmp(oeq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true>
 
   // CHECK-LABEL: @test_cmp_ps_eq_oq
   // CHECK: %[[CMP:.*]] = fcmp oeq <4 x float> %{{.*}}, %{{.*}}
@@ -33,7 +33,7 @@ __m128 test_cmp_ps_eq_oq(__m128 a, __m128 b) {
 // EQ_OS is signaling although eq is quiet by default.
 __m128 test_cmp_ps_eq_os(__m128 a, __m128 b) {
   // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_eq_os
-  // CIR-STRICT: cir.vec.cmp(eq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling true
+  // CIR-STRICT: cir.vec.fcmp(oeq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling fenv<{{.*}}strict_except = true>
 
   // CHECK-STRICT-LABEL: @test_cmp_ps_eq_os
   // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"oeq", metadata !"fpexcept.strict")
@@ -43,44 +43,35 @@ __m128 test_cmp_ps_eq_os(__m128 a, __m128 b) {
 // LT_OQ is quiet although lt is signaling by default.
 __m256d test_cmp_pd_lt_oq(__m256d a, __m256d b) {
   // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_pd_lt_oq
-  // CIR-STRICT: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.double>, !cir.vector<4 x !s64i> fenv<{{.*}}strict_except = true> signaling false
+  // CIR-STRICT: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.double>, !cir.vector<4 x !s64i> fenv<{{.*}}strict_except = true>
 
   // CHECK-STRICT-LABEL: @test_cmp_pd_lt_oq
   // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmp.v4f64(<4 x double> %{{.*}}, <4 x double> %{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
   return _mm256_cmp_pd(a, b, _CMP_LT_OQ);
 }
 
-// NLT is the unordered UGE. CIR expresses it as the inverse of OLT.
 __m128 test_cmp_ps_nlt_us(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_nlt_us
-  // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
-  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
-  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(uge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-LABEL: @test_cmp_ps_nlt_us
-  // LLVM: %[[CMP:.*]] = fcmp olt <4 x float> %{{.*}}, %{{.*}}
-  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
-  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
-  // OGCG: %[[CMP:.*]] = fcmp uge <4 x float> %{{.*}}, %{{.*}}
-  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  // CHECK: %[[CMP:.*]] = fcmp uge <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: sext <4 x i1> %[[CMP]] to <4 x i32>
 
   // CHECK-STRICT-LABEL: @test_cmp_ps_nlt_us
-  // LLVM-STRICT: %[[CMP:.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
-  // LLVM-STRICT: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
-  // LLVM-STRICT: xor <4 x i32> %[[SEXT]], splat (i32 -1)
-  // OGCG-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uge", metadata !"fpexcept.strict")
+  // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uge", metadata !"fpexcept.strict")
   return _mm_cmp_ps(a, b, _CMP_NLT_US);
 }
 
 // FALSE and TRUE
 __m128 test_cmp_ps_false_oq(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_false_oq
-  // CIR: %[[ZERO:.*]] = cir.const #cir.zero : !cir.vector<4 x !s32i>
-  // CIR: cir.cast bitcast %[[ZERO]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(false, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-LABEL: @test_cmp_ps_false_oq
-  // LLVM: store <4 x float> zeroinitializer
-  // OGCG: fcmp false <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: fcmp false <4 x float> %{{.*}}, %{{.*}}
 
   // Under strict FP there is no compare to use, so the target intrinsic is
   // called.
@@ -94,20 +85,18 @@ __m128 test_cmp_ps_false_oq(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_true_uq(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_true_uq
-  // CIR: %[[M1:.*]] = cir.const #cir.int<-1> : !s32i
-  // CIR: %[[ONES:.*]] = cir.vec.splat %[[M1]] : !s32i, !cir.vector<4 x !s32i>
-  // CIR: cir.cast bitcast %[[ONES]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(true, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-LABEL: @test_cmp_ps_true_uq
-  // LLVM: store <4 x float> splat (float -nan(0x3FFFFF))
-  // OGCG: fcmp true <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: fcmp true <4 x float> %{{.*}}, %{{.*}}
   return _mm_cmp_ps(a, b, _CMP_TRUE_UQ);
 }
 
 // Masked compares.
 __mmask8 test_mm256_mask_cmp_ps_mask(__mmask8 m, __m256 a, __m256 b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask
-  // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
   // CIR: cir.and
 
   // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask
@@ -120,11 +109,10 @@ __mmask8 test_mm256_mask_cmp_ps_mask(__mmask8 m, __m256 a, __m256 b) {
   return _mm256_mask_cmp_ps_mask(m, a, b, _CMP_LT_OS);
 }
 
-// Remaining non-signaling-flipped predicates. Unordered predicates are
-// expressed in CIR as the inverse of the ordered ones.
+// Remaining non-signaling-flipped predicates.
 __m128 test_cmp_ps_lt_os(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_lt_os
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
 
   // CHECK-LABEL: @test_cmp_ps_lt_os
   // CHECK: fcmp olt <4 x float> %{{.*}}, %{{.*}}
@@ -133,7 +121,7 @@ __m128 test_cmp_ps_lt_os(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_le_os(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_le_os
-  // CIR: cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.vec.fcmp(ole, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
 
   // CHECK-LABEL: @test_cmp_ps_le_os
   // CHECK: fcmp ole <4 x float> %{{.*}}, %{{.*}}
@@ -142,7 +130,7 @@ __m128 test_cmp_ps_le_os(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_unord_q(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_unord_q
-  // CIR: cir.vec.cmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.vec.fcmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
 
   // CHECK-LABEL: @test_cmp_ps_unord_q
   // CHECK: fcmp uno <4 x float> %{{.*}}, %{{.*}}
@@ -151,7 +139,7 @@ __m128 test_cmp_ps_unord_q(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_neq_uq(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_neq_uq
-  // CIR: cir.vec.cmp(ne, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.vec.fcmp(une, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
 
   // CHECK-LABEL: @test_cmp_ps_neq_uq
   // CHECK: fcmp une <4 x float> %{{.*}}, %{{.*}}
@@ -160,82 +148,62 @@ __m128 test_cmp_ps_neq_uq(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_nle_us(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_nle_us
-  // CIR: %[[CMP:.*]] = cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
-  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
-  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(ugt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-LABEL: @test_cmp_ps_nle_us
-  // LLVM: %[[CMP:.*]] = fcmp ole <4 x float> %{{.*}}, %{{.*}}
-  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
-  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
-  // OGCG: %[[CMP:.*]] = fcmp ugt <4 x float> %{{.*}}, %{{.*}}
-  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  // CHECK: %[[CMP:.*]] = fcmp ugt <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: sext <4 x i1> %[[CMP]] to <4 x i32>
   return _mm_cmp_ps(a, b, _CMP_NLE_US);
 }
 
 __m128 test_cmp_ps_ord_q(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_ord_q
-  // CIR: %[[CMP:.*]] = cir.vec.cmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
-  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
-  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(ord, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-LABEL: @test_cmp_ps_ord_q
-  // LLVM: %[[CMP:.*]] = fcmp uno <4 x float> %{{.*}}, %{{.*}}
-  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
-  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
-  // OGCG: %[[CMP:.*]] = fcmp ord <4 x float> %{{.*}}, %{{.*}}
-  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  // CHECK: %[[CMP:.*]] = fcmp ord <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: sext <4 x i1> %[[CMP]] to <4 x i32>
   return _mm_cmp_ps(a, b, _CMP_ORD_Q);
 }
 
 __m128 test_cmp_ps_eq_uq(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_eq_uq
-  // CIR: %[[CMP:.*]] = cir.vec.cmp(one, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
-  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
-  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(ueq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-LABEL: @test_cmp_ps_eq_uq
-  // LLVM: %[[CMP:.*]] = fcmp one <4 x float> %{{.*}}, %{{.*}}
-  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
-  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
-  // OGCG: %[[CMP:.*]] = fcmp ueq <4 x float> %{{.*}}, %{{.*}}
-  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  // CHECK: %[[CMP:.*]] = fcmp ueq <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: sext <4 x i1> %[[CMP]] to <4 x i32>
   return _mm_cmp_ps(a, b, _CMP_EQ_UQ);
 }
 
 __m128 test_cmp_ps_nge_us(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_nge_us
-  // CIR: %[[CMP:.*]] = cir.vec.cmp(ge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
-  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
-  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(ult, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-LABEL: @test_cmp_ps_nge_us
-  // LLVM: %[[CMP:.*]] = fcmp oge <4 x float> %{{.*}}, %{{.*}}
-  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
-  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
-  // OGCG: %[[CMP:.*]] = fcmp ult <4 x float> %{{.*}}, %{{.*}}
-  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  // CHECK: %[[CMP:.*]] = fcmp ult <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: sext <4 x i1> %[[CMP]] to <4 x i32>
   return _mm_cmp_ps(a, b, _CMP_NGE_US);
 }
 
 __m128 test_cmp_ps_ngt_us(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_ngt_us
-  // CIR: %[[CMP:.*]] = cir.vec.cmp(gt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
-  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
-  // CIR: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(ule, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-LABEL: @test_cmp_ps_ngt_us
-  // LLVM: %[[CMP:.*]] = fcmp ogt <4 x float> %{{.*}}, %{{.*}}
-  // LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
-  // LLVM: xor <4 x i32> %[[SEXT]], splat (i32 -1)
-  // OGCG: %[[CMP:.*]] = fcmp ule <4 x float> %{{.*}}, %{{.*}}
-  // OGCG: sext <4 x i1> %[[CMP]] to <4 x i32>
+  // CHECK: %[[CMP:.*]] = fcmp ule <4 x float> %{{.*}}, %{{.*}}
+  // CHECK: sext <4 x i1> %[[CMP]] to <4 x i32>
   return _mm_cmp_ps(a, b, _CMP_NGT_US);
 }
 
 __m128 test_cmp_ps_neq_oq(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_neq_oq
-  // CIR: cir.vec.cmp(one, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.vec.fcmp(one, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
 
   // CHECK-LABEL: @test_cmp_ps_neq_oq
   // CHECK: fcmp one <4 x float> %{{.*}}, %{{.*}}
@@ -244,7 +212,7 @@ __m128 test_cmp_ps_neq_oq(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_ge_os(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_ge_os
-  // CIR: cir.vec.cmp(ge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.vec.fcmp(oge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
 
   // CHECK-LABEL: @test_cmp_ps_ge_os
   // CHECK: fcmp oge <4 x float> %{{.*}}, %{{.*}}
@@ -253,7 +221,7 @@ __m128 test_cmp_ps_ge_os(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_gt_os(__m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps_gt_os
-  // CIR: cir.vec.cmp(gt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+  // CIR: cir.vec.fcmp(ogt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
 
   // CHECK-LABEL: @test_cmp_ps_gt_os
   // CHECK: fcmp ogt <4 x float> %{{.*}}, %{{.*}}
@@ -263,7 +231,7 @@ __m128 test_cmp_ps_gt_os(__m128 a, __m128 b) {
 // Predicates 16-31 flip the signaling behavior of predicates 0-15.
 __m128 test_cmp_ps_neq_us(__m128 a, __m128 b) {
   // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_neq_us
-  // CIR-STRICT: cir.vec.cmp(ne, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling true
+  // CIR-STRICT: cir.vec.fcmp(une, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling fenv<{{.*}}strict_except = true>
 
   // CHECK-STRICT-LABEL: @test_cmp_ps_neq_us
   // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"une", metadata !"fpexcept.strict")
@@ -272,7 +240,7 @@ __m128 test_cmp_ps_neq_us(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_unord_s(__m128 a, __m128 b) {
   // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_unord_s
-  // CIR-STRICT: cir.vec.cmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling true
+  // CIR-STRICT: cir.vec.fcmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling fenv<{{.*}}strict_except = true>
 
   // CHECK-STRICT-LABEL: @test_cmp_ps_unord_s
   // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uno", metadata !"fpexcept.strict")
@@ -281,7 +249,7 @@ __m128 test_cmp_ps_unord_s(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_ge_oq(__m128 a, __m128 b) {
   // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_ge_oq
-  // CIR-STRICT: cir.vec.cmp(ge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling false
+  // CIR-STRICT: cir.vec.fcmp(oge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true>
 
   // CHECK-STRICT-LABEL: @test_cmp_ps_ge_oq
   // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"oge", metadata !"fpexcept.strict")
@@ -290,35 +258,27 @@ __m128 test_cmp_ps_ge_oq(__m128 a, __m128 b) {
 
 __m128 test_cmp_ps_nge_uq(__m128 a, __m128 b) {
   // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_nge_uq
-  // CIR-STRICT: %[[CMP:.*]] = cir.vec.cmp(ge, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling false
-  // CIR-STRICT: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
-  // CIR-STRICT: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR-STRICT: %[[CMP:.*]] = cir.vec.fcmp(ult, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true>
+  // CIR-STRICT: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-STRICT-LABEL: @test_cmp_ps_nge_uq
-  // LLVM-STRICT: %[[CMP:.*]] = call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"oge", metadata !"fpexcept.strict")
-  // LLVM-STRICT: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
-  // LLVM-STRICT: xor <4 x i32> %[[SEXT]], splat (i32 -1)
-  // OGCG-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ult", metadata !"fpexcept.strict")
+  // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ult", metadata !"fpexcept.strict")
   return _mm_cmp_ps(a, b, _CMP_NGE_UQ);
 }
 
 __m128 test_cmp_ps_ord_s(__m128 a, __m128 b) {
   // CIR-STRICT-LABEL: cir.func {{.*}}@test_cmp_ps_ord_s
-  // CIR-STRICT: %[[CMP:.*]] = cir.vec.cmp(uno, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<{{.*}}strict_except = true> signaling true
-  // CIR-STRICT: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<4 x !s32i>
-  // CIR-STRICT: cir.cast bitcast %[[NOT]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
+  // CIR-STRICT: %[[CMP:.*]] = cir.vec.fcmp(ord, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling fenv<{{.*}}strict_except = true>
+  // CIR-STRICT: cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float>
 
   // CHECK-STRICT-LABEL: @test_cmp_ps_ord_s
-  // LLVM-STRICT: %[[CMP:.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uno", metadata !"fpexcept.strict")
-  // LLVM-STRICT: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
-  // LLVM-STRICT: xor <4 x i32> %[[SEXT]], splat (i32 -1)
-  // OGCG-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ord", metadata !"fpexcept.strict")
+  // CHECK-STRICT: call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ord", metadata !"fpexcept.strict")
   return _mm_cmp_ps(a, b, _CMP_ORD_S);
 }
 
 __m128d test_cmp_pd_lt_os(__m128d a, __m128d b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_pd_lt_os
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<2 x !cir.double>, !cir.vector<2 x !s64i>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<2 x !cir.double>, !cir.vector<2 x !s64i>
   // CIR: cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !cir.double>
 
   // CHECK-LABEL: @test_cmp_pd_lt_os
@@ -328,7 +288,7 @@ __m128d test_cmp_pd_lt_os(__m128d a, __m128d b) {
 
 __m256 test_cmp_ps256_le_os(__m256 a, __m256 b) {
   // CIR-LABEL: cir.func {{.*}}@test_cmp_ps256_le_os
-  // CIR: cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !s32i>
+  // CIR: cir.vec.fcmp(ole, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !s32i>
   // CIR: cir.cast bitcast %{{.*}} : !cir.vector<8 x !s32i> -> !cir.vector<8 x !cir.float>
 
   // CHECK-LABEL: @test_cmp_ps256_le_os
@@ -347,7 +307,7 @@ __m128d test_cmp_pd_true_us_strict(__m128d a, __m128d b) {
 
 __mmask8 test_mm_mask_cmp_ps_mask(__mmask8 m, __m128 a, __m128 b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm_mask_cmp_ps_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !cir.int<s, 1>>
   // CIR: cir.and
   // CIR: cir.vec.shuffle
 
@@ -360,7 +320,7 @@ __mmask8 test_mm_mask_cmp_ps_mask(__mmask8 m, __m128 a, __m128 b) {
 
 __mmask8 test_mm_mask_cmp_pd_mask(__mmask8 m, __m128d a, __m128d b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm_mask_cmp_pd_mask
-  // CIR: cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<2 x !cir.double>, !cir.vector<2 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(ole, %{{.*}}, %{{.*}}) : !cir.vector<2 x !cir.double>, !cir.vector<2 x !cir.int<s, 1>>
   // CIR: cir.and
 
   // CHECK-LABEL: @test_mm_mask_cmp_pd_mask
@@ -371,7 +331,7 @@ __mmask8 test_mm_mask_cmp_pd_mask(__mmask8 m, __m128d a, __m128d b) {
 
 __mmask8 test_mm256_mask_cmp_pd_mask(__mmask8 m, __m256d a, __m256d b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_pd_mask
-  // CIR: cir.vec.cmp(gt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.double>, !cir.vector<4 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(ogt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.double>, !cir.vector<4 x !cir.int<s, 1>>
   // CIR: cir.and
 
   // CHECK-LABEL: @test_mm256_mask_cmp_pd_mask
@@ -382,7 +342,7 @@ __mmask8 test_mm256_mask_cmp_pd_mask(__mmask8 m, __m256d a, __m256d b) {
 
 __mmask8 test_mm256_cmp_ps_mask(__m256 a, __m256 b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm256_cmp_ps_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm256_cmp_ps_mask
@@ -393,26 +353,23 @@ __mmask8 test_mm256_cmp_ps_mask(__m256 a, __m256 b) {
 
 __mmask8 test_mm256_mask_cmp_ps_mask_false(__mmask8 m, __m256 a, __m256 b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask_false
-  // CIR: %[[ZERO:.*]] = cir.const #cir.zero : !cir.vector<8 x !cir.int<s, 1>>
-  // CIR: cir.and %{{.*}}, %[[ZERO]]
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(false, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.and %[[CMP]], %{{.*}}
 
   // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask_false
-  // LLVM: and <8 x i1> %{{.*}}, zeroinitializer
-  // OGCG: %[[CMP:.*]] = fcmp false <8 x float> %{{.*}}, %{{.*}}
-  // OGCG: and <8 x i1> %[[CMP]], %{{.*}}
+  // CHECK: %[[CMP:.*]] = fcmp false <8 x float> %{{.*}}, %{{.*}}
+  // CHECK: and <8 x i1> %[[CMP]], %{{.*}}
   return _mm256_mask_cmp_ps_mask(m, a, b, _CMP_FALSE_OQ);
 }
 
 __mmask8 test_mm256_mask_cmp_ps_mask_true(__mmask8 m, __m256 a, __m256 b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask_true
-  // CIR: cir.const #cir.int<-1> : !cir.int<s, 1>
-  // CIR: cir.vec.splat %{{.*}} : !cir.int<s, 1>, !cir.vector<8 x !cir.int<s, 1>>
-  // CIR: cir.and
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(true, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.and %[[CMP]], %{{.*}}
 
   // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask_true
-  // LLVM: and <8 x i1> splat (i1 true), %{{.*}}
-  // OGCG: %[[CMP:.*]] = fcmp true <8 x float> %{{.*}}, %{{.*}}
-  // OGCG: and <8 x i1> %[[CMP]], %{{.*}}
+  // CHECK: %[[CMP:.*]] = fcmp true <8 x float> %{{.*}}, %{{.*}}
+  // CHECK: and <8 x i1> %[[CMP]], %{{.*}}
 
   // Under strict FP the target intrinsic is called.
   // CIR-STRICT-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask_true
@@ -423,19 +380,13 @@ __mmask8 test_mm256_mask_cmp_ps_mask_true(__mmask8 m, __m256 a, __m256 b) {
   return _mm256_mask_cmp_ps_mask(m, a, b, _CMP_TRUE_UQ);
 }
 
-// Inversion also applies to masked compares: the compare produces a vector of
-// i1, which is inverted before the mask is applied.
 __mmask8 test_mm256_mask_cmp_ps_mask_nlt_us(__mmask8 m, __m256 a, __m256 b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm256_mask_cmp_ps_mask_nlt_us
-  // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
-  // CIR: %[[NOT:.*]] = cir.not %[[CMP]] : !cir.vector<8 x !cir.int<s, 1>>
-  // CIR: cir.and %[[NOT]], %{{.*}}
+  // CIR: %[[CMP:.*]] = cir.vec.fcmp(uge, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.float>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.and %[[CMP]], %{{.*}}
 
   // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask_nlt_us
-  // LLVM: %[[CMP:.*]] = fcmp olt <8 x float> %{{.*}}, %{{.*}}
-  // LLVM: %[[NOT:.*]] = xor <8 x i1> %[[CMP]], splat (i1 true)
-  // LLVM: and <8 x i1> %[[NOT]], %{{.*}}
-  // OGCG: %[[CMP:.*]] = fcmp uge <8 x float> %{{.*}}, %{{.*}}
-  // OGCG: and <8 x i1> %[[CMP]], %{{.*}}
+  // CHECK: %[[CMP:.*]] = fcmp uge <8 x float> %{{.*}}, %{{.*}}
+  // CHECK: and <8 x i1> %[[CMP]], %{{.*}}
   return _mm256_mask_cmp_ps_mask(m, a, b, _CMP_NLT_US);
 }
diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp16-512-builtins.c b/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp16-512-builtins.c
index 2ca425e4e5b79d..6d4722912d47c5 100644
--- a/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp16-512-builtins.c
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cmp-fp16-512-builtins.c
@@ -14,7 +14,7 @@
 
 __mmask8 test_mm_cmp_ph_mask(__m128h a, __m128h b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm_cmp_ph_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.f16>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.f16>, !cir.vector<8 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm_cmp_ph_mask
@@ -31,7 +31,7 @@ __mmask8 test_mm_cmp_ph_mask(__m128h a, __m128h b) {
 
 __mmask16 test_mm256_cmp_ph_mask(__m256h a, __m256h b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm256_cmp_ph_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.f16>, !cir.vector<16 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.f16>, !cir.vector<16 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm256_cmp_ph_mask
@@ -48,7 +48,7 @@ __mmask16 test_mm256_cmp_ph_mask(__m256h a, __m256h b) {
 
 __mmask32 test_mm512_cmp_ph_mask(__m512h a, __m512h b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_ph_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<32 x !cir.f16>, !cir.vector<32 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<32 x !cir.f16>, !cir.vector<32 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm512_cmp_ph_mask
@@ -65,7 +65,7 @@ __mmask32 test_mm512_cmp_ph_mask(__m512h a, __m512h b) {
 
 __mmask16 test_mm512_cmp_ps_mask(__m512 a, __m512 b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_ps_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.float>, !cir.vector<16 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.float>, !cir.vector<16 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm512_cmp_ps_mask
@@ -82,7 +82,7 @@ __mmask16 test_mm512_cmp_ps_mask(__m512 a, __m512 b) {
 
 __mmask8 test_mm512_cmp_pd_mask(__m512d a, __m512d b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_pd_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.double>, !cir.vector<8 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.double>, !cir.vector<8 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm512_cmp_pd_mask
@@ -101,7 +101,7 @@ __mmask8 test_mm512_cmp_pd_mask(__m512d a, __m512d b) {
 // under strict FP.
 __mmask16 test_mm512_cmp_round_ps_mask(__m512 a, __m512 b) {
   // CIR-LABEL: cir.func {{.*}}@test_mm512_cmp_round_ps_mask
-  // CIR: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.float>, !cir.vector<16 x !cir.int<s, 1>>
+  // CIR: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.float>, !cir.vector<16 x !cir.int<s, 1>>
   // CIR: cir.cast bitcast
 
   // CHECK-LABEL: @test_mm512_cmp_round_ps_mask
diff --git a/clang/test/CIR/IR/fenv.cir b/clang/test/CIR/IR/fenv.cir
index afcb6510c56426..d7979ab7f81a46 100644
--- a/clang/test/CIR/IR/fenv.cir
+++ b/clang/test/CIR/IR/fenv.cir
@@ -137,9 +137,9 @@ cir.func @cmp_fenv(%a: !cir.float, %b: !cir.float,
   // CHECK: cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
   // CHECK-NOT: fenv
   %4 = cir.vec.cmp(le, %va, %vb) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
-  // CHECK: cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling false
-  %5 = cir.vec.cmp(lt, %va, %vb) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling false
-  // CHECK: cir.vec.cmp(eq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling true
-  %6 = cir.vec.cmp(eq, %va, %vb) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling true
+  // CHECK: cir.vec.fcmp(olt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true>
+  %5 = cir.vec.fcmp(olt, %va, %vb) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true>
+  // CHECK: cir.vec.fcmp(oeq, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling fenv<strict_except = true>
+  %6 = cir.vec.fcmp(oeq, %va, %vb) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling fenv<strict_except = true>
   cir.return
 }
diff --git a/clang/test/CIR/IR/invalid-cmp.cir b/clang/test/CIR/IR/invalid-cmp.cir
index 80798d6259f76e..25e09700c2d72f 100644
--- a/clang/test/CIR/IR/invalid-cmp.cir
+++ b/clang/test/CIR/IR/invalid-cmp.cir
@@ -35,17 +35,3 @@ module {
     cir.return
   }
 }
-
-// -----
-
-!s32i = !cir.int<s, 32>
-
-module {
-  cir.func @signaling_on_int_vec_cmp(%a: !cir.vector<4 x !s32i>,
-                                     %b: !cir.vector<4 x !s32i>) {
-    // expected-error at +1 {{'signaling' is only valid for floating-point comparisons}}
-    %0 = cir.vec.cmp(eq, %a, %b) : !cir.vector<4 x !s32i>,
-                                   !cir.vector<4 x !s32i> signaling true
-    cir.return
-  }
-}
diff --git a/clang/test/CIR/Lowering/fenv.cir b/clang/test/CIR/Lowering/fenv.cir
index 1c9198736356df..a19ed59ca235b2 100644
--- a/clang/test/CIR/Lowering/fenv.cir
+++ b/clang/test/CIR/Lowering/fenv.cir
@@ -219,26 +219,22 @@ module {
     // CHECK: %[[EB:.*]] = llvm.mlir.metadata_as_value #llvm.md_string<"fpexcept.strict">
     // CHECK: %[[CMP:.*]] = llvm.call_intrinsic "llvm.experimental.constrained.fcmps"(%{{.*}}, %{{.*}}, %[[PRED]], %[[EB]]) : (vector<4xf32>, vector<4xf32>, !llvm.metadata, !llvm.metadata) -> vector<4xi1>
     // CHECK: llvm.sext %[[CMP]] : vector<4xi1> to vector<4xi32>
-    %0 = cir.vec.cmp(gt, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+    %0 = cir.vec.fcmp(ogt, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling
          fenv<strict_except = true>
     // CHECK: %[[PRED_EQ:.*]] = llvm.mlir.metadata_as_value #llvm.md_string<"oeq">
     // CHECK: %[[CMP_EQ:.*]] = llvm.call_intrinsic "llvm.experimental.constrained.fcmp"(%{{.*}}, %{{.*}}, %[[PRED_EQ]], %{{.*}}) : (vector<4xf32>, vector<4xf32>, !llvm.metadata, !llvm.metadata) -> vector<4xi1>
     // CHECK: llvm.sext %[[CMP_EQ]] : vector<4xi1> to vector<4xi32>
-    %1 = cir.vec.cmp(eq, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
+    %1 = cir.vec.fcmp(oeq, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
          fenv<strict_except = true>
     // CHECK: llvm.fcmp "olt" %{{.*}}, %{{.*}} : vector<4xf32>
     // CHECK: llvm.sext %{{.*}} : vector<4xi1> to vector<4xi32>
-    %2 = cir.vec.cmp(lt, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
-    // The `signaling` attribute overrides the behavior implied by the kind.
-    // CHECK: llvm.mlir.metadata_as_value #llvm.md_string<"oeq">
-    // CHECK: llvm.call_intrinsic "llvm.experimental.constrained.fcmps"
-    %3 = cir.vec.cmp(eq, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling true
+    %2 = cir.vec.fcmp(olt, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i>
     // CHECK: llvm.mlir.metadata_as_value #llvm.md_string<"olt">
     // CHECK: llvm.call_intrinsic "llvm.experimental.constrained.fcmp"
-    %4 = cir.vec.cmp(lt, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true> signaling false
+    %3 = cir.vec.fcmp(olt, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> fenv<strict_except = true>
     // Without `fenv`, `signaling` has no effect.
     // CHECK: llvm.fcmp "oeq" %{{.*}}, %{{.*}} : vector<4xf32>
-    %5 = cir.vec.cmp(eq, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling true
+    %4 = cir.vec.fcmp(oeq, %a, %b) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> signaling
     cir.return
   }
 

>From 3466f6e998175060f13336375787e153a7f9186b Mon Sep 17 00:00:00 2001
From: Mariya Podchishchaeva <Mariya.Podchishchaeva at amd.com>
Date: Mon, 9 Nov 2026 07:54:07 -0600
Subject: [PATCH 4/5] Info struct, claude-assisted

---
 clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp | 167 +++++++++++----------
 1 file changed, 91 insertions(+), 76 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index 419f78818061cc..c6467034a50bba 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -43,6 +43,90 @@ static mlir::Value emitVectorFCmp(CIRGenFunction &cgf, const CallExpr &expr,
   return builder.createBitcast(cmp, ops[0].getType());
 }
 
+struct X86FCmpInfo {
+  cir::FCmpOpKind pred;
+  bool isSignaling;
+};
+
+/// Decodes comparison condition of x86 cmppps/cmppd* builtins which is an
+/// integer in the range [0, 31]. Predicates for 16-31 repeat the 0-15
+/// predicates and differ only in signaling behavior.
+static X86FCmpInfo getX86FCmpInfo(unsigned cc) {
+  X86FCmpInfo info;
+  switch (cc & 0xf) {
+  case 0x00:
+    info.pred = cir::FCmpOpKind::oeq;
+    info.isSignaling = false;
+    break;
+  case 0x01:
+    info.pred = cir::FCmpOpKind::olt;
+    info.isSignaling = true;
+    break;
+  case 0x02:
+    info.pred = cir::FCmpOpKind::ole;
+    info.isSignaling = true;
+    break;
+  case 0x03:
+    info.pred = cir::FCmpOpKind::uno;
+    info.isSignaling = false;
+    break;
+  case 0x04:
+    info.pred = cir::FCmpOpKind::une;
+    info.isSignaling = false;
+    break;
+  case 0x05:
+    info.pred = cir::FCmpOpKind::uge;
+    info.isSignaling = true;
+    break;
+  case 0x06:
+    info.pred = cir::FCmpOpKind::ugt;
+    info.isSignaling = true;
+    break;
+  case 0x07:
+    info.pred = cir::FCmpOpKind::ord;
+    info.isSignaling = false;
+    break;
+  case 0x08:
+    info.pred = cir::FCmpOpKind::ueq;
+    info.isSignaling = false;
+    break;
+  case 0x09:
+    info.pred = cir::FCmpOpKind::ult;
+    info.isSignaling = true;
+    break;
+  case 0x0a:
+    info.pred = cir::FCmpOpKind::ule;
+    info.isSignaling = true;
+    break;
+  case 0x0b:
+    info.pred = cir::FCmpOpKind::_false;
+    info.isSignaling = false;
+    break;
+  case 0x0c:
+    info.pred = cir::FCmpOpKind::one;
+    info.isSignaling = false;
+    break;
+  case 0x0d:
+    info.pred = cir::FCmpOpKind::oge;
+    info.isSignaling = true;
+    break;
+  case 0x0e:
+    info.pred = cir::FCmpOpKind::ogt;
+    info.isSignaling = true;
+    break;
+  case 0x0f:
+    info.pred = cir::FCmpOpKind::_true;
+    info.isSignaling = false;
+    break;
+  default:
+    llvm_unreachable("Unhandled cc");
+  }
+
+  if (cc & 0x10)
+    info.isSignaling = !info.isSignaling;
+  return info;
+}
+
 static mlir::Value getMaskVecValue(CIRGenBuilderTy &builder, mlir::Location loc,
                                    mlir::Value mask, unsigned numElems) {
   auto maskTy = cir::VectorType::getFixed(
@@ -2902,83 +2986,12 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
   case X86::BI__builtin_ia32_cmppd256: {
     mlir::Location loc = getLoc(expr->getExprLoc());
 
-    // The third argument is the comparison condition, an integer in the range
-    // [0, 31]. Predicates for 16-31 repeat the 0-15 predicates and differ only
-    // in signalling behavior.
+    // The third argument is the comparison condition.
     unsigned cc =
         ops[2].getDefiningOp<cir::ConstantOp>().getIntValue().getZExtValue() &
         0x1f;
 
-    cir::FCmpOpKind pred = cir::FCmpOpKind::oeq;
-    bool isTrue = false;
-    bool isFalse = false;
-    bool isSignaling = false;
-    switch (cc & 0xf) {
-    case 0x00:
-      pred = cir::FCmpOpKind::oeq;
-      break;
-    case 0x01:
-      pred = cir::FCmpOpKind::olt;
-      isSignaling = true;
-      break;
-    case 0x02:
-      pred = cir::FCmpOpKind::ole;
-      isSignaling = true;
-      break;
-    case 0x03:
-      pred = cir::FCmpOpKind::uno;
-      break;
-    case 0x04:
-      pred = cir::FCmpOpKind::une;
-      break;
-    case 0x05:
-      pred = cir::FCmpOpKind::uge;
-      isSignaling = true;
-      break;
-    case 0x06:
-      pred = cir::FCmpOpKind::ugt;
-      isSignaling = true;
-      break;
-    case 0x07:
-      pred = cir::FCmpOpKind::ord;
-      break;
-    case 0x08:
-      pred = cir::FCmpOpKind::ueq;
-      break;
-    case 0x09:
-      pred = cir::FCmpOpKind::ult;
-      isSignaling = true;
-      break;
-    case 0x0a:
-      pred = cir::FCmpOpKind::ule;
-      isSignaling = true;
-      break;
-    case 0x0b: // FALSE
-      pred = cir::FCmpOpKind::_false;
-      isFalse = true;
-      break;
-    case 0x0c:
-      pred = cir::FCmpOpKind::one;
-      break;
-    case 0x0d:
-      pred = cir::FCmpOpKind::oge;
-      isSignaling = true;
-      break;
-    case 0x0e:
-      pred = cir::FCmpOpKind::ogt;
-      isSignaling = true;
-      break;
-    case 0x0f: // TRUE
-      pred = cir::FCmpOpKind::_true;
-      isTrue = true;
-      break;
-    default:
-      llvm_unreachable("Unhandled cc");
-    }
-
-    // Invert the signalling behavior for 16-31.
-    if (cc & 0x10)
-      isSignaling = !isSignaling;
+    X86FCmpInfo cmpInfo = getX86FCmpInfo(cc);
 
     auto opsTy = cast<cir::VectorType>(ops[0].getType());
     unsigned numElts = opsTy.getFixedSize();
@@ -2986,7 +2999,9 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
     // If the predicate is true or false, or the builtin is mask enabled, and
     // we're using constrained intrinsics, there is no compare operation we can
     // use. Just use the legacy X86 specific intrinsic.
-    if (builder.getIsFPConstrained() && (isTrue || isFalse || isMaskFCmp)) {
+    if (builder.getIsFPConstrained() &&
+        (cmpInfo.pred == cir::FCmpOpKind::_true ||
+         cmpInfo.pred == cir::FCmpOpKind::_false || isMaskFCmp)) {
       llvm::StringRef intrinsicName;
       switch (builtinID) {
       default:
@@ -3049,8 +3064,8 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
     auto cmpTy = cir::VectorType::getFixed(cmpEltTy, numElts);
 
     CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, expr);
-    mlir::Value cmp = builder.createVecFCompare(loc, cmpTy, pred, ops[0],
-                                                ops[1], isSignaling);
+    mlir::Value cmp = builder.createVecFCompare(
+        loc, cmpTy, cmpInfo.pred, ops[0], ops[1], cmpInfo.isSignaling);
 
     if (isMaskFCmp)
       return emitX86MaskedCompareResult(builder, cmp, numElts, ops[3], loc);

>From b3c3b08d23dd43106e62d4a06c090b0ffa84d69d Mon Sep 17 00:00:00 2001
From: Mariya Podchishchaeva <Mariya.Podchishchaeva at amd.com>
Date: Mon, 9 Nov 2026 07:59:21 -0600
Subject: [PATCH 5/5] Refactor another switch too, claude-assisted

---
 clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp | 80 ++++++++++------------
 1 file changed, 36 insertions(+), 44 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index c6467034a50bba..62be539f184aea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -127,6 +127,41 @@ static X86FCmpInfo getX86FCmpInfo(unsigned cc) {
   return info;
 }
 
+/// Returns the legacy x86 intrinsic that implements the given x86 cmppps/cmppd*
+/// builtin.
+static llvm::StringRef getX86FCmpIntrinsicName(unsigned builtinID) {
+  switch (builtinID) {
+  default:
+    llvm_unreachable("Unexpected builtin");
+  case X86::BI__builtin_ia32_cmpps:
+    return "x86.sse.cmp.ps";
+  case X86::BI__builtin_ia32_cmpps256:
+    return "x86.avx.cmp.ps.256";
+  case X86::BI__builtin_ia32_cmppd:
+    return "x86.sse2.cmp.pd";
+  case X86::BI__builtin_ia32_cmppd256:
+    return "x86.avx.cmp.pd.256";
+  case X86::BI__builtin_ia32_cmpph128_mask:
+    return "x86.avx512fp16.mask.cmp.ph.128";
+  case X86::BI__builtin_ia32_cmpph256_mask:
+    return "x86.avx512fp16.mask.cmp.ph.256";
+  case X86::BI__builtin_ia32_cmpph512_mask:
+    return "x86.avx512fp16.mask.cmp.ph.512";
+  case X86::BI__builtin_ia32_cmpps512_mask:
+    return "x86.avx512.mask.cmp.ps.512";
+  case X86::BI__builtin_ia32_cmppd512_mask:
+    return "x86.avx512.mask.cmp.pd.512";
+  case X86::BI__builtin_ia32_cmpps128_mask:
+    return "x86.avx512.mask.cmp.ps.128";
+  case X86::BI__builtin_ia32_cmpps256_mask:
+    return "x86.avx512.mask.cmp.ps.256";
+  case X86::BI__builtin_ia32_cmppd128_mask:
+    return "x86.avx512.mask.cmp.pd.128";
+  case X86::BI__builtin_ia32_cmppd256_mask:
+    return "x86.avx512.mask.cmp.pd.256";
+  }
+}
+
 static mlir::Value getMaskVecValue(CIRGenBuilderTy &builder, mlir::Location loc,
                                    mlir::Value mask, unsigned numElems) {
   auto maskTy = cir::VectorType::getFixed(
@@ -3002,50 +3037,7 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
     if (builder.getIsFPConstrained() &&
         (cmpInfo.pred == cir::FCmpOpKind::_true ||
          cmpInfo.pred == cir::FCmpOpKind::_false || isMaskFCmp)) {
-      llvm::StringRef intrinsicName;
-      switch (builtinID) {
-      default:
-        llvm_unreachable("Unexpected builtin");
-      case X86::BI__builtin_ia32_cmpps:
-        intrinsicName = "x86.sse.cmp.ps";
-        break;
-      case X86::BI__builtin_ia32_cmpps256:
-        intrinsicName = "x86.avx.cmp.ps.256";
-        break;
-      case X86::BI__builtin_ia32_cmppd:
-        intrinsicName = "x86.sse2.cmp.pd";
-        break;
-      case X86::BI__builtin_ia32_cmppd256:
-        intrinsicName = "x86.avx.cmp.pd.256";
-        break;
-      case X86::BI__builtin_ia32_cmpph128_mask:
-        intrinsicName = "x86.avx512fp16.mask.cmp.ph.128";
-        break;
-      case X86::BI__builtin_ia32_cmpph256_mask:
-        intrinsicName = "x86.avx512fp16.mask.cmp.ph.256";
-        break;
-      case X86::BI__builtin_ia32_cmpph512_mask:
-        intrinsicName = "x86.avx512fp16.mask.cmp.ph.512";
-        break;
-      case X86::BI__builtin_ia32_cmpps512_mask:
-        intrinsicName = "x86.avx512.mask.cmp.ps.512";
-        break;
-      case X86::BI__builtin_ia32_cmppd512_mask:
-        intrinsicName = "x86.avx512.mask.cmp.pd.512";
-        break;
-      case X86::BI__builtin_ia32_cmpps128_mask:
-        intrinsicName = "x86.avx512.mask.cmp.ps.128";
-        break;
-      case X86::BI__builtin_ia32_cmpps256_mask:
-        intrinsicName = "x86.avx512.mask.cmp.ps.256";
-        break;
-      case X86::BI__builtin_ia32_cmppd128_mask:
-        intrinsicName = "x86.avx512.mask.cmp.pd.128";
-        break;
-      case X86::BI__builtin_ia32_cmppd256_mask:
-        intrinsicName = "x86.avx512.mask.cmp.pd.256";
-        break;
-      }
+      llvm::StringRef intrinsicName = getX86FCmpIntrinsicName(builtinID);
 
       if (isMaskFCmp) {
         ops[3] = getMaskVecValue(builder, loc, ops[3], numElts);



More information about the cfe-commits mailing list