[clang] [CIR] Upstream missing support for floating point unary operator (PR #193215)
Haocong Lu via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 00:28:30 PDT 2026
https://github.com/Luhaocong updated https://github.com/llvm/llvm-project/pull/193215
>From 47f0b2208cce7cb01b46bb071fcc53628aa810e1 Mon Sep 17 00:00:00 2001
From: Haocong Lu <haocong.lu at witintech.com>
Date: Sat, 5 Sep 2026 13:25:08 +0800
Subject: [PATCH 1/3] [CIR] Upstream missing support for floating point unary
operator
- Add Support for `__bf16/Float16/bfloat16/float128` scalar
pre/post increment and decrement.
- Add support for float vector increment and decrement.
- Add test case for `__bf16/Float16/bfloat16/double/long double/float128`
unary operator with target `x86_64`.
- Add test case for interger/float vector increment and decrement
with target `powerpc64le + altivec`.
---
clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 72 +-
.../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 5 +-
clang/lib/CodeGen/CGExprScalar.cpp | 15 +-
.../CIR/CodeGen/unary-inc-dec-unsupport.cpp | 11 +
.../test/CIR/CodeGen/unary-inc-dec-vector.cpp | 153 ++++
clang/test/CIR/CodeGen/unary.cpp | 695 +++++++++++++++++-
6 files changed, 889 insertions(+), 62 deletions(-)
create mode 100644 clang/test/CIR/CodeGen/unary-inc-dec-unsupport.cpp
create mode 100644 clang/test/CIR/CodeGen/unary-inc-dec-vector.cpp
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index f7a39a9b4a8c9..55c7fe8fb974e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -682,7 +682,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
value = emitIncDecConsiderOverflowBehavior(e, value);
} else {
// NOTE(CIR): clang calls CreateAdd but folds this to a unary op
- value = emitIncOrDec(e, input, /*nsw=*/false);
+ value = emitIntIncOrDec(e, input, /*nsw=*/false);
}
} else if (const PointerType *ptr = type->getAs<PointerType>()) {
QualType type = ptr->getPointeeType();
@@ -704,32 +704,14 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
}
} else if (type->isVectorType()) {
if (type->hasIntegerRepresentation()) {
- value = emitIncOrDec(e, input, /*nsw=*/false);
+ value = emitIntIncOrDec(e, input, /*nsw=*/false);
} else {
- cgf.cgm.errorNYI(e->getSourceRange(), "Unary inc/dec vector of float");
- return {};
+ CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, e);
+ value = emitFloatIncOrDec(e, input);
}
} else if (type->isRealFloatingType()) {
CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, e);
-
- if (type->isHalfType() &&
- !cgf.getContext().getLangOpts().NativeHalfType) {
- cgf.cgm.errorNYI(e->getSourceRange(), "Unary inc/dec half");
- return {};
- }
-
- if (mlir::isa<cir::SingleType, cir::DoubleType, cir::LongDoubleType>(
- value.getType())) {
- mlir::Location loc = cgf.getLoc(e->getExprLoc());
- auto fpType = mlir::cast<cir::FPTypeInterface>(value.getType());
- mlir::Value amount = builder.getConstFP(
- loc, value.getType(), llvm::APFloat(fpType.getFloatSemantics(), 1));
- value = e->isIncrementOp() ? builder.createFAdd(loc, value, amount)
- : builder.createFSub(loc, value, amount);
- } else {
- cgf.cgm.errorNYI(e->getSourceRange(), "Unary inc/dec other fp type");
- return {};
- }
+ value = emitFloatIncOrDec(e, input);
} else if (type->isFixedPointType()) {
value = emitFixedPointIncDec(e, value, type);
} else {
@@ -756,13 +738,13 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
mlir::Value inVal) {
switch (cgf.getLangOpts().getSignedOverflowBehavior()) {
case LangOptions::SOB_Defined:
- return emitIncOrDec(e, inVal, /*nsw=*/false);
+ return emitIntIncOrDec(e, inVal, /*nsw=*/false);
case LangOptions::SOB_Undefined:
assert(!cir::MissingFeatures::sanitizers());
- return emitIncOrDec(e, inVal, /*nsw=*/true);
+ return emitIntIncOrDec(e, inVal, /*nsw=*/true);
case LangOptions::SOB_Trapping:
if (!e->canOverflow())
- return emitIncOrDec(e, inVal, /*nsw=*/true);
+ return emitIntIncOrDec(e, inVal, /*nsw=*/true);
cgf.cgm.errorNYI(e->getSourceRange(), "inc/def overflow SOB_Trapping");
return {};
}
@@ -828,14 +810,48 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
return builder.createOrFold<cir::MinusOp>(loc, operand, nsw);
}
- mlir::Value emitIncOrDec(const UnaryOperator *e, mlir::Value input,
- bool nsw = false) {
+ mlir::Value emitIntIncOrDec(const UnaryOperator *e, mlir::Value input,
+ bool nsw = false) {
mlir::Location loc = cgf.getLoc(e->getSourceRange().getBegin());
return e->isIncrementOp()
? builder.createOrFold<cir::IncOp>(loc, input, nsw)
: builder.createOrFold<cir::DecOp>(loc, input, nsw);
}
+ mlir::Value emitFloatIncOrDec(const UnaryOperator *e, mlir::Value input) {
+ assert(cir::isFPOrVectorOfFPType(input.getType()) &&
+ "Expect floating-point operand");
+ mlir::Location loc = cgf.getLoc(e->getSourceRange().getBegin());
+
+ if (auto vecType = mlir::dyn_cast<cir::VectorType>(input.getType())) {
+ mlir::Type fpScalarType = vecType.getElementType();
+ auto fpInterface = mlir::cast<cir::FPTypeInterface>(fpScalarType);
+ mlir::Value amount = builder.getConstFP(
+ loc, fpScalarType, llvm::APFloat(fpInterface.getFloatSemantics(), 1));
+ amount = cir::VecSplatOp::create(builder, loc, vecType, amount);
+ return e->isIncrementOp() ? builder.createFAdd(loc, input, amount)
+ : builder.createFSub(loc, input, amount);
+ } else {
+ QualType type = e->getSubExpr()->getType();
+ // Another special case: half FP increment should be done via float.
+ if (type->isHalfType() && !cgf.getContext().getLangOpts().NativeHalfType)
+ input = builder.createFloatingCast(input, builder.getSingleTy());
+
+ auto fpInterface = mlir::cast<cir::FPTypeInterface>(input.getType());
+ mlir::Value amount =
+ builder.getConstFP(loc, input.getType(),
+ llvm::APFloat(fpInterface.getFloatSemantics(), 1));
+ mlir::Value output = e->isIncrementOp()
+ ? builder.createFAdd(loc, input, amount)
+ : builder.createFSub(loc, input, amount);
+
+ if (type->isHalfType() && !cgf.getContext().getLangOpts().NativeHalfType)
+ output = builder.createFloatingCast(output, builder.getFp16Ty());
+
+ return output;
+ }
+ }
+
mlir::Value VisitUnaryNot(const UnaryOperator *e) {
ignoreResultAssign = false;
mlir::Value op = Visit(e->getSubExpr());
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 6f7509c363fd3..bd1ace8be7563 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -3201,8 +3201,9 @@ lowerIncDecOp(CIROp op, typename CIROp::Adaptor adaptor,
auto maybeNSW = nswFlag(op.getNoSignedWrap());
mlir::LLVM::ConstantOp one;
if (mlir::isa<cir::VectorType>(op.getType())) {
- mlir::DenseIntElementsAttr oneVec = mlir::DenseIntElementsAttr::get(
- mlir::cast<mlir::ShapedType>(llvmType), 1);
+ mlir::ShapedType shapedTy = mlir::cast<mlir::ShapedType>(llvmType);
+ mlir::APInt oneAP(shapedTy.getElementTypeBitWidth(), 1);
+ auto oneVec = mlir::DenseElementsAttr::get(shapedTy, {oneAP});
one = mlir::LLVM::ConstantOp::create(rewriter, loc, llvmType, oneVec);
} else {
one = mlir::LLVM::ConstantOp::create(rewriter, loc, llvmType, 1);
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 8a1dd776118f5..0ceaeef3da4b4 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -3557,12 +3557,9 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
llvm::Value *amt;
CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
- if (type->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) {
- // Another special case: half FP increment should be done via float. If
- // the input isn't already half, it may be i16.
- Value *bitcast = Builder.CreateBitCast(input, CGF.CGM.HalfTy);
- value = Builder.CreateFPExt(bitcast, CGF.CGM.FloatTy, "incdec.conv");
- }
+ // Another special case: half FP increment should be done via float.
+ if (type->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType)
+ value = Builder.CreateFPExt(value, CGF.CGM.FloatTy, "incdec.conv");
if (value->getType()->isFloatTy())
amt = llvm::ConstantFP::get(VMContext,
@@ -3593,12 +3590,10 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
}
value = Builder.CreateFAdd(value, amt, isInc ? "inc" : "dec");
- if (type->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) {
+ if (type->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType)
value = Builder.CreateFPTrunc(value, CGF.CGM.HalfTy, "incdec.conv");
- value = Builder.CreateBitCast(value, input->getType());
- }
- // Fixed-point types.
+ // Fixed-point types.
} else if (type->isFixedPointType()) {
// Fixed-point types are tricky. In some cases, it isn't possible to
// represent a 1 or a -1 in the type at all. Piggyback off of
diff --git a/clang/test/CIR/CodeGen/unary-inc-dec-unsupport.cpp b/clang/test/CIR/CodeGen/unary-inc-dec-unsupport.cpp
new file mode 100644
index 0000000000000..58cf166eee2b9
--- /dev/null
+++ b/clang/test/CIR/CodeGen/unary-inc-dec-unsupport.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64le -fclangir -emit-cir -verify %s -o -
+
+// PPC fp128 (__ibm128) unary inc/dec is not yet supported, drop the errorNYI
+// and turn this into a regular test.
+
+__ibm128 g; // expected-error@*:* {{ClangIR code gen Not Yet Implemented: processing of built-in type: '__ibm128'}}
+
+void test_pre_inc() { ++g; }
+void test_pre_dec() { --g; }
+void test_post_inc() { g++; }
+void test_post_dec() { g--; }
diff --git a/clang/test/CIR/CodeGen/unary-inc-dec-vector.cpp b/clang/test/CIR/CodeGen/unary-inc-dec-vector.cpp
new file mode 100644
index 0000000000000..5b5bf72af369d
--- /dev/null
+++ b/clang/test/CIR/CodeGen/unary-inc-dec-vector.cpp
@@ -0,0 +1,153 @@
+// RUN: %clang_cc1 -triple powerpc64le -target-feature +altivec -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
+// RUN: %clang_cc1 -triple powerpc64le -target-feature +altivec -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
+// RUN: %clang_cc1 -triple powerpc64le -target-feature +altivec -Wno-unused-value -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
+
+// Unary inc/dec on vector types, covering the CIRGenExprScalar.cpp vector
+// branch:
+// * integer vectors go through emitIntIncOrDec -> cir.inc/cir.dec
+// * float vectors go through emitFloatIncOrDec -> cir.fadd/cir.fsub
+
+typedef int vi4 __attribute__((vector_size(16)));
+typedef unsigned uvi4 __attribute__((vector_size(16)));
+typedef short vsh8 __attribute__((vector_size(16)));
+typedef float vf4 __attribute__((vector_size(16)));
+typedef double vd2 __attribute__((vector_size(16)));
+
+void vecIntIncDec(vi4 a) {
+ ++a;
+ --a;
+ a++;
+ a--;
+}
+// CIR-LABEL: @_Z12vecIntIncDecDv4_i
+// CIR: cir.inc %{{.+}} : !cir.vector<4 x !s32i>
+// CIR: cir.dec %{{.+}} : !cir.vector<4 x !s32i>
+// CIR: cir.inc %{{.+}} : !cir.vector<4 x !s32i>
+// CIR: cir.dec %{{.+}} : !cir.vector<4 x !s32i>
+
+// LLVM-LABEL: @_Z12vecIntIncDecDv4_i
+// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
+
+// OGCG-LABEL: @_Z12vecIntIncDecDv4_i
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
+
+void vecUIntIncDec(uvi4 b) {
+ ++b;
+ --b;
+ b++;
+ b--;
+}
+// CIR-LABEL: @_Z13vecUIntIncDecDv4_j
+// CIR: cir.inc %{{.+}} : !cir.vector<4 x !u32i>
+// CIR: cir.dec %{{.+}} : !cir.vector<4 x !u32i>
+// CIR: cir.inc %{{.+}} : !cir.vector<4 x !u32i>
+// CIR: cir.dec %{{.+}} : !cir.vector<4 x !u32i>
+
+// LLVM-LABEL: @_Z13vecUIntIncDecDv4_j
+// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
+
+// OGCG-LABEL: @_Z13vecUIntIncDecDv4_j
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
+
+void vecShortIncDec(vsh8 c) {
+ ++c;
+ --c;
+ c++;
+ c--;
+}
+// CIR-LABEL: @_Z14vecShortIncDecDv8_s
+// CIR: cir.inc %{{.+}} : !cir.vector<8 x !s16i>
+// CIR: cir.dec %{{.+}} : !cir.vector<8 x !s16i>
+// CIR: cir.inc %{{.+}} : !cir.vector<8 x !s16i>
+// CIR: cir.dec %{{.+}} : !cir.vector<8 x !s16i>
+
+// LLVM-LABEL: @_Z14vecShortIncDecDv8_s
+// LLVM: add <8 x i16> %{{.+}}, splat (i16 1)
+// LLVM: sub <8 x i16> %{{.+}}, splat (i16 1)
+// LLVM: add <8 x i16> %{{.+}}, splat (i16 1)
+// LLVM: sub <8 x i16> %{{.+}}, splat (i16 1)
+
+// OGCG-LABEL: @_Z14vecShortIncDecDv8_s
+// OGCG: add <8 x i16> %{{.+}}, splat (i16 1)
+// OGCG: add <8 x i16> %{{.+}}, splat (i16 -1)
+// OGCG: add <8 x i16> %{{.+}}, splat (i16 1)
+// OGCG: add <8 x i16> %{{.+}}, splat (i16 -1)
+
+void vecFloatIncDec(vf4 a) {
+ ++a;
+ --a;
+ a++;
+ a--;
+}
+// CIR-LABEL: @_Z14vecFloatIncDecDv4_f
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
+// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
+// CIR: cir.fsub %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
+// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
+// CIR: cir.fsub %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
+
+// LLVM-LABEL: @_Z14vecFloatIncDecDv4_f
+// LLVM: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
+// LLVM: fsub <4 x float> %{{.+}}, splat (float 1.000000e+00)
+// LLVM: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
+// LLVM: fsub <4 x float> %{{.+}}, splat (float 1.000000e+00)
+
+// OGCG-LABEL: @_Z14vecFloatIncDecDv4_f
+// OGCG: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
+// OGCG: fadd <4 x float> %{{.+}}, splat (float -1.000000e+00)
+// OGCG: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
+// OGCG: fadd <4 x float> %{{.+}}, splat (float -1.000000e+00)
+
+void vecDoubleIncDec(vd2 b) {
+ ++b;
+ --b;
+ b++;
+ b--;
+}
+// CIR-LABEL: @_Z15vecDoubleIncDecDv2_d
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
+// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
+// CIR: cir.fsub %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
+// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
+// CIR: cir.fsub %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
+
+// LLVM-LABEL: @_Z15vecDoubleIncDecDv2_d
+// LLVM: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
+// LLVM: fsub <2 x double> %{{.+}}, splat (double 1.000000e+00)
+// LLVM: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
+// LLVM: fsub <2 x double> %{{.+}}, splat (double 1.000000e+00)
+
+// OGCG-LABEL: @_Z15vecDoubleIncDecDv2_d
+// OGCG: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
+// OGCG: fadd <2 x double> %{{.+}}, splat (double -1.000000e+00)
+// OGCG: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
+// OGCG: fadd <2 x double> %{{.+}}, splat (double -1.000000e+00)
diff --git a/clang/test/CIR/CodeGen/unary.cpp b/clang/test/CIR/CodeGen/unary.cpp
index 03b068a68d066..84a07691ce85b 100644
--- a/clang/test/CIR/CodeGen/unary.cpp
+++ b/clang/test/CIR/CodeGen/unary.cpp
@@ -222,6 +222,24 @@ int inc2() {
// OGCG: store i32 %[[A_LOAD]], ptr %[[B]], align 4
// OGCG: %[[B_TO_OUTPUT:.*]] = load i32, ptr %[[B]], align 4
+void chars(char c) {
+// CHECK: cir.func{{.*}} @_Z5charsc
+
+ int c1 = +c;
+ // CHECK: %[[PROMO:.*]] = cir.cast integral %{{.+}} : !s8i -> !s32i
+ int c2 = -c;
+ // CHECK: %[[PROMO:.*]] = cir.cast integral %{{.+}} : !s8i -> !s32i
+ // CHECK: cir.minus nsw %[[PROMO]] : !s32i
+
+ // Chars can go through some integer promotion codegen paths even when not promoted.
+ // These should not have nsw attributes because the intermediate promotion makes the
+ // overflow defined behavior.
+ ++c; // CHECK: cir.inc %{{.+}} : !s8i
+ --c; // CHECK: cir.dec %{{.+}} : !s8i
+ c++; // CHECK: cir.inc %{{.+}} : !s8i
+ c--; // CHECK: cir.dec %{{.+}} : !s8i
+}
+
float fpPlus() {
float a = 1.0f;
return +a;
@@ -409,65 +427,698 @@ float fpPostInc2() {
// OGCG: store float %[[A_LOAD]], ptr %[[B]], align 4
// OGCG: %[[B_TO_OUTPUT:.*]] = load float, ptr %[[B]], align 4
-void chars(char c) {
-// CHECK: cir.func{{.*}} @_Z5charsc
+// double unary operations
+double doubleUPlus(double f) {
+ return +f;
+}
- int c1 = +c;
- // CHECK: %[[PROMO:.*]] = cir.cast integral %{{.+}} : !s8i -> !s32i
- int c2 = -c;
- // CHECK: %[[PROMO:.*]] = cir.cast integral %{{.+}} : !s8i -> !s32i
- // CHECK: cir.minus nsw %[[PROMO]] : !s32i
+// CHECK: cir.func{{.*}} @_Z11doubleUPlusd({{.*}}) -> (!cir.double{{.*}})
+// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
- // Chars can go through some integer promotion codegen paths even when not promoted.
- // These should not have nsw attributes because the intermediate promotion makes the
- // overflow defined behavior.
- ++c; // CHECK: cir.inc %{{.+}} : !s8i
- --c; // CHECK: cir.dec %{{.+}} : !s8i
- c++; // CHECK: cir.inc %{{.+}} : !s8i
- c--; // CHECK: cir.dec %{{.+}} : !s8i
+// LLVM: define{{.*}} double @_Z11doubleUPlusd({{.*}})
+// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+
+// OGCG: define{{.*}} double @_Z11doubleUPlusd({{.*}})
+// OGCG: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+
+double doubleUMinus(double f) {
+ return -f;
+}
+
+// CHECK: cir.func{{.*}} @_Z12doubleUMinusd({{.*}}) -> (!cir.double{{.*}})
+// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CHECK: %[[DBL_NEGATED:.*]] = cir.fneg %[[DBL_LOAD]]
+
+// LLVM: define{{.*}} double @_Z12doubleUMinusd({{.*}})
+// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// LLVM: %[[DBL_NEGATED:.*]] = fneg double %[[DBL_LOAD]]
+
+// OGCG: define{{.*}} double @_Z12doubleUMinusd({{.*}})
+// OGCG: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// OGCG: %[[DBL_NEGATED:.*]] = fneg double %[[DBL_LOAD]]
+
+double doubleUPreInc(double f) {
+ return ++f;
+}
+
+// CHECK: cir.func{{.*}} @_Z13doubleUPreIncd({{.*}}) -> (!cir.double{{.*}})
+// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CHECK: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CHECK: %[[DBL_INC:.*]] = cir.fadd %[[DBL_LOAD]], %[[DBL_ONE]]
+
+// LLVM: define{{.*}} double @_Z13doubleUPreIncd({{.*}})
+// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// LLVM: %[[DBL_INC:.*]] = fadd double %[[DBL_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} double @_Z13doubleUPreIncd({{.*}})
+// OGCG: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// OGCG: %[[DBL_INC:.*]] = fadd double %[[DBL_LOAD]], 1.000000e+00
+
+double doubleUPreDec(double f) {
+ return --f;
+}
+
+// CHECK: cir.func{{.*}} @_Z13doubleUPreDecd({{.*}}) -> (!cir.double{{.*}})
+// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CHECK: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CHECK: %[[DBL_DEC:.*]] = cir.fsub %[[DBL_LOAD]], %[[DBL_ONE]]
+
+// LLVM: define{{.*}} double @_Z13doubleUPreDecd({{.*}})
+// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// LLVM: %[[DBL_DEC:.*]] = fsub double %[[DBL_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} double @_Z13doubleUPreDecd({{.*}})
+// OGCG: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// OGCG: %[[DBL_DEC:.*]] = fadd double %[[DBL_LOAD]], -1.000000e+00
+
+double doubleUPostInc(double f) {
+ return f++;
+}
+
+// CHECK: cir.func{{.*}} @_Z14doubleUPostIncd({{.*}}) -> (!cir.double{{.*}})
+// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CHECK: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CHECK: %[[DBL_INC:.*]] = cir.fadd %[[DBL_LOAD]], %[[DBL_ONE]]
+
+// LLVM: define{{.*}} double @_Z14doubleUPostIncd({{.*}})
+// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// LLVM: %[[DBL_INC:.*]] = fadd double %[[DBL_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} double @_Z14doubleUPostIncd({{.*}})
+// OGCG: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// OGCG: %[[DBL_INC:.*]] = fadd double %[[DBL_LOAD]], 1.000000e+00
+
+double doubleUPostDec(double f) {
+ return f--;
+}
+
+// CHECK: cir.func{{.*}} @_Z14doubleUPostDecd({{.*}}) -> (!cir.double{{.*}})
+// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CHECK: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CHECK: %[[DBL_DEC:.*]] = cir.fsub %[[DBL_LOAD]], %[[DBL_ONE]]
+
+// LLVM: define{{.*}} double @_Z14doubleUPostDecd({{.*}})
+// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// LLVM: %[[DBL_DEC:.*]] = fsub double %[[DBL_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} double @_Z14doubleUPostDecd({{.*}})
+// OGCG: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
+// OGCG: %[[DBL_DEC:.*]] = fadd double %[[DBL_LOAD]], -1.000000e+00
+
+// long double unary operations
+long double ldUPlus(long double f) {
+ return +f;
+}
+
+// CHECK: cir.func{{.*}} @_Z7ldUPluse({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+
+// LLVM: define{{.*}} x86_fp80 @_Z7ldUPluse({{.*}})
+// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+
+// OGCG: define{{.*}} x86_fp80 @_Z7ldUPluse({{.*}})
+// OGCG: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+
+long double ldUMinus(long double f) {
+ return -f;
+}
+
+// CHECK: cir.func{{.*}} @_Z8ldUMinuse({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CHECK: %[[LD_NEGATED:.*]] = cir.fneg %[[LD_LOAD]]
+
+// LLVM: define{{.*}} x86_fp80 @_Z8ldUMinuse({{.*}})
+// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// LLVM: %[[LD_NEGATED:.*]] = fneg x86_fp80 %[[LD_LOAD]]
+
+// OGCG: define{{.*}} x86_fp80 @_Z8ldUMinuse({{.*}})
+// OGCG: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// OGCG: %[[LD_NEGATED:.*]] = fneg x86_fp80 %[[LD_LOAD]]
+
+long double ldUPreInc(long double f) {
+ return ++f;
+}
+
+// CHECK: cir.func{{.*}} @_Z9ldUPreInce({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CHECK: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
+// CHECK: %[[LD_INC:.*]] = cir.fadd %[[LD_LOAD]], %[[LD_ONE]]
+
+// LLVM: define{{.*}} x86_fp80 @_Z9ldUPreInce({{.*}})
+// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// LLVM: %[[LD_INC:.*]] = fadd x86_fp80 %[[LD_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} x86_fp80 @_Z9ldUPreInce({{.*}})
+// OGCG: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// OGCG: %[[LD_INC:.*]] = fadd x86_fp80 %[[LD_LOAD]], 1.000000e+00
+
+long double ldUPreDec(long double f) {
+ return --f;
+}
+
+// CHECK: cir.func{{.*}} @_Z9ldUPreDece({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CHECK: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
+// CHECK: %[[LD_DEC:.*]] = cir.fsub %[[LD_LOAD]], %[[LD_ONE]]
+
+// LLVM: define{{.*}} x86_fp80 @_Z9ldUPreDece({{.*}})
+// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// LLVM: %[[LD_DEC:.*]] = fsub x86_fp80 %[[LD_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} x86_fp80 @_Z9ldUPreDece({{.*}})
+// OGCG: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// OGCG: %[[LD_DEC:.*]] = fadd x86_fp80 %[[LD_LOAD]], -1.000000e+00
+
+long double ldUPostInc(long double f) {
+ return f++;
+}
+
+// CHECK: cir.func{{.*}} @_Z10ldUPostInce({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CHECK: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
+// CHECK: %[[LD_INC:.*]] = cir.fadd %[[LD_LOAD]], %[[LD_ONE]]
+
+// LLVM: define{{.*}} x86_fp80 @_Z10ldUPostInce({{.*}})
+// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// LLVM: %[[LD_INC:.*]] = fadd x86_fp80 %[[LD_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} x86_fp80 @_Z10ldUPostInce({{.*}})
+// OGCG: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// OGCG: %[[LD_INC:.*]] = fadd x86_fp80 %[[LD_LOAD]], 1.000000e+00
+
+long double ldUPostDec(long double f) {
+ return f--;
+}
+
+// CHECK: cir.func{{.*}} @_Z10ldUPostDece({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CHECK: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
+// CHECK: %[[LD_DEC:.*]] = cir.fsub %[[LD_LOAD]], %[[LD_ONE]]
+
+// LLVM: define{{.*}} x86_fp80 @_Z10ldUPostDece({{.*}})
+// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// LLVM: %[[LD_DEC:.*]] = fsub x86_fp80 %[[LD_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} x86_fp80 @_Z10ldUPostDece({{.*}})
+// OGCG: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
+// OGCG: %[[LD_DEC:.*]] = fadd x86_fp80 %[[LD_LOAD]], -1.000000e+00
+
+// __float128 unary operations
+__float128 f128UPlus(__float128 f) {
+ return +f;
+}
+
+// CHECK: cir.func{{.*}} @_Z9f128UPlusg({{.*}}) -> (!cir.f128{{.*}})
+// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+
+// LLVM: define{{.*}} fp128 @_Z9f128UPlusg({{.*}})
+// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+
+// OGCG: define{{.*}} fp128 @_Z9f128UPlusg({{.*}})
+// OGCG: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+
+__float128 f128UMinus(__float128 f) {
+ return -f;
+}
+
+// CHECK: cir.func{{.*}} @_Z10f128UMinusg({{.*}}) -> (!cir.f128{{.*}})
+// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CHECK: %[[F128_NEG:.*]] = cir.fneg %[[F128_LOAD]]
+
+// LLVM: define{{.*}} fp128 @_Z10f128UMinusg({{.*}})
+// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// LLVM: %[[F128_NEG:.*]] = fneg fp128 %[[F128_LOAD]]
+
+// OGCG: define{{.*}} fp128 @_Z10f128UMinusg({{.*}})
+// OGCG: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// OGCG: %[[F128_NEG:.*]] = fneg fp128 %[[F128_LOAD]]
+
+__float128 f128UPreInc(__float128 f) {
+ return ++f;
+}
+
+// CHECK: cir.func{{.*}} @_Z11f128UPreIncg({{.*}}) -> (!cir.f128{{.*}})
+// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CHECK: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
+// CHECK: %[[F128_INC:.*]] = cir.fadd %[[F128_LOAD]], %[[F128_ONE]]
+
+// LLVM: define{{.*}} fp128 @_Z11f128UPreIncg({{.*}})
+// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// LLVM: %[[F128_INC:.*]] = fadd fp128 %[[F128_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} fp128 @_Z11f128UPreIncg({{.*}})
+// OGCG: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// OGCG: %[[F128_INC:.*]] = fadd fp128 %[[F128_LOAD]], 1.000000e+00
+
+__float128 f128UPreDec(__float128 f) {
+ return --f;
+}
+
+// CHECK: cir.func{{.*}} @_Z11f128UPreDecg({{.*}}) -> (!cir.f128{{.*}})
+// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CHECK: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
+// CHECK: %[[F128_DEC:.*]] = cir.fsub %[[F128_LOAD]], %[[F128_ONE]]
+
+// LLVM: define{{.*}} fp128 @_Z11f128UPreDecg({{.*}})
+// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// LLVM: %[[F128_DEC:.*]] = fsub fp128 %[[F128_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} fp128 @_Z11f128UPreDecg({{.*}})
+// OGCG: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// OGCG: %[[F128_DEC:.*]] = fadd fp128 %[[F128_LOAD]], -1.000000e+00
+
+__float128 f128UPostInc(__float128 f) {
+ return f++;
+}
+
+// CHECK: cir.func{{.*}} @_Z12f128UPostIncg({{.*}}) -> (!cir.f128{{.*}})
+// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CHECK: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
+// CHECK: %[[F128_INC:.*]] = cir.fadd %[[F128_LOAD]], %[[F128_ONE]]
+
+// LLVM: define{{.*}} fp128 @_Z12f128UPostIncg({{.*}})
+// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// LLVM: %[[F128_INC:.*]] = fadd fp128 %[[F128_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} fp128 @_Z12f128UPostIncg({{.*}})
+// OGCG: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// OGCG: %[[F128_INC:.*]] = fadd fp128 %[[F128_LOAD]], 1.000000e+00
+
+__float128 f128UPostDec(__float128 f) {
+ return f--;
}
-_Float16 fp16UPlus(_Float16 f) {
+// CHECK: cir.func{{.*}} @_Z12f128UPostDecg({{.*}}) -> (!cir.f128{{.*}})
+// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CHECK: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
+// CHECK: %[[F128_DEC:.*]] = cir.fsub %[[F128_LOAD]], %[[F128_ONE]]
+
+// LLVM: define{{.*}} fp128 @_Z12f128UPostDecg({{.*}})
+// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// LLVM: %[[F128_DEC:.*]] = fsub fp128 %[[F128_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} fp128 @_Z12f128UPostDecg({{.*}})
+// OGCG: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
+// OGCG: %[[F128_DEC:.*]] = fadd fp128 %[[F128_LOAD]], -1.000000e+00
+
+// Float16 unary operations
+_Float16 Float16UPlus(_Float16 f) {
return +f;
}
-// CHECK: cir.func{{.*}} @_Z9fp16UPlusDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CHECK: cir.func{{.*}} @_Z12Float16UPlusDF16_({{.*}}) -> (!cir.f16{{.*}})
// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[F:.*]]
// CHECK: %[[PROMOTED:.*]] = cir.cast floating %[[INPUT]] : !cir.f16 -> !cir.float
// CHECK: %[[UNPROMOTED:.*]] = cir.cast floating %[[PROMOTED]] : !cir.float -> !cir.f16
-// LLVM: define{{.*}} half @_Z9fp16UPlusDF16_({{.*}})
+// LLVM: define{{.*}} half @_Z12Float16UPlusDF16_({{.*}})
// LLVM: %[[F_LOAD:.*]] = load half, ptr %{{.*}}, align 2
// LLVM: %[[PROMOTED:.*]] = fpext half %[[F_LOAD]] to float
// LLVM: %[[UNPROMOTED:.*]] = fptrunc float %[[PROMOTED]] to half
-// OGCG: define{{.*}} half @_Z9fp16UPlusDF16_({{.*}})
+// OGCG: define{{.*}} half @_Z12Float16UPlusDF16_({{.*}})
// OGCG: %[[F_LOAD:.*]] = load half, ptr %{{.*}}, align 2
// OGCG: %[[PROMOTED:.*]] = fpext half %[[F_LOAD]] to float
// OGCG: %[[UNPROMOTED:.*]] = fptrunc float %[[PROMOTED]] to half
-_Float16 fp16UMinus(_Float16 f) {
+_Float16 Float16UMinus(_Float16 f) {
return -f;
}
-// CHECK: cir.func{{.*}} @_Z10fp16UMinusDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CHECK: cir.func{{.*}} @_Z13Float16UMinusDF16_({{.*}}) -> (!cir.f16{{.*}})
// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[F:.*]]
// CHECK: %[[PROMOTED:.*]] = cir.cast floating %[[INPUT]] : !cir.f16 -> !cir.float
// CHECK: %[[RESULT:.*]] = cir.fneg %[[PROMOTED]]
// CHECK: %[[UNPROMOTED:.*]] = cir.cast floating %[[RESULT]] : !cir.float -> !cir.f16
-// LLVM: define{{.*}} half @_Z10fp16UMinusDF16_({{.*}})
+// LLVM: define{{.*}} half @_Z13Float16UMinusDF16_({{.*}})
// LLVM: %[[F_LOAD:.*]] = load half, ptr %{{.*}}, align 2
// LLVM: %[[PROMOTED:.*]] = fpext half %[[F_LOAD]] to float
// LLVM: %[[RESULT:.*]] = fneg float %[[PROMOTED]]
// LLVM: %[[UNPROMOTED:.*]] = fptrunc float %[[RESULT]] to half
-// OGCG: define{{.*}} half @_Z10fp16UMinusDF16_({{.*}})
+// OGCG: define{{.*}} half @_Z13Float16UMinusDF16_({{.*}})
// OGCG: %[[F_LOAD:.*]] = load half, ptr %{{.*}}, align 2
// OGCG: %[[PROMOTED:.*]] = fpext half %[[F_LOAD]] to float
// OGCG: %[[RESULT:.*]] = fneg float %[[PROMOTED]]
// OGCG: %[[UNPROMOTED:.*]] = fptrunc float %[[RESULT]] to half
+_Float16 Float16UPreInc(_Float16 f) {
+ return ++f;
+}
+
+// CHECK: cir.func{{.*}} @_Z14Float16UPreIncDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CHECK: %[[PREINC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
+// CHECK: %[[PREINC_INPUT:.*]] = cir.load{{.*}} %[[PREINC_F]]
+// CHECK: %[[PREINC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
+// CHECK: %[[PREINC_RESULT:.*]] = cir.fadd %[[PREINC_INPUT]], %[[PREINC_ONE]] : !cir.f16
+
+// LLVM: define{{.*}} half @_Z14Float16UPreIncDF16_({{.*}})
+// LLVM: %[[PREINC_F_ADDR:.*]] = alloca half, align 2
+// LLVM: %[[PREINC_INPUT:.*]] = load half, ptr %[[PREINC_F_ADDR]], align 2
+// LLVM: %[[PREINC_RESULT:.*]] = fadd half %[[PREINC_INPUT]], 1.000000e+00
+
+// OGCG: define{{.*}} half @_Z14Float16UPreIncDF16_({{.*}})
+// OGCG: %[[PREINC_F_ADDR:.*]] = alloca half, align 2
+// OGCG: %[[PREINC_INPUT:.*]] = load half, ptr %[[PREINC_F_ADDR]], align 2
+// OGCG: %[[PREINC_RESULT:.*]] = fadd half %[[PREINC_INPUT]], 1.000000e+00
+
+_Float16 Float16UPreDec(_Float16 f) {
+ return --f;
+}
+
+// CHECK: cir.func{{.*}} @_Z14Float16UPreDecDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CHECK: %[[PREDEC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
+// CHECK: %[[PREDEC_INPUT:.*]] = cir.load{{.*}} %[[PREDEC_F]]
+// CHECK: %[[PREDEC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
+// CHECK: %[[PREDEC_RESULT:.*]] = cir.fsub %[[PREDEC_INPUT]], %[[PREDEC_ONE]] : !cir.f16
+
+// LLVM: define{{.*}} half @_Z14Float16UPreDecDF16_({{.*}})
+// LLVM: %[[PREDEC_F_ADDR:.*]] = alloca half, align 2
+// LLVM: %[[PREDEC_INPUT:.*]] = load half, ptr %[[PREDEC_F_ADDR]], align 2
+// LLVM: %[[PREDEC_RESULT:.*]] = fsub half %[[PREDEC_INPUT]], 1.000000e+00
+
+// OGCG: define{{.*}} half @_Z14Float16UPreDecDF16_({{.*}})
+// OGCG: %[[PREDEC_F_ADDR:.*]] = alloca half, align 2
+// OGCG: %[[PREDEC_INPUT:.*]] = load half, ptr %[[PREDEC_F_ADDR]], align 2
+// OGCG: %[[PREDEC_RESULT:.*]] = fadd half %[[PREDEC_INPUT]], -1.000000e+00
+
+_Float16 Float16UPostInc(_Float16 f) {
+ return f++;
+}
+
+// CHECK: cir.func{{.*}} @_Z15Float16UPostIncDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CHECK: %[[POSTINC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
+// CHECK: %[[POSTINC_INPUT:.*]] = cir.load{{.*}} %[[POSTINC_F]]
+// CHECK: %[[POSTINC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
+// CHECK: %[[POSTINC_RESULT:.*]] = cir.fadd %[[POSTINC_INPUT]], %[[POSTINC_ONE]] : !cir.f16
+
+// LLVM: define{{.*}} half @_Z15Float16UPostIncDF16_({{.*}})
+// LLVM: %[[POSTINC_F_ADDR:.*]] = alloca half, align 2
+// LLVM: %[[POSTINC_INPUT:.*]] = load half, ptr %[[POSTINC_F_ADDR]], align 2
+// LLVM: %[[POSTINC_RESULT:.*]] = fadd half %[[POSTINC_INPUT]], 1.000000e+00
+
+// OGCG: define{{.*}} half @_Z15Float16UPostIncDF16_({{.*}})
+// OGCG: %[[POSTINC_F_ADDR:.*]] = alloca half, align 2
+// OGCG: %[[POSTINC_INPUT:.*]] = load half, ptr %[[POSTINC_F_ADDR]], align 2
+// OGCG: %[[POSTINC_RESULT:.*]] = fadd half %[[POSTINC_INPUT]], 1.000000e+00
+
+_Float16 Float16UPostDec(_Float16 f) {
+ return f--;
+}
+
+// CHECK: cir.func{{.*}} @_Z15Float16UPostDecDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CHECK: %[[POSTDEC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
+// CHECK: %[[POSTDEC_INPUT:.*]] = cir.load{{.*}} %[[POSTDEC_F]]
+// CHECK: %[[POSTDEC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
+// CHECK: %[[POSTDEC_RESULT:.*]] = cir.fsub %[[POSTDEC_INPUT]], %[[POSTDEC_ONE]] : !cir.f16
+
+// LLVM: define{{.*}} half @_Z15Float16UPostDecDF16_({{.*}})
+// LLVM: %[[POSTDEC_F_ADDR:.*]] = alloca half, align 2
+// LLVM: %[[POSTDEC_INPUT:.*]] = load half, ptr %[[POSTDEC_F_ADDR]], align 2
+// LLVM: %[[POSTDEC_RESULT:.*]] = fsub half %[[POSTDEC_INPUT]], 1.000000e+00
+
+// OGCG: define{{.*}} half @_Z15Float16UPostDecDF16_({{.*}})
+// OGCG: %[[POSTDEC_F_ADDR:.*]] = alloca half, align 2
+// OGCG: %[[POSTDEC_INPUT:.*]] = load half, ptr %[[POSTDEC_F_ADDR]], align 2
+// OGCG: %[[POSTDEC_RESULT:.*]] = fadd half %[[POSTDEC_INPUT]], -1.000000e+00
+
+// __fp16 unary operations
+void fp16PtrUPlus(__fp16 *f) {
+ *f = +(*f);
+}
+
+// CHECK: cir.func{{.*}} @_Z12fp16PtrUPlusPDh({{.*}})
+// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_PROMOTED]] : !cir.float -> !cir.f16
+
+// LLVM: define{{.*}} void @_Z12fp16PtrUPlusPDh({{.*}})
+// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// LLVM: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// LLVM: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_PROMOTED]] to half
+
+// OGCG: define{{.*}} void @_Z12fp16PtrUPlusPDh({{.*}})
+// OGCG: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// OGCG: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// OGCG: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_PROMOTED]] to half
+
+void fp16PtrUMinus(__fp16 *f) {
+ *f = -(*f);
+}
+
+// CHECK: cir.func{{.*}} @_Z13fp16PtrUMinusPDh({{.*}})
+// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CHECK: %[[FPTR_NEGATED:.*]] = cir.fneg %[[FPTR_PROMOTED]]
+// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_NEGATED]] : !cir.float -> !cir.f16
+
+// LLVM: define{{.*}} void @_Z13fp16PtrUMinusPDh({{.*}})
+// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// LLVM: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// LLVM: %[[FPTR_NEGATED:.*]] = fneg float %[[FPTR_PROMOTED]]
+// LLVM: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_NEGATED]] to half
+
+// OGCG: define{{.*}} void @_Z13fp16PtrUMinusPDh({{.*}})
+// OGCG: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// OGCG: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// OGCG: %[[FPTR_NEGATED:.*]] = fneg float %[[FPTR_PROMOTED]]
+// OGCG: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_NEGATED]] to half
+
+void fp16PtrUPreInc(__fp16 *f) {
+ ++(*f);
+}
+
+// CHECK: cir.func{{.*}} @_Z14fp16PtrUPreIncPDh({{.*}})
+// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CHECK: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CHECK: %[[FPTR_INC:.*]] = cir.fadd %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
+// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_INC]] : !cir.float -> !cir.f16
+
+// LLVM: define{{.*}} void @_Z14fp16PtrUPreIncPDh({{.*}})
+// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// LLVM: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// LLVM: %[[FPTR_INC:.*]] = fadd float %[[FPTR_PROMOTED]], 1.000000e+00
+// LLVM: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_INC]] to half
+
+// OGCG: define{{.*}} void @_Z14fp16PtrUPreIncPDh({{.*}})
+// OGCG: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// OGCG: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// OGCG: %[[FPTR_INC:.*]] = fadd float %[[FPTR_PROMOTED]], 1.000000e+00
+// OGCG: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_INC]] to half
+
+void fp16PtrUPreDec(__fp16 *f) {
+ --(*f);
+}
+
+// CHECK: cir.func{{.*}} @_Z14fp16PtrUPreDecPDh({{.*}})
+// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CHECK: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CHECK: %[[FPTR_DEC:.*]] = cir.fsub %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
+// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_DEC]] : !cir.float -> !cir.f16
+
+// LLVM: define{{.*}} void @_Z14fp16PtrUPreDecPDh({{.*}})
+// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// LLVM: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// LLVM: %[[FPTR_DEC:.*]] = fsub float %[[FPTR_PROMOTED]], 1.000000e+00
+// LLVM: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_DEC]] to half
+
+// OGCG: define{{.*}} void @_Z14fp16PtrUPreDecPDh({{.*}})
+// OGCG: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// OGCG: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// OGCG: %[[FPTR_DEC:.*]] = fadd float %[[FPTR_PROMOTED]], -1.000000e+00
+// OGCG: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_DEC]] to half
+
+void fp16PtrUPostInc(__fp16 *f) {
+ (*f)++;
+}
+
+// CHECK: cir.func{{.*}} @_Z15fp16PtrUPostIncPDh({{.*}})
+// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CHECK: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CHECK: %[[FPTR_INC:.*]] = cir.fadd %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
+// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_DEC]] : !cir.float -> !cir.f16
+
+// LLVM: define{{.*}} void @_Z15fp16PtrUPostIncPDh({{.*}})
+// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// LLVM: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// LLVM: %[[FPTR_INC:.*]] = fadd float %[[FPTR_PROMOTED]], 1.000000e+00
+// LLVM: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_INC]] to half
+
+// OGCG: define{{.*}} void @_Z15fp16PtrUPostIncPDh({{.*}})
+// OGCG: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// OGCG: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// OGCG: %[[FPTR_INC:.*]] = fadd float %[[FPTR_PROMOTED]], 1.000000e+00
+// OGCG: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_INC]] to half
+
+void fp16PtrUPostDec(__fp16 *f) {
+ (*f)--;
+}
+
+// CHECK: cir.func{{.*}} @_Z15fp16PtrUPostDecPDh({{.*}})
+// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CHECK: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CHECK: %[[FPTR_DEC:.*]] = cir.fsub %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
+// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_DEC]] : !cir.float -> !cir.f16
+
+// LLVM: define{{.*}} void @_Z15fp16PtrUPostDecPDh({{.*}})
+// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// LLVM: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// LLVM: %[[FPTR_DEC:.*]] = fsub float %[[FPTR_PROMOTED]], 1.000000e+00
+// LLVM: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_DEC]] to half
+
+// OGCG: define{{.*}} void @_Z15fp16PtrUPostDecPDh({{.*}})
+// OGCG: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
+// OGCG: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
+// OGCG: %[[FPTR_DEC:.*]] = fadd float %[[FPTR_PROMOTED]], -1.000000e+00
+// OGCG: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_DEC]] to half
+
+// __bf16 unary operations
+__bf16 bf16UPlus(__bf16 f) {
+ return +f;
+}
+
+// CHECK: cir.func{{.*}} @_Z9bf16UPlusDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CHECK: %[[BF16_PROMOTED:.*]] = cir.cast floating %[[BF16_LOAD]] : !cir.bf16 -> !cir.float
+// CHECK: %[[BF16_UNPROMOTED:.*]] = cir.cast floating %[[BF16_PROMOTED]] : !cir.float -> !cir.bf16
+
+// LLVM: define{{.*}} bfloat @_Z9bf16UPlusDF16b({{.*}})
+// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// LLVM: %[[BF16_PROMOTED:.*]] = fpext bfloat %[[BF16_LOAD]] to float
+// LLVM: %[[BF16_UNPROMOTED:.*]] = fptrunc float %[[BF16_PROMOTED]] to bfloat
+
+// OGCG: define{{.*}} bfloat @_Z9bf16UPlusDF16b({{.*}})
+// OGCG: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// OGCG: %[[BF16_PROMOTED:.*]] = fpext bfloat %[[BF16_LOAD]] to float
+// OGCG: %[[BF16_UNPROMOTED:.*]] = fptrunc float %[[BF16_PROMOTED]] to bfloat
+
+__bf16 bf16UMinus(__bf16 f) {
+ return -f;
+}
+
+// CHECK: cir.func{{.*}} @_Z10bf16UMinusDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CHECK: %[[BF16_PROMOTED:.*]] = cir.cast floating %[[BF16_LOAD]] : !cir.bf16 -> !cir.float
+// CHECK: %[[BF16_NEGATED:.*]] = cir.fneg %[[BF16_PROMOTED]]
+// CHECK: %[[BF16_UNPROMOTED:.*]] = cir.cast floating %[[BF16_NEGATED]] : !cir.float -> !cir.bf16
+
+// LLVM: define{{.*}} bfloat @_Z10bf16UMinusDF16b({{.*}})
+// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// LLVM: %[[BF16_PROMOTED:.*]] = fpext bfloat %[[BF16_LOAD]] to float
+// LLVM: %[[BF16_NEGATED:.*]] = fneg float %[[BF16_PROMOTED]]
+// LLVM: %[[BF16_UNPROMOTED:.*]] = fptrunc float %[[BF16_NEGATED]] to bfloat
+
+// OGCG: define{{.*}} bfloat @_Z10bf16UMinusDF16b({{.*}})
+// OGCG: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// OGCG: %[[BF16_PROMOTED:.*]] = fpext bfloat %[[BF16_LOAD]] to float
+// OGCG: %[[BF16_NEGATED:.*]] = fneg float %[[BF16_PROMOTED]]
+// OGCG: %[[BF16_UNPROMOTED:.*]] = fptrunc float %[[BF16_NEGATED]] to bfloat
+
+__bf16 bf16UPreInc(__bf16 f) {
+ return ++f;
+}
+
+// CHECK: cir.func{{.*}} @_Z11bf16UPreIncDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CHECK: %[[BF16_INC:.*]] = cir.fadd %[[BF16_LOAD]], %{{.*}} : !cir.bf16
+
+// LLVM: define{{.*}} bfloat @_Z11bf16UPreIncDF16b({{.*}})
+// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// LLVM: %[[BF16_INC:.*]] = fadd bfloat %[[BF16_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} bfloat @_Z11bf16UPreIncDF16b({{.*}})
+// OGCG: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// OGCG: %[[BF16_INC:.*]] = fadd bfloat %[[BF16_LOAD]], 1.000000e+00
+
+__bf16 bf16UPreDec(__bf16 f) {
+ return --f;
+}
+
+// CHECK: cir.func{{.*}} @_Z11bf16UPreDecDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CHECK: %[[BF16_DEC:.*]] = cir.fsub %[[BF16_LOAD]], %{{.*}} : !cir.bf16
+
+// LLVM: define{{.*}} bfloat @_Z11bf16UPreDecDF16b({{.*}})
+// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// LLVM: %[[BF16_DEC:.*]] = fsub bfloat %[[BF16_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} bfloat @_Z11bf16UPreDecDF16b({{.*}})
+// OGCG: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// OGCG: %[[BF16_DEC:.*]] = fadd bfloat %[[BF16_LOAD]], -1.000000e+00
+
+__bf16 bf16UPostInc(__bf16 f) {
+ return f++;
+}
+
+// CHECK: cir.func{{.*}} @_Z12bf16UPostIncDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CHECK: %[[BF16_INC:.*]] = cir.fadd %[[BF16_LOAD]], %{{.*}} : !cir.bf16
+
+// LLVM: define{{.*}} bfloat @_Z12bf16UPostIncDF16b({{.*}})
+// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// LLVM: %[[BF16_INC:.*]] = fadd bfloat %[[BF16_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} bfloat @_Z12bf16UPostIncDF16b({{.*}})
+// OGCG: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// OGCG: %[[BF16_INC:.*]] = fadd bfloat %[[BF16_LOAD]], 1.000000e+00
+
+__bf16 bf16UPostDec(__bf16 f) {
+ return f--;
+}
+
+// CHECK: cir.func{{.*}} @_Z12bf16UPostDecDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CHECK: %[[BF16_DEC:.*]] = cir.fsub %[[BF16_LOAD]], %{{.*}} : !cir.bf16
+
+// LLVM: define{{.*}} bfloat @_Z12bf16UPostDecDF16b({{.*}})
+// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// LLVM: %[[BF16_DEC:.*]] = fsub bfloat %[[BF16_LOAD]], 1.000000e+00
+
+// OGCG: define{{.*}} bfloat @_Z12bf16UPostDecDF16b({{.*}})
+// OGCG: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
+// OGCG: %[[BF16_DEC:.*]] = fadd bfloat %[[BF16_LOAD]], -1.000000e+00
+
void test_logical_not() {
int a = 5;
a = !a;
>From 66f2a2095080568d1c5cb3c12965596fe7572fc9 Mon Sep 17 00:00:00 2001
From: Haocong Lu <haocong.lu at witintech.com>
Date: Wed, 9 Sep 2026 15:05:14 +0800
Subject: [PATCH 2/3] address comments
---
clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 20 +-
.../test/CIR/CodeGen/long-double-inc-dec.cpp | 12 +-
.../CIR/CodeGen/unary-inc-dec-unsupport.cpp | 11 -
.../test/CIR/CodeGen/unary-inc-dec-vector.cpp | 153 ----
clang/test/CIR/CodeGen/unary.cpp | 867 +++++++++++-------
5 files changed, 532 insertions(+), 531 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/unary-inc-dec-unsupport.cpp
delete mode 100644 clang/test/CIR/CodeGen/unary-inc-dec-vector.cpp
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index 55c7fe8fb974e..b30e1076e551b 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -826,11 +826,11 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
if (auto vecType = mlir::dyn_cast<cir::VectorType>(input.getType())) {
mlir::Type fpScalarType = vecType.getElementType();
auto fpInterface = mlir::cast<cir::FPTypeInterface>(fpScalarType);
- mlir::Value amount = builder.getConstFP(
- loc, fpScalarType, llvm::APFloat(fpInterface.getFloatSemantics(), 1));
- amount = cir::VecSplatOp::create(builder, loc, vecType, amount);
- return e->isIncrementOp() ? builder.createFAdd(loc, input, amount)
- : builder.createFSub(loc, input, amount);
+ auto amount = llvm::APFloat::getOne(fpInterface.getFloatSemantics(),
+ /*Negative=*/e->isDecrementOp());
+ mlir::Value amtValue = builder.getConstFP(loc, fpScalarType, amount);
+ amtValue = cir::VecSplatOp::create(builder, loc, vecType, amtValue);
+ return builder.createFAdd(loc, input, amtValue);
} else {
QualType type = e->getSubExpr()->getType();
// Another special case: half FP increment should be done via float.
@@ -838,12 +838,10 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
input = builder.createFloatingCast(input, builder.getSingleTy());
auto fpInterface = mlir::cast<cir::FPTypeInterface>(input.getType());
- mlir::Value amount =
- builder.getConstFP(loc, input.getType(),
- llvm::APFloat(fpInterface.getFloatSemantics(), 1));
- mlir::Value output = e->isIncrementOp()
- ? builder.createFAdd(loc, input, amount)
- : builder.createFSub(loc, input, amount);
+ auto amount = llvm::APFloat::getOne(fpInterface.getFloatSemantics(),
+ /*Negative=*/e->isDecrementOp());
+ mlir::Value amtValue = builder.getConstFP(loc, input.getType(), amount);
+ mlir::Value output = builder.createFAdd(loc, input, amtValue);
if (type->isHalfType() && !cgf.getContext().getLangOpts().NativeHalfType)
output = builder.createFloatingCast(output, builder.getFp16Ty());
diff --git a/clang/test/CIR/CodeGen/long-double-inc-dec.cpp b/clang/test/CIR/CodeGen/long-double-inc-dec.cpp
index daf71e5af5a46..a5fa4ff40a7b2 100644
--- a/clang/test/CIR/CodeGen/long-double-inc-dec.cpp
+++ b/clang/test/CIR/CodeGen/long-double-inc-dec.cpp
@@ -85,15 +85,15 @@ extern "C" long double do_pre_dec(long double d) {
return --d;
// CIR: %[[ARG_LOAD:.*]] = cir.load {{.*}}%[[ARG_ALLOCA]] : !cir.ptr<!cir.long_double<![[LDTY]]>>, !cir.long_double<![[LDTY]]>
- // CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<![[LDTY]]>
- // CIR: %[[ARG_DEC:.*]] = cir.fsub %[[ARG_LOAD]], %[[ONE]]
+ // CIR: %[[NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.long_double<![[LDTY]]>
+ // CIR: %[[ARG_DEC:.*]] = cir.fadd %[[ARG_LOAD]], %[[NEGONE]]
// CIR: cir.store{{.*}} %[[ARG_DEC]], %[[ARG_ALLOCA]] : !cir.long_double<![[LDTY]]>, !cir.ptr<!cir.long_double<![[LDTY]]>>
// CIR: cir.store %[[ARG_DEC]], %[[RET_ALLOCA]] : !cir.long_double<![[LDTY]]>, !cir.ptr<!cir.long_double<![[LDTY]]>>
// CIR: %[[LOAD_RET:.*]] = cir.load %[[RET_ALLOCA]]
// CIR: cir.return %[[LOAD_RET]] : !cir.long_double<![[LDTY]]>
//
// LLVM: %[[ARG_LOAD:.*]] = load [[LDTY]], ptr %[[ARG_ALLOCA]]
- // LLVMCIR: %[[ARG_DEC:.*]] = fsub [[LDTY]] %[[ARG_LOAD]], 1.000000e+00
+ // LLVMCIR: %[[ARG_DEC:.*]] = fadd [[LDTY]] %[[ARG_LOAD]], -1.000000e+00
// OGCG: %[[ARG_DEC:.*]] = fadd [[LDTY]] %[[ARG_LOAD]], -1.000000e+00
// LLVM: store [[LDTY]] %[[ARG_DEC]], ptr %[[ARG_ALLOCA]]
// LLVMCIR: store [[LDTY]] %[[ARG_DEC]], ptr %[[RET_ALLOCA]]
@@ -112,15 +112,15 @@ extern "C" long double do_post_dec(long double d) {
return d--;
// CIR: %[[ARG_LOAD:.*]] = cir.load {{.*}}%[[ARG_ALLOCA]] : !cir.ptr<!cir.long_double<![[LDTY]]>>, !cir.long_double<![[LDTY]]>
- // CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<![[LDTY]]>
- // CIR: %[[ARG_DEC:.*]] = cir.fsub %[[ARG_LOAD]], %[[ONE]]
+ // CIR: %[[NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.long_double<![[LDTY]]>
+ // CIR: %[[ARG_DEC:.*]] = cir.fadd %[[ARG_LOAD]], %[[NEGONE]]
// CIR: cir.store{{.*}} %[[ARG_DEC]], %[[ARG_ALLOCA]] : !cir.long_double<![[LDTY]]>, !cir.ptr<!cir.long_double<![[LDTY]]>>
// CIR: cir.store %[[ARG_LOAD]], %[[RET_ALLOCA]] : !cir.long_double<![[LDTY]]>, !cir.ptr<!cir.long_double<![[LDTY]]>>
// CIR: %[[LOAD_RET:.*]] = cir.load %[[RET_ALLOCA]]
// CIR: cir.return %[[LOAD_RET]] : !cir.long_double<![[LDTY]]>
//
// LLVM: %[[ARG_LOAD:.*]] = load [[LDTY]], ptr %[[ARG_ALLOCA]]
- // LLVMCIR: %[[ARG_DEC:.*]] = fsub [[LDTY]] %[[ARG_LOAD]], 1.000000e+00
+ // LLVMCIR: %[[ARG_DEC:.*]] = fadd [[LDTY]] %[[ARG_LOAD]], -1.000000e+00
// OGCG: %[[ARG_DEC:.*]] = fadd [[LDTY]] %[[ARG_LOAD]], -1.000000e+00
// LLVM: store [[LDTY]] %[[ARG_DEC]], ptr %[[ARG_ALLOCA]]
// LLVMCIR: store [[LDTY]] %[[ARG_LOAD]], ptr %[[RET_ALLOCA]]
diff --git a/clang/test/CIR/CodeGen/unary-inc-dec-unsupport.cpp b/clang/test/CIR/CodeGen/unary-inc-dec-unsupport.cpp
deleted file mode 100644
index 58cf166eee2b9..0000000000000
--- a/clang/test/CIR/CodeGen/unary-inc-dec-unsupport.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc64le -fclangir -emit-cir -verify %s -o -
-
-// PPC fp128 (__ibm128) unary inc/dec is not yet supported, drop the errorNYI
-// and turn this into a regular test.
-
-__ibm128 g; // expected-error@*:* {{ClangIR code gen Not Yet Implemented: processing of built-in type: '__ibm128'}}
-
-void test_pre_inc() { ++g; }
-void test_pre_dec() { --g; }
-void test_post_inc() { g++; }
-void test_post_dec() { g--; }
diff --git a/clang/test/CIR/CodeGen/unary-inc-dec-vector.cpp b/clang/test/CIR/CodeGen/unary-inc-dec-vector.cpp
deleted file mode 100644
index 5b5bf72af369d..0000000000000
--- a/clang/test/CIR/CodeGen/unary-inc-dec-vector.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc64le -target-feature +altivec -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
-// RUN: %clang_cc1 -triple powerpc64le -target-feature +altivec -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
-// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
-// RUN: %clang_cc1 -triple powerpc64le -target-feature +altivec -Wno-unused-value -emit-llvm %s -o %t.ll
-// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
-
-// Unary inc/dec on vector types, covering the CIRGenExprScalar.cpp vector
-// branch:
-// * integer vectors go through emitIntIncOrDec -> cir.inc/cir.dec
-// * float vectors go through emitFloatIncOrDec -> cir.fadd/cir.fsub
-
-typedef int vi4 __attribute__((vector_size(16)));
-typedef unsigned uvi4 __attribute__((vector_size(16)));
-typedef short vsh8 __attribute__((vector_size(16)));
-typedef float vf4 __attribute__((vector_size(16)));
-typedef double vd2 __attribute__((vector_size(16)));
-
-void vecIntIncDec(vi4 a) {
- ++a;
- --a;
- a++;
- a--;
-}
-// CIR-LABEL: @_Z12vecIntIncDecDv4_i
-// CIR: cir.inc %{{.+}} : !cir.vector<4 x !s32i>
-// CIR: cir.dec %{{.+}} : !cir.vector<4 x !s32i>
-// CIR: cir.inc %{{.+}} : !cir.vector<4 x !s32i>
-// CIR: cir.dec %{{.+}} : !cir.vector<4 x !s32i>
-
-// LLVM-LABEL: @_Z12vecIntIncDecDv4_i
-// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
-// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
-// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
-// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
-
-// OGCG-LABEL: @_Z12vecIntIncDecDv4_i
-// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
-// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
-// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
-// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
-
-void vecUIntIncDec(uvi4 b) {
- ++b;
- --b;
- b++;
- b--;
-}
-// CIR-LABEL: @_Z13vecUIntIncDecDv4_j
-// CIR: cir.inc %{{.+}} : !cir.vector<4 x !u32i>
-// CIR: cir.dec %{{.+}} : !cir.vector<4 x !u32i>
-// CIR: cir.inc %{{.+}} : !cir.vector<4 x !u32i>
-// CIR: cir.dec %{{.+}} : !cir.vector<4 x !u32i>
-
-// LLVM-LABEL: @_Z13vecUIntIncDecDv4_j
-// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
-// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
-// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
-// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
-
-// OGCG-LABEL: @_Z13vecUIntIncDecDv4_j
-// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
-// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
-// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
-// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
-
-void vecShortIncDec(vsh8 c) {
- ++c;
- --c;
- c++;
- c--;
-}
-// CIR-LABEL: @_Z14vecShortIncDecDv8_s
-// CIR: cir.inc %{{.+}} : !cir.vector<8 x !s16i>
-// CIR: cir.dec %{{.+}} : !cir.vector<8 x !s16i>
-// CIR: cir.inc %{{.+}} : !cir.vector<8 x !s16i>
-// CIR: cir.dec %{{.+}} : !cir.vector<8 x !s16i>
-
-// LLVM-LABEL: @_Z14vecShortIncDecDv8_s
-// LLVM: add <8 x i16> %{{.+}}, splat (i16 1)
-// LLVM: sub <8 x i16> %{{.+}}, splat (i16 1)
-// LLVM: add <8 x i16> %{{.+}}, splat (i16 1)
-// LLVM: sub <8 x i16> %{{.+}}, splat (i16 1)
-
-// OGCG-LABEL: @_Z14vecShortIncDecDv8_s
-// OGCG: add <8 x i16> %{{.+}}, splat (i16 1)
-// OGCG: add <8 x i16> %{{.+}}, splat (i16 -1)
-// OGCG: add <8 x i16> %{{.+}}, splat (i16 1)
-// OGCG: add <8 x i16> %{{.+}}, splat (i16 -1)
-
-void vecFloatIncDec(vf4 a) {
- ++a;
- --a;
- a++;
- a--;
-}
-// CIR-LABEL: @_Z14vecFloatIncDecDv4_f
-// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
-// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
-// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
-// CIR: cir.fsub %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
-// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
-// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
-// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
-// CIR: cir.fsub %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
-
-// LLVM-LABEL: @_Z14vecFloatIncDecDv4_f
-// LLVM: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
-// LLVM: fsub <4 x float> %{{.+}}, splat (float 1.000000e+00)
-// LLVM: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
-// LLVM: fsub <4 x float> %{{.+}}, splat (float 1.000000e+00)
-
-// OGCG-LABEL: @_Z14vecFloatIncDecDv4_f
-// OGCG: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
-// OGCG: fadd <4 x float> %{{.+}}, splat (float -1.000000e+00)
-// OGCG: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
-// OGCG: fadd <4 x float> %{{.+}}, splat (float -1.000000e+00)
-
-void vecDoubleIncDec(vd2 b) {
- ++b;
- --b;
- b++;
- b--;
-}
-// CIR-LABEL: @_Z15vecDoubleIncDecDv2_d
-// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
-// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
-// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
-// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
-// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
-// CIR: cir.fsub %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
-// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
-// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
-// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
-// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
-// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
-// CIR: cir.fsub %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
-
-// LLVM-LABEL: @_Z15vecDoubleIncDecDv2_d
-// LLVM: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
-// LLVM: fsub <2 x double> %{{.+}}, splat (double 1.000000e+00)
-// LLVM: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
-// LLVM: fsub <2 x double> %{{.+}}, splat (double 1.000000e+00)
-
-// OGCG-LABEL: @_Z15vecDoubleIncDecDv2_d
-// OGCG: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
-// OGCG: fadd <2 x double> %{{.+}}, splat (double -1.000000e+00)
-// OGCG: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
-// OGCG: fadd <2 x double> %{{.+}}, splat (double -1.000000e+00)
diff --git a/clang/test/CIR/CodeGen/unary.cpp b/clang/test/CIR/CodeGen/unary.cpp
index 84a07691ce85b..06569d63bf484 100644
--- a/clang/test/CIR/CodeGen/unary.cpp
+++ b/clang/test/CIR/CodeGen/unary.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value -emit-llvm %s -o %t-cir.ll
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fzvector -fclangir -Wno-unused-value -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fzvector -fclangir -Wno-unused-value -emit-llvm %s -o %t-cir.ll
// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fzvector -Wno-unused-value -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG
unsigned up0() {
@@ -10,9 +10,9 @@ unsigned up0() {
return +a;
}
-// CHECK: cir.func{{.*}} @_Z3up0v() -> (!u32i{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!u32i>
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: cir.func{{.*}} @_Z3up0v() -> (!u32i{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!u32i>
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
// LLVM: define{{.*}} i32 @_Z3up0v()
// LLVM: %[[RV:.*]] = alloca i32, align 4
@@ -30,10 +30,10 @@ unsigned um0() {
return -a;
}
-// CHECK: cir.func{{.*}} @_Z3um0v() -> (!u32i{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!u32i>
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[OUTPUT:.*]] = cir.minus %[[INPUT]]
+// CIR: cir.func{{.*}} @_Z3um0v() -> (!u32i{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!u32i>
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[OUTPUT:.*]] = cir.minus %[[INPUT]]
// LLVM: define{{.*}} i32 @_Z3um0v()
// LLVM: %[[RV:.*]] = alloca i32, align 4
@@ -53,10 +53,10 @@ unsigned un0() {
return ~a; // a ^ -1 , not
}
-// CHECK: cir.func{{.*}} @_Z3un0v() -> (!u32i{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!u32i>
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[OUTPUT:.*]] = cir.not %[[INPUT]]
+// CIR: cir.func{{.*}} @_Z3un0v() -> (!u32i{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!u32i>
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[OUTPUT:.*]] = cir.not %[[INPUT]]
// LLVM: define{{.*}} i32 @_Z3un0v()
// LLVM: %[[RV:.*]] = alloca i32, align 4
@@ -77,14 +77,14 @@ int inc0() {
return a;
}
-// CHECK: cir.func{{.*}} @_Z4inc0v() -> (!s32i{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[INCREMENTED:.*]] = cir.inc nsw %[[INPUT]]
-// CHECK: cir.store{{.*}} %[[INCREMENTED]], %[[A]]
-// CHECK: %[[A_TO_OUTPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: cir.func{{.*}} @_Z4inc0v() -> (!s32i{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
+// CIR: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[INCREMENTED:.*]] = cir.inc nsw %[[INPUT]]
+// CIR: cir.store{{.*}} %[[INCREMENTED]], %[[A]]
+// CIR: %[[A_TO_OUTPUT:.*]] = cir.load{{.*}} %[[A]]
// LLVM: define{{.*}} i32 @_Z4inc0v()
// LLVM: %[[RV:.*]] = alloca i32, align 4
@@ -105,14 +105,14 @@ int dec0() {
return a;
}
-// CHECK: cir.func{{.*}} @_Z4dec0v() -> (!s32i{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[DECREMENTED:.*]] = cir.dec nsw %[[INPUT]]
-// CHECK: cir.store{{.*}} %[[DECREMENTED]], %[[A]]
-// CHECK: %[[A_TO_OUTPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: cir.func{{.*}} @_Z4dec0v() -> (!s32i{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
+// CIR: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[DECREMENTED:.*]] = cir.dec nsw %[[INPUT]]
+// CIR: cir.store{{.*}} %[[DECREMENTED]], %[[A]]
+// CIR: %[[A_TO_OUTPUT:.*]] = cir.load{{.*}} %[[A]]
// LLVM: define{{.*}} i32 @_Z4dec0v()
// LLVM: %[[RV:.*]] = alloca i32, align 4
@@ -133,14 +133,14 @@ int inc1() {
return a;
}
-// CHECK: cir.func{{.*}} @_Z4inc1v() -> (!s32i{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[INCREMENTED:.*]] = cir.inc nsw %[[INPUT]]
-// CHECK: cir.store{{.*}} %[[INCREMENTED]], %[[A]]
-// CHECK: %[[A_TO_OUTPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: cir.func{{.*}} @_Z4inc1v() -> (!s32i{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
+// CIR: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[INCREMENTED:.*]] = cir.inc nsw %[[INPUT]]
+// CIR: cir.store{{.*}} %[[INCREMENTED]], %[[A]]
+// CIR: %[[A_TO_OUTPUT:.*]] = cir.load{{.*}} %[[A]]
// LLVM: define{{.*}} i32 @_Z4inc1v()
// LLVM: %[[RV:.*]] = alloca i32, align 4
@@ -161,14 +161,14 @@ int dec1() {
return a;
}
-// CHECK: cir.func{{.*}} @_Z4dec1v() -> (!s32i{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[DECREMENTED:.*]] = cir.dec nsw %[[INPUT]]
-// CHECK: cir.store{{.*}} %[[DECREMENTED]], %[[A]]
-// CHECK: %[[A_TO_OUTPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: cir.func{{.*}} @_Z4dec1v() -> (!s32i{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
+// CIR: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[DECREMENTED:.*]] = cir.dec nsw %[[INPUT]]
+// CIR: cir.store{{.*}} %[[DECREMENTED]], %[[A]]
+// CIR: %[[A_TO_OUTPUT:.*]] = cir.load{{.*}} %[[A]]
// LLVM: define{{.*}} i32 @_Z4dec1v()
// LLVM: %[[RV:.*]] = alloca i32, align 4
@@ -190,16 +190,16 @@ int inc2() {
return b;
}
-// CHECK: cir.func{{.*}} @_Z4inc2v() -> (!s32i{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
-// CHECK: %[[B:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!s32i>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
-// CHECK: %[[ATOB:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[INCREMENTED:.*]] = cir.inc nsw %[[ATOB]]
-// CHECK: cir.store{{.*}} %[[INCREMENTED]], %[[A]]
-// CHECK: cir.store{{.*}} %[[ATOB]], %[[B]]
-// CHECK: %[[B_TO_OUTPUT:.*]] = cir.load{{.*}} %[[B]]
+// CIR: cir.func{{.*}} @_Z4inc2v() -> (!s32i{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
+// CIR: %[[B:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!s32i>
+// CIR: %[[ATMP:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !s32i
+// CIR: %[[ATOB:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[INCREMENTED:.*]] = cir.inc nsw %[[ATOB]]
+// CIR: cir.store{{.*}} %[[INCREMENTED]], %[[A]]
+// CIR: cir.store{{.*}} %[[ATOB]], %[[B]]
+// CIR: %[[B_TO_OUTPUT:.*]] = cir.load{{.*}} %[[B]]
// LLVM: define{{.*}} i32 @_Z4inc2v()
// LLVM: %[[RV:.*]] = alloca i32, align 4
@@ -222,32 +222,52 @@ int inc2() {
// OGCG: store i32 %[[A_LOAD]], ptr %[[B]], align 4
// OGCG: %[[B_TO_OUTPUT:.*]] = load i32, ptr %[[B]], align 4
+// Chars can go through some integer promotion codegen paths even when not promoted.
+// These should not have nsw attributes because the intermediate promotion makes the
+// overflow defined behavior.
void chars(char c) {
-// CHECK: cir.func{{.*}} @_Z5charsc
-
int c1 = +c;
- // CHECK: %[[PROMO:.*]] = cir.cast integral %{{.+}} : !s8i -> !s32i
int c2 = -c;
- // CHECK: %[[PROMO:.*]] = cir.cast integral %{{.+}} : !s8i -> !s32i
- // CHECK: cir.minus nsw %[[PROMO]] : !s32i
-
- // Chars can go through some integer promotion codegen paths even when not promoted.
- // These should not have nsw attributes because the intermediate promotion makes the
- // overflow defined behavior.
- ++c; // CHECK: cir.inc %{{.+}} : !s8i
- --c; // CHECK: cir.dec %{{.+}} : !s8i
- c++; // CHECK: cir.inc %{{.+}} : !s8i
- c--; // CHECK: cir.dec %{{.+}} : !s8i
+ ++c;
+ --c;
+ c++;
+ c--;
}
+// CIR: cir.func{{.*}} @_Z5charsc
+// CIR: %[[PROMO1:.*]] = cir.cast integral %{{.+}} : !s8i -> !s32i
+// CIR: %[[PROMO2:.*]] = cir.cast integral %{{.+}} : !s8i -> !s32i
+// CIR: cir.minus nsw %[[PROMO2]] : !s32i
+// CIR: cir.inc %{{.+}} : !s8i
+// CIR: cir.dec %{{.+}} : !s8i
+// CIR: cir.inc %{{.+}} : !s8i
+// CIR: cir.dec %{{.+}} : !s8i
+
+// LLVM: define{{.*}} void @_Z5charsc
+// LLVM: %[[PROMO1:.*]] = sext i8 %{{.+}} to i32
+// LLVM: %[[PROMO2:.*]] = sext i8 %{{.+}} to i32
+// LLVM: %[[MINUS:.*]] = sub nsw i32 0, %[[PROMO2]]
+// LLVM: add i8 %{{.+}}, 1
+// LLVM: sub i8 %{{.+}}, 1
+// LLVM: add i8 %{{.+}}, 1
+// LLVM: sub i8 %{{.+}}, 1
+
+// OGCG: define{{.*}} void @_Z5charsc
+// OGCG: %[[PROMO1:.*]] = sext i8 %{{.+}} to i32
+// OGCG: %[[PROMO2:.*]] = sext i8 %{{.+}} to i32
+// OGCG: %[[MINUS:.*]] = sub nsw i32 0, %[[PROMO2]]
+// OGCG: add i8 %{{.+}}, 1
+// OGCG: add i8 %{{.+}}, -1
+// OGCG: add i8 %{{.+}}, 1
+// OGCG: add i8 %{{.+}}, -1
float fpPlus() {
float a = 1.0f;
return +a;
}
-// CHECK: cir.func{{.*}} @_Z6fpPlusv() -> (!cir.float{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: cir.func{{.*}} @_Z6fpPlusv() -> (!cir.float{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
// LLVM: define{{.*}} float @_Z6fpPlusv()
// LLVM: %[[RV:.*]] = alloca float, align 4
@@ -265,10 +285,10 @@ float fpMinus() {
return -a;
}
-// CHECK: cir.func{{.*}} @_Z7fpMinusv() -> (!cir.float{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[OUTPUT:.*]] = cir.fneg %[[INPUT]]
+// CIR: cir.func{{.*}} @_Z7fpMinusv() -> (!cir.float{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[OUTPUT:.*]] = cir.fneg %[[INPUT]]
// LLVM: define{{.*}} float @_Z7fpMinusv()
// LLVM: %[[RV:.*]] = alloca float, align 4
@@ -288,13 +308,13 @@ float fpPreInc() {
return ++a;
}
-// CHECK: cir.func{{.*}} @_Z8fpPreIncv() -> (!cir.float{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: %[[INCREMENTED:.*]] = cir.fadd %[[INPUT]], %[[ONE]]
+// CIR: cir.func{{.*}} @_Z8fpPreIncv() -> (!cir.float{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
+// CIR: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[INCREMENTED:.*]] = cir.fadd %[[INPUT]], %[[ONE]]
// LLVM: define{{.*}} float @_Z8fpPreIncv()
// LLVM: %[[RV:.*]] = alloca float, align 4
@@ -314,20 +334,20 @@ float fpPreDec() {
return --a;
}
-// CHECK: cir.func{{.*}} @_Z8fpPreDecv() -> (!cir.float{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: %[[DECREMENTED:.*]] = cir.fsub %[[INPUT]], %[[ONE]]
+// CIR: cir.func{{.*}} @_Z8fpPreDecv() -> (!cir.float{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
+// CIR: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.float
+// CIR: %[[DECREMENTED:.*]] = cir.fadd %[[INPUT]], %[[NEGONE]]
// LLVM: define{{.*}} float @_Z8fpPreDecv()
// LLVM: %[[RV:.*]] = alloca float, align 4
// LLVM: %[[A:.*]] = alloca float, align 4
// LLVM: store float 1.000000e+00, ptr %[[A]], align 4
// LLVM: %[[A_LOAD:.*]] = load float, ptr %[[A]], align 4
-// LLVM: %[[RESULT:.*]] = fsub float %[[A_LOAD]], 1.000000e+00
+// LLVM: %[[RESULT:.*]] = fadd float %[[A_LOAD]], -1.000000e+00
// OGCG: define{{.*}} float @_Z8fpPreDecv()
// OGCG: %[[A:.*]] = alloca float, align 4
@@ -340,13 +360,13 @@ float fpPostInc() {
return a++;
}
-// CHECK: cir.func{{.*}} @_Z9fpPostIncv() -> (!cir.float{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: %[[INCREMENTED:.*]] = cir.fadd %[[INPUT]], %[[ONE]]
+// CIR: cir.func{{.*}} @_Z9fpPostIncv() -> (!cir.float{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
+// CIR: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[INCREMENTED:.*]] = cir.fadd %[[INPUT]], %[[ONE]]
// LLVM: define{{.*}} float @_Z9fpPostIncv()
// LLVM: %[[RV:.*]] = alloca float, align 4
@@ -366,20 +386,20 @@ float fpPostDec() {
return a--;
}
-// CHECK: cir.func{{.*}} @_Z9fpPostDecv() -> (!cir.float{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: %[[DECREMENTED:.*]] = cir.fsub %[[INPUT]], %[[ONE]]
+// CIR: cir.func{{.*}} @_Z9fpPostDecv() -> (!cir.float{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
+// CIR: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.float
+// CIR: %[[DECREMENTED:.*]] = cir.fadd %[[INPUT]], %[[NEGONE]]
// LLVM: define{{.*}} float @_Z9fpPostDecv()
// LLVM: %[[RV:.*]] = alloca float, align 4
// LLVM: %[[A:.*]] = alloca float, align 4
// LLVM: store float 1.000000e+00, ptr %[[A]], align 4
// LLVM: %[[A_LOAD:.*]] = load float, ptr %[[A]], align 4
-// LLVM: %[[RESULT:.*]] = fsub float %[[A_LOAD]], 1.000000e+00
+// LLVM: %[[RESULT:.*]] = fadd float %[[A_LOAD]], -1.000000e+00
// OGCG: define{{.*}} float @_Z9fpPostDecv()
// OGCG: %[[A:.*]] = alloca float, align 4
@@ -394,17 +414,17 @@ float fpPostInc2() {
return b;
}
-// CHECK: cir.func{{.*}} @_Z10fpPostInc2v() -> (!cir.float{{.*}})
-// CHECK: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
-// CHECK: %[[B:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!cir.float>
-// CHECK: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
-// CHECK: %[[ATOB:.*]] = cir.load{{.*}} %[[A]]
-// CHECK: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: %[[INCREMENTED:.*]] = cir.fadd %[[ATOB]], %[[ONE]]
-// CHECK: cir.store{{.*}} %[[INCREMENTED]], %[[A]]
-// CHECK: cir.store{{.*}} %[[ATOB]], %[[B]]
-// CHECK: %[[B_TO_OUTPUT:.*]] = cir.load{{.*}} %[[B]]
+// CIR: cir.func{{.*}} @_Z10fpPostInc2v() -> (!cir.float{{.*}})
+// CIR: %[[A:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.float>
+// CIR: %[[B:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!cir.float>
+// CIR: %[[ATMP:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: cir.store{{.*}} %[[ATMP]], %[[A]] : !cir.float
+// CIR: %[[ATOB:.*]] = cir.load{{.*}} %[[A]]
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[INCREMENTED:.*]] = cir.fadd %[[ATOB]], %[[ONE]]
+// CIR: cir.store{{.*}} %[[INCREMENTED]], %[[A]]
+// CIR: cir.store{{.*}} %[[ATOB]], %[[B]]
+// CIR: %[[B_TO_OUTPUT:.*]] = cir.load{{.*}} %[[B]]
// LLVM: define{{.*}} float @_Z10fpPostInc2v()
// LLVM: %[[RV:.*]] = alloca float, align 4
@@ -432,9 +452,9 @@ double doubleUPlus(double f) {
return +f;
}
-// CHECK: cir.func{{.*}} @_Z11doubleUPlusd({{.*}}) -> (!cir.double{{.*}})
-// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
-// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CIR: cir.func{{.*}} @_Z11doubleUPlusd({{.*}}) -> (!cir.double{{.*}})
+// CIR: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CIR: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
// LLVM: define{{.*}} double @_Z11doubleUPlusd({{.*}})
// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
@@ -446,10 +466,10 @@ double doubleUMinus(double f) {
return -f;
}
-// CHECK: cir.func{{.*}} @_Z12doubleUMinusd({{.*}}) -> (!cir.double{{.*}})
-// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
-// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
-// CHECK: %[[DBL_NEGATED:.*]] = cir.fneg %[[DBL_LOAD]]
+// CIR: cir.func{{.*}} @_Z12doubleUMinusd({{.*}}) -> (!cir.double{{.*}})
+// CIR: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CIR: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CIR: %[[DBL_NEGATED:.*]] = cir.fneg %[[DBL_LOAD]]
// LLVM: define{{.*}} double @_Z12doubleUMinusd({{.*}})
// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
@@ -463,11 +483,11 @@ double doubleUPreInc(double f) {
return ++f;
}
-// CHECK: cir.func{{.*}} @_Z13doubleUPreIncd({{.*}}) -> (!cir.double{{.*}})
-// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
-// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
-// CHECK: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
-// CHECK: %[[DBL_INC:.*]] = cir.fadd %[[DBL_LOAD]], %[[DBL_ONE]]
+// CIR: cir.func{{.*}} @_Z13doubleUPreIncd({{.*}}) -> (!cir.double{{.*}})
+// CIR: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CIR: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CIR: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CIR: %[[DBL_INC:.*]] = cir.fadd %[[DBL_LOAD]], %[[DBL_ONE]]
// LLVM: define{{.*}} double @_Z13doubleUPreIncd({{.*}})
// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
@@ -481,15 +501,15 @@ double doubleUPreDec(double f) {
return --f;
}
-// CHECK: cir.func{{.*}} @_Z13doubleUPreDecd({{.*}}) -> (!cir.double{{.*}})
-// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
-// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
-// CHECK: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
-// CHECK: %[[DBL_DEC:.*]] = cir.fsub %[[DBL_LOAD]], %[[DBL_ONE]]
+// CIR: cir.func{{.*}} @_Z13doubleUPreDecd({{.*}}) -> (!cir.double{{.*}})
+// CIR: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CIR: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CIR: %[[DBL_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.double
+// CIR: %[[DBL_DEC:.*]] = cir.fadd %[[DBL_LOAD]], %[[DBL_NEGONE]]
// LLVM: define{{.*}} double @_Z13doubleUPreDecd({{.*}})
// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
-// LLVM: %[[DBL_DEC:.*]] = fsub double %[[DBL_LOAD]], 1.000000e+00
+// LLVM: %[[DBL_DEC:.*]] = fadd double %[[DBL_LOAD]], -1.000000e+00
// OGCG: define{{.*}} double @_Z13doubleUPreDecd({{.*}})
// OGCG: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
@@ -499,11 +519,11 @@ double doubleUPostInc(double f) {
return f++;
}
-// CHECK: cir.func{{.*}} @_Z14doubleUPostIncd({{.*}}) -> (!cir.double{{.*}})
-// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
-// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
-// CHECK: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
-// CHECK: %[[DBL_INC:.*]] = cir.fadd %[[DBL_LOAD]], %[[DBL_ONE]]
+// CIR: cir.func{{.*}} @_Z14doubleUPostIncd({{.*}}) -> (!cir.double{{.*}})
+// CIR: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CIR: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CIR: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CIR: %[[DBL_INC:.*]] = cir.fadd %[[DBL_LOAD]], %[[DBL_ONE]]
// LLVM: define{{.*}} double @_Z14doubleUPostIncd({{.*}})
// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
@@ -517,15 +537,15 @@ double doubleUPostDec(double f) {
return f--;
}
-// CHECK: cir.func{{.*}} @_Z14doubleUPostDecd({{.*}}) -> (!cir.double{{.*}})
-// CHECK: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
-// CHECK: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
-// CHECK: %[[DBL_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
-// CHECK: %[[DBL_DEC:.*]] = cir.fsub %[[DBL_LOAD]], %[[DBL_ONE]]
+// CIR: cir.func{{.*}} @_Z14doubleUPostDecd({{.*}}) -> (!cir.double{{.*}})
+// CIR: %[[DBL_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.double>
+// CIR: %[[DBL_LOAD:.*]] = cir.load{{.*}} %[[DBL_F]]
+// CIR: %[[DBL_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.double
+// CIR: %[[DBL_DEC:.*]] = cir.fadd %[[DBL_LOAD]], %[[DBL_NEGONE]]
// LLVM: define{{.*}} double @_Z14doubleUPostDecd({{.*}})
// LLVM: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
-// LLVM: %[[DBL_DEC:.*]] = fsub double %[[DBL_LOAD]], 1.000000e+00
+// LLVM: %[[DBL_DEC:.*]] = fadd double %[[DBL_LOAD]], -1.000000e+00
// OGCG: define{{.*}} double @_Z14doubleUPostDecd({{.*}})
// OGCG: %[[DBL_LOAD:.*]] = load double, ptr %{{.*}}, align 8
@@ -536,9 +556,9 @@ long double ldUPlus(long double f) {
return +f;
}
-// CHECK: cir.func{{.*}} @_Z7ldUPluse({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
-// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
-// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CIR: cir.func{{.*}} @_Z7ldUPluse({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CIR: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CIR: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
// LLVM: define{{.*}} x86_fp80 @_Z7ldUPluse({{.*}})
// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
@@ -550,10 +570,10 @@ long double ldUMinus(long double f) {
return -f;
}
-// CHECK: cir.func{{.*}} @_Z8ldUMinuse({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
-// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
-// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
-// CHECK: %[[LD_NEGATED:.*]] = cir.fneg %[[LD_LOAD]]
+// CIR: cir.func{{.*}} @_Z8ldUMinuse({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CIR: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CIR: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CIR: %[[LD_NEGATED:.*]] = cir.fneg %[[LD_LOAD]]
// LLVM: define{{.*}} x86_fp80 @_Z8ldUMinuse({{.*}})
// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
@@ -567,11 +587,11 @@ long double ldUPreInc(long double f) {
return ++f;
}
-// CHECK: cir.func{{.*}} @_Z9ldUPreInce({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
-// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
-// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
-// CHECK: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
-// CHECK: %[[LD_INC:.*]] = cir.fadd %[[LD_LOAD]], %[[LD_ONE]]
+// CIR: cir.func{{.*}} @_Z9ldUPreInce({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CIR: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CIR: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CIR: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
+// CIR: %[[LD_INC:.*]] = cir.fadd %[[LD_LOAD]], %[[LD_ONE]]
// LLVM: define{{.*}} x86_fp80 @_Z9ldUPreInce({{.*}})
// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
@@ -585,15 +605,15 @@ long double ldUPreDec(long double f) {
return --f;
}
-// CHECK: cir.func{{.*}} @_Z9ldUPreDece({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
-// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
-// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
-// CHECK: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
-// CHECK: %[[LD_DEC:.*]] = cir.fsub %[[LD_LOAD]], %[[LD_ONE]]
+// CIR: cir.func{{.*}} @_Z9ldUPreDece({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CIR: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CIR: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CIR: %[[LD_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.long_double<!cir.f80>
+// CIR: %[[LD_DEC:.*]] = cir.fadd %[[LD_LOAD]], %[[LD_NEGONE]]
// LLVM: define{{.*}} x86_fp80 @_Z9ldUPreDece({{.*}})
// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
-// LLVM: %[[LD_DEC:.*]] = fsub x86_fp80 %[[LD_LOAD]], 1.000000e+00
+// LLVM: %[[LD_DEC:.*]] = fadd x86_fp80 %[[LD_LOAD]], -1.000000e+00
// OGCG: define{{.*}} x86_fp80 @_Z9ldUPreDece({{.*}})
// OGCG: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
@@ -603,11 +623,11 @@ long double ldUPostInc(long double f) {
return f++;
}
-// CHECK: cir.func{{.*}} @_Z10ldUPostInce({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
-// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
-// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
-// CHECK: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
-// CHECK: %[[LD_INC:.*]] = cir.fadd %[[LD_LOAD]], %[[LD_ONE]]
+// CIR: cir.func{{.*}} @_Z10ldUPostInce({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CIR: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CIR: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CIR: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
+// CIR: %[[LD_INC:.*]] = cir.fadd %[[LD_LOAD]], %[[LD_ONE]]
// LLVM: define{{.*}} x86_fp80 @_Z10ldUPostInce({{.*}})
// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
@@ -621,15 +641,15 @@ long double ldUPostDec(long double f) {
return f--;
}
-// CHECK: cir.func{{.*}} @_Z10ldUPostDece({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
-// CHECK: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
-// CHECK: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
-// CHECK: %[[LD_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.long_double<!cir.f80>
-// CHECK: %[[LD_DEC:.*]] = cir.fsub %[[LD_LOAD]], %[[LD_ONE]]
+// CIR: cir.func{{.*}} @_Z10ldUPostDece({{.*}}) -> (!cir.long_double<!cir.f80>{{.*}})
+// CIR: %[[LD_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.long_double<!cir.f80>>
+// CIR: %[[LD_LOAD:.*]] = cir.load{{.*}} %[[LD_F]]
+// CIR: %[[LD_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.long_double<!cir.f80>
+// CIR: %[[LD_DEC:.*]] = cir.fadd %[[LD_LOAD]], %[[LD_NEGONE]]
// LLVM: define{{.*}} x86_fp80 @_Z10ldUPostDece({{.*}})
// LLVM: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
-// LLVM: %[[LD_DEC:.*]] = fsub x86_fp80 %[[LD_LOAD]], 1.000000e+00
+// LLVM: %[[LD_DEC:.*]] = fadd x86_fp80 %[[LD_LOAD]], -1.000000e+00
// OGCG: define{{.*}} x86_fp80 @_Z10ldUPostDece({{.*}})
// OGCG: %[[LD_LOAD:.*]] = load x86_fp80, ptr %{{.*}}, align 16
@@ -640,9 +660,9 @@ __float128 f128UPlus(__float128 f) {
return +f;
}
-// CHECK: cir.func{{.*}} @_Z9f128UPlusg({{.*}}) -> (!cir.f128{{.*}})
-// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
-// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CIR: cir.func{{.*}} @_Z9f128UPlusg({{.*}}) -> (!cir.f128{{.*}})
+// CIR: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CIR: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
// LLVM: define{{.*}} fp128 @_Z9f128UPlusg({{.*}})
// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
@@ -654,10 +674,10 @@ __float128 f128UMinus(__float128 f) {
return -f;
}
-// CHECK: cir.func{{.*}} @_Z10f128UMinusg({{.*}}) -> (!cir.f128{{.*}})
-// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
-// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
-// CHECK: %[[F128_NEG:.*]] = cir.fneg %[[F128_LOAD]]
+// CIR: cir.func{{.*}} @_Z10f128UMinusg({{.*}}) -> (!cir.f128{{.*}})
+// CIR: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CIR: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CIR: %[[F128_NEG:.*]] = cir.fneg %[[F128_LOAD]]
// LLVM: define{{.*}} fp128 @_Z10f128UMinusg({{.*}})
// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
@@ -671,11 +691,11 @@ __float128 f128UPreInc(__float128 f) {
return ++f;
}
-// CHECK: cir.func{{.*}} @_Z11f128UPreIncg({{.*}}) -> (!cir.f128{{.*}})
-// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
-// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
-// CHECK: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
-// CHECK: %[[F128_INC:.*]] = cir.fadd %[[F128_LOAD]], %[[F128_ONE]]
+// CIR: cir.func{{.*}} @_Z11f128UPreIncg({{.*}}) -> (!cir.f128{{.*}})
+// CIR: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CIR: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CIR: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
+// CIR: %[[F128_INC:.*]] = cir.fadd %[[F128_LOAD]], %[[F128_ONE]]
// LLVM: define{{.*}} fp128 @_Z11f128UPreIncg({{.*}})
// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
@@ -689,15 +709,15 @@ __float128 f128UPreDec(__float128 f) {
return --f;
}
-// CHECK: cir.func{{.*}} @_Z11f128UPreDecg({{.*}}) -> (!cir.f128{{.*}})
-// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
-// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
-// CHECK: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
-// CHECK: %[[F128_DEC:.*]] = cir.fsub %[[F128_LOAD]], %[[F128_ONE]]
+// CIR: cir.func{{.*}} @_Z11f128UPreDecg({{.*}}) -> (!cir.f128{{.*}})
+// CIR: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CIR: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CIR: %[[F128_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.f128
+// CIR: %[[F128_DEC:.*]] = cir.fadd %[[F128_LOAD]], %[[F128_NEGONE]]
// LLVM: define{{.*}} fp128 @_Z11f128UPreDecg({{.*}})
// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
-// LLVM: %[[F128_DEC:.*]] = fsub fp128 %[[F128_LOAD]], 1.000000e+00
+// LLVM: %[[F128_DEC:.*]] = fadd fp128 %[[F128_LOAD]], -1.000000e+00
// OGCG: define{{.*}} fp128 @_Z11f128UPreDecg({{.*}})
// OGCG: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
@@ -707,11 +727,11 @@ __float128 f128UPostInc(__float128 f) {
return f++;
}
-// CHECK: cir.func{{.*}} @_Z12f128UPostIncg({{.*}}) -> (!cir.f128{{.*}})
-// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
-// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
-// CHECK: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
-// CHECK: %[[F128_INC:.*]] = cir.fadd %[[F128_LOAD]], %[[F128_ONE]]
+// CIR: cir.func{{.*}} @_Z12f128UPostIncg({{.*}}) -> (!cir.f128{{.*}})
+// CIR: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CIR: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CIR: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
+// CIR: %[[F128_INC:.*]] = cir.fadd %[[F128_LOAD]], %[[F128_ONE]]
// LLVM: define{{.*}} fp128 @_Z12f128UPostIncg({{.*}})
// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
@@ -725,15 +745,15 @@ __float128 f128UPostDec(__float128 f) {
return f--;
}
-// CHECK: cir.func{{.*}} @_Z12f128UPostDecg({{.*}}) -> (!cir.f128{{.*}})
-// CHECK: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
-// CHECK: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
-// CHECK: %[[F128_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f128
-// CHECK: %[[F128_DEC:.*]] = cir.fsub %[[F128_LOAD]], %[[F128_ONE]]
+// CIR: cir.func{{.*}} @_Z12f128UPostDecg({{.*}}) -> (!cir.f128{{.*}})
+// CIR: %[[F128_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f128>
+// CIR: %[[F128_LOAD:.*]] = cir.load{{.*}} %[[F128_F]]
+// CIR: %[[F128_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.f128
+// CIR: %[[F128_DEC:.*]] = cir.fadd %[[F128_LOAD]], %[[F128_NEGONE]]
// LLVM: define{{.*}} fp128 @_Z12f128UPostDecg({{.*}})
// LLVM: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
-// LLVM: %[[F128_DEC:.*]] = fsub fp128 %[[F128_LOAD]], 1.000000e+00
+// LLVM: %[[F128_DEC:.*]] = fadd fp128 %[[F128_LOAD]], -1.000000e+00
// OGCG: define{{.*}} fp128 @_Z12f128UPostDecg({{.*}})
// OGCG: %[[F128_LOAD:.*]] = load fp128, ptr %{{.*}}, align 16
@@ -744,10 +764,10 @@ _Float16 Float16UPlus(_Float16 f) {
return +f;
}
-// CHECK: cir.func{{.*}} @_Z12Float16UPlusDF16_({{.*}}) -> (!cir.f16{{.*}})
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[F:.*]]
-// CHECK: %[[PROMOTED:.*]] = cir.cast floating %[[INPUT]] : !cir.f16 -> !cir.float
-// CHECK: %[[UNPROMOTED:.*]] = cir.cast floating %[[PROMOTED]] : !cir.float -> !cir.f16
+// CIR: cir.func{{.*}} @_Z12Float16UPlusDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[F:.*]]
+// CIR: %[[PROMOTED:.*]] = cir.cast floating %[[INPUT]] : !cir.f16 -> !cir.float
+// CIR: %[[UNPROMOTED:.*]] = cir.cast floating %[[PROMOTED]] : !cir.float -> !cir.f16
// LLVM: define{{.*}} half @_Z12Float16UPlusDF16_({{.*}})
// LLVM: %[[F_LOAD:.*]] = load half, ptr %{{.*}}, align 2
@@ -763,11 +783,11 @@ _Float16 Float16UMinus(_Float16 f) {
return -f;
}
-// CHECK: cir.func{{.*}} @_Z13Float16UMinusDF16_({{.*}}) -> (!cir.f16{{.*}})
-// CHECK: %[[INPUT:.*]] = cir.load{{.*}} %[[F:.*]]
-// CHECK: %[[PROMOTED:.*]] = cir.cast floating %[[INPUT]] : !cir.f16 -> !cir.float
-// CHECK: %[[RESULT:.*]] = cir.fneg %[[PROMOTED]]
-// CHECK: %[[UNPROMOTED:.*]] = cir.cast floating %[[RESULT]] : !cir.float -> !cir.f16
+// CIR: cir.func{{.*}} @_Z13Float16UMinusDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CIR: %[[INPUT:.*]] = cir.load{{.*}} %[[F:.*]]
+// CIR: %[[PROMOTED:.*]] = cir.cast floating %[[INPUT]] : !cir.f16 -> !cir.float
+// CIR: %[[RESULT:.*]] = cir.fneg %[[PROMOTED]]
+// CIR: %[[UNPROMOTED:.*]] = cir.cast floating %[[RESULT]] : !cir.float -> !cir.f16
// LLVM: define{{.*}} half @_Z13Float16UMinusDF16_({{.*}})
// LLVM: %[[F_LOAD:.*]] = load half, ptr %{{.*}}, align 2
@@ -785,11 +805,11 @@ _Float16 Float16UPreInc(_Float16 f) {
return ++f;
}
-// CHECK: cir.func{{.*}} @_Z14Float16UPreIncDF16_({{.*}}) -> (!cir.f16{{.*}})
-// CHECK: %[[PREINC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
-// CHECK: %[[PREINC_INPUT:.*]] = cir.load{{.*}} %[[PREINC_F]]
-// CHECK: %[[PREINC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
-// CHECK: %[[PREINC_RESULT:.*]] = cir.fadd %[[PREINC_INPUT]], %[[PREINC_ONE]] : !cir.f16
+// CIR: cir.func{{.*}} @_Z14Float16UPreIncDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CIR: %[[PREINC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
+// CIR: %[[PREINC_INPUT:.*]] = cir.load{{.*}} %[[PREINC_F]]
+// CIR: %[[PREINC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
+// CIR: %[[PREINC_RESULT:.*]] = cir.fadd %[[PREINC_INPUT]], %[[PREINC_ONE]] : !cir.f16
// LLVM: define{{.*}} half @_Z14Float16UPreIncDF16_({{.*}})
// LLVM: %[[PREINC_F_ADDR:.*]] = alloca half, align 2
@@ -805,16 +825,16 @@ _Float16 Float16UPreDec(_Float16 f) {
return --f;
}
-// CHECK: cir.func{{.*}} @_Z14Float16UPreDecDF16_({{.*}}) -> (!cir.f16{{.*}})
-// CHECK: %[[PREDEC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
-// CHECK: %[[PREDEC_INPUT:.*]] = cir.load{{.*}} %[[PREDEC_F]]
-// CHECK: %[[PREDEC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
-// CHECK: %[[PREDEC_RESULT:.*]] = cir.fsub %[[PREDEC_INPUT]], %[[PREDEC_ONE]] : !cir.f16
+// CIR: cir.func{{.*}} @_Z14Float16UPreDecDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CIR: %[[PREDEC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
+// CIR: %[[PREDEC_INPUT:.*]] = cir.load{{.*}} %[[PREDEC_F]]
+// CIR: %[[PREDEC_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.f16
+// CIR: %[[PREDEC_RESULT:.*]] = cir.fadd %[[PREDEC_INPUT]], %[[PREDEC_NEGONE]] : !cir.f16
// LLVM: define{{.*}} half @_Z14Float16UPreDecDF16_({{.*}})
// LLVM: %[[PREDEC_F_ADDR:.*]] = alloca half, align 2
// LLVM: %[[PREDEC_INPUT:.*]] = load half, ptr %[[PREDEC_F_ADDR]], align 2
-// LLVM: %[[PREDEC_RESULT:.*]] = fsub half %[[PREDEC_INPUT]], 1.000000e+00
+// LLVM: %[[PREDEC_RESULT:.*]] = fadd half %[[PREDEC_INPUT]], -1.000000e+00
// OGCG: define{{.*}} half @_Z14Float16UPreDecDF16_({{.*}})
// OGCG: %[[PREDEC_F_ADDR:.*]] = alloca half, align 2
@@ -825,11 +845,11 @@ _Float16 Float16UPostInc(_Float16 f) {
return f++;
}
-// CHECK: cir.func{{.*}} @_Z15Float16UPostIncDF16_({{.*}}) -> (!cir.f16{{.*}})
-// CHECK: %[[POSTINC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
-// CHECK: %[[POSTINC_INPUT:.*]] = cir.load{{.*}} %[[POSTINC_F]]
-// CHECK: %[[POSTINC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
-// CHECK: %[[POSTINC_RESULT:.*]] = cir.fadd %[[POSTINC_INPUT]], %[[POSTINC_ONE]] : !cir.f16
+// CIR: cir.func{{.*}} @_Z15Float16UPostIncDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CIR: %[[POSTINC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
+// CIR: %[[POSTINC_INPUT:.*]] = cir.load{{.*}} %[[POSTINC_F]]
+// CIR: %[[POSTINC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
+// CIR: %[[POSTINC_RESULT:.*]] = cir.fadd %[[POSTINC_INPUT]], %[[POSTINC_ONE]] : !cir.f16
// LLVM: define{{.*}} half @_Z15Float16UPostIncDF16_({{.*}})
// LLVM: %[[POSTINC_F_ADDR:.*]] = alloca half, align 2
@@ -845,16 +865,16 @@ _Float16 Float16UPostDec(_Float16 f) {
return f--;
}
-// CHECK: cir.func{{.*}} @_Z15Float16UPostDecDF16_({{.*}}) -> (!cir.f16{{.*}})
-// CHECK: %[[POSTDEC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
-// CHECK: %[[POSTDEC_INPUT:.*]] = cir.load{{.*}} %[[POSTDEC_F]]
-// CHECK: %[[POSTDEC_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.f16
-// CHECK: %[[POSTDEC_RESULT:.*]] = cir.fsub %[[POSTDEC_INPUT]], %[[POSTDEC_ONE]] : !cir.f16
+// CIR: cir.func{{.*}} @_Z15Float16UPostDecDF16_({{.*}}) -> (!cir.f16{{.*}})
+// CIR: %[[POSTDEC_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.f16>
+// CIR: %[[POSTDEC_INPUT:.*]] = cir.load{{.*}} %[[POSTDEC_F]]
+// CIR: %[[POSTDEC_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.f16
+// CIR: %[[POSTDEC_RESULT:.*]] = cir.fadd %[[POSTDEC_INPUT]], %[[POSTDEC_NEGONE]] : !cir.f16
// LLVM: define{{.*}} half @_Z15Float16UPostDecDF16_({{.*}})
// LLVM: %[[POSTDEC_F_ADDR:.*]] = alloca half, align 2
// LLVM: %[[POSTDEC_INPUT:.*]] = load half, ptr %[[POSTDEC_F_ADDR]], align 2
-// LLVM: %[[POSTDEC_RESULT:.*]] = fsub half %[[POSTDEC_INPUT]], 1.000000e+00
+// LLVM: %[[POSTDEC_RESULT:.*]] = fadd half %[[POSTDEC_INPUT]], -1.000000e+00
// OGCG: define{{.*}} half @_Z15Float16UPostDecDF16_({{.*}})
// OGCG: %[[POSTDEC_F_ADDR:.*]] = alloca half, align 2
@@ -866,12 +886,12 @@ void fp16PtrUPlus(__fp16 *f) {
*f = +(*f);
}
-// CHECK: cir.func{{.*}} @_Z12fp16PtrUPlusPDh({{.*}})
-// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
-// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
-// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
-// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
-// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_PROMOTED]] : !cir.float -> !cir.f16
+// CIR: cir.func{{.*}} @_Z12fp16PtrUPlusPDh({{.*}})
+// CIR: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CIR: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CIR: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CIR: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CIR: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_PROMOTED]] : !cir.float -> !cir.f16
// LLVM: define{{.*}} void @_Z12fp16PtrUPlusPDh({{.*}})
// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
@@ -887,13 +907,13 @@ void fp16PtrUMinus(__fp16 *f) {
*f = -(*f);
}
-// CHECK: cir.func{{.*}} @_Z13fp16PtrUMinusPDh({{.*}})
-// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
-// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
-// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
-// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
-// CHECK: %[[FPTR_NEGATED:.*]] = cir.fneg %[[FPTR_PROMOTED]]
-// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_NEGATED]] : !cir.float -> !cir.f16
+// CIR: cir.func{{.*}} @_Z13fp16PtrUMinusPDh({{.*}})
+// CIR: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CIR: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CIR: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CIR: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CIR: %[[FPTR_NEGATED:.*]] = cir.fneg %[[FPTR_PROMOTED]]
+// CIR: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_NEGATED]] : !cir.float -> !cir.f16
// LLVM: define{{.*}} void @_Z13fp16PtrUMinusPDh({{.*}})
// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
@@ -911,14 +931,14 @@ void fp16PtrUPreInc(__fp16 *f) {
++(*f);
}
-// CHECK: cir.func{{.*}} @_Z14fp16PtrUPreIncPDh({{.*}})
-// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
-// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
-// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
-// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
-// CHECK: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: %[[FPTR_INC:.*]] = cir.fadd %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
-// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_INC]] : !cir.float -> !cir.f16
+// CIR: cir.func{{.*}} @_Z14fp16PtrUPreIncPDh({{.*}})
+// CIR: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CIR: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CIR: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CIR: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CIR: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[FPTR_INC:.*]] = cir.fadd %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
+// CIR: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_INC]] : !cir.float -> !cir.f16
// LLVM: define{{.*}} void @_Z14fp16PtrUPreIncPDh({{.*}})
// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
@@ -936,19 +956,19 @@ void fp16PtrUPreDec(__fp16 *f) {
--(*f);
}
-// CHECK: cir.func{{.*}} @_Z14fp16PtrUPreDecPDh({{.*}})
-// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
-// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
-// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
-// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
-// CHECK: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: %[[FPTR_DEC:.*]] = cir.fsub %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
-// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_DEC]] : !cir.float -> !cir.f16
+// CIR: cir.func{{.*}} @_Z14fp16PtrUPreDecPDh({{.*}})
+// CIR: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CIR: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CIR: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CIR: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CIR: %[[FPTR_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.float
+// CIR: %[[FPTR_DEC:.*]] = cir.fadd %[[FPTR_PROMOTED]], %[[FPTR_NEGONE]] : !cir.float
+// CIR: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_DEC]] : !cir.float -> !cir.f16
// LLVM: define{{.*}} void @_Z14fp16PtrUPreDecPDh({{.*}})
// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
// LLVM: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
-// LLVM: %[[FPTR_DEC:.*]] = fsub float %[[FPTR_PROMOTED]], 1.000000e+00
+// LLVM: %[[FPTR_DEC:.*]] = fadd float %[[FPTR_PROMOTED]], -1.000000e+00
// LLVM: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_DEC]] to half
// OGCG: define{{.*}} void @_Z14fp16PtrUPreDecPDh({{.*}})
@@ -961,14 +981,14 @@ void fp16PtrUPostInc(__fp16 *f) {
(*f)++;
}
-// CHECK: cir.func{{.*}} @_Z15fp16PtrUPostIncPDh({{.*}})
-// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
-// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
-// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
-// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
-// CHECK: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: %[[FPTR_INC:.*]] = cir.fadd %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
-// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_DEC]] : !cir.float -> !cir.f16
+// CIR: cir.func{{.*}} @_Z15fp16PtrUPostIncPDh({{.*}})
+// CIR: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CIR: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CIR: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CIR: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CIR: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[FPTR_INC:.*]] = cir.fadd %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
+// CIR: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_DEC]] : !cir.float -> !cir.f16
// LLVM: define{{.*}} void @_Z15fp16PtrUPostIncPDh({{.*}})
// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
@@ -986,19 +1006,19 @@ void fp16PtrUPostDec(__fp16 *f) {
(*f)--;
}
-// CHECK: cir.func{{.*}} @_Z15fp16PtrUPostDecPDh({{.*}})
-// CHECK: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
-// CHECK: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
-// CHECK: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
-// CHECK: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
-// CHECK: %[[FPTR_ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
-// CHECK: %[[FPTR_DEC:.*]] = cir.fsub %[[FPTR_PROMOTED]], %[[FPTR_ONE]] : !cir.float
-// CHECK: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_DEC]] : !cir.float -> !cir.f16
+// CIR: cir.func{{.*}} @_Z15fp16PtrUPostDecPDh({{.*}})
+// CIR: %[[FPTR_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.ptr<!cir.f16>>
+// CIR: %[[FPTR_DEREF:.*]] = cir.load deref{{.*}} %[[FPTR_F]]
+// CIR: %[[FPTR_LOAD:.*]] = cir.load{{.*}} %[[FPTR_DEREF]]
+// CIR: %[[FPTR_PROMOTED:.*]] = cir.cast floating %[[FPTR_LOAD]] : !cir.f16 -> !cir.float
+// CIR: %[[FPTR_NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.float
+// CIR: %[[FPTR_DEC:.*]] = cir.fadd %[[FPTR_PROMOTED]], %[[FPTR_NEGONE]] : !cir.float
+// CIR: %[[FPTR_UNPROMOTED:.*]] = cir.cast floating %[[FPTR_DEC]] : !cir.float -> !cir.f16
// LLVM: define{{.*}} void @_Z15fp16PtrUPostDecPDh({{.*}})
// LLVM: %[[FPTR_LOAD:.*]] = load half, ptr %{{.*}}, align 2
// LLVM: %[[FPTR_PROMOTED:.*]] = fpext half %[[FPTR_LOAD]] to float
-// LLVM: %[[FPTR_DEC:.*]] = fsub float %[[FPTR_PROMOTED]], 1.000000e+00
+// LLVM: %[[FPTR_DEC:.*]] = fadd float %[[FPTR_PROMOTED]], -1.000000e+00
// LLVM: %[[FPTR_UNPROMOTED:.*]] = fptrunc float %[[FPTR_DEC]] to half
// OGCG: define{{.*}} void @_Z15fp16PtrUPostDecPDh({{.*}})
@@ -1012,11 +1032,11 @@ __bf16 bf16UPlus(__bf16 f) {
return +f;
}
-// CHECK: cir.func{{.*}} @_Z9bf16UPlusDF16b({{.*}}) -> (!cir.bf16{{.*}})
-// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
-// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
-// CHECK: %[[BF16_PROMOTED:.*]] = cir.cast floating %[[BF16_LOAD]] : !cir.bf16 -> !cir.float
-// CHECK: %[[BF16_UNPROMOTED:.*]] = cir.cast floating %[[BF16_PROMOTED]] : !cir.float -> !cir.bf16
+// CIR: cir.func{{.*}} @_Z9bf16UPlusDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CIR: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CIR: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CIR: %[[BF16_PROMOTED:.*]] = cir.cast floating %[[BF16_LOAD]] : !cir.bf16 -> !cir.float
+// CIR: %[[BF16_UNPROMOTED:.*]] = cir.cast floating %[[BF16_PROMOTED]] : !cir.float -> !cir.bf16
// LLVM: define{{.*}} bfloat @_Z9bf16UPlusDF16b({{.*}})
// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
@@ -1032,12 +1052,12 @@ __bf16 bf16UMinus(__bf16 f) {
return -f;
}
-// CHECK: cir.func{{.*}} @_Z10bf16UMinusDF16b({{.*}}) -> (!cir.bf16{{.*}})
-// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
-// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
-// CHECK: %[[BF16_PROMOTED:.*]] = cir.cast floating %[[BF16_LOAD]] : !cir.bf16 -> !cir.float
-// CHECK: %[[BF16_NEGATED:.*]] = cir.fneg %[[BF16_PROMOTED]]
-// CHECK: %[[BF16_UNPROMOTED:.*]] = cir.cast floating %[[BF16_NEGATED]] : !cir.float -> !cir.bf16
+// CIR: cir.func{{.*}} @_Z10bf16UMinusDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CIR: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CIR: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CIR: %[[BF16_PROMOTED:.*]] = cir.cast floating %[[BF16_LOAD]] : !cir.bf16 -> !cir.float
+// CIR: %[[BF16_NEGATED:.*]] = cir.fneg %[[BF16_PROMOTED]]
+// CIR: %[[BF16_UNPROMOTED:.*]] = cir.cast floating %[[BF16_NEGATED]] : !cir.float -> !cir.bf16
// LLVM: define{{.*}} bfloat @_Z10bf16UMinusDF16b({{.*}})
// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
@@ -1055,10 +1075,10 @@ __bf16 bf16UPreInc(__bf16 f) {
return ++f;
}
-// CHECK: cir.func{{.*}} @_Z11bf16UPreIncDF16b({{.*}}) -> (!cir.bf16{{.*}})
-// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
-// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
-// CHECK: %[[BF16_INC:.*]] = cir.fadd %[[BF16_LOAD]], %{{.*}} : !cir.bf16
+// CIR: cir.func{{.*}} @_Z11bf16UPreIncDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CIR: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CIR: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CIR: %[[BF16_INC:.*]] = cir.fadd %[[BF16_LOAD]], %{{.*}} : !cir.bf16
// LLVM: define{{.*}} bfloat @_Z11bf16UPreIncDF16b({{.*}})
// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
@@ -1072,14 +1092,14 @@ __bf16 bf16UPreDec(__bf16 f) {
return --f;
}
-// CHECK: cir.func{{.*}} @_Z11bf16UPreDecDF16b({{.*}}) -> (!cir.bf16{{.*}})
-// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
-// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
-// CHECK: %[[BF16_DEC:.*]] = cir.fsub %[[BF16_LOAD]], %{{.*}} : !cir.bf16
+// CIR: cir.func{{.*}} @_Z11bf16UPreDecDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CIR: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CIR: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CIR: %[[BF16_DEC:.*]] = cir.fadd %[[BF16_LOAD]], %{{.*}} : !cir.bf16
// LLVM: define{{.*}} bfloat @_Z11bf16UPreDecDF16b({{.*}})
// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
-// LLVM: %[[BF16_DEC:.*]] = fsub bfloat %[[BF16_LOAD]], 1.000000e+00
+// LLVM: %[[BF16_DEC:.*]] = fadd bfloat %[[BF16_LOAD]], -1.000000e+00
// OGCG: define{{.*}} bfloat @_Z11bf16UPreDecDF16b({{.*}})
// OGCG: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
@@ -1089,10 +1109,10 @@ __bf16 bf16UPostInc(__bf16 f) {
return f++;
}
-// CHECK: cir.func{{.*}} @_Z12bf16UPostIncDF16b({{.*}}) -> (!cir.bf16{{.*}})
-// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
-// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
-// CHECK: %[[BF16_INC:.*]] = cir.fadd %[[BF16_LOAD]], %{{.*}} : !cir.bf16
+// CIR: cir.func{{.*}} @_Z12bf16UPostIncDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CIR: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CIR: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CIR: %[[BF16_INC:.*]] = cir.fadd %[[BF16_LOAD]], %{{.*}} : !cir.bf16
// LLVM: define{{.*}} bfloat @_Z12bf16UPostIncDF16b({{.*}})
// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
@@ -1106,14 +1126,14 @@ __bf16 bf16UPostDec(__bf16 f) {
return f--;
}
-// CHECK: cir.func{{.*}} @_Z12bf16UPostDecDF16b({{.*}}) -> (!cir.bf16{{.*}})
-// CHECK: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
-// CHECK: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
-// CHECK: %[[BF16_DEC:.*]] = cir.fsub %[[BF16_LOAD]], %{{.*}} : !cir.bf16
+// CIR: cir.func{{.*}} @_Z12bf16UPostDecDF16b({{.*}}) -> (!cir.bf16{{.*}})
+// CIR: %[[BF16_F:.*]] = cir.alloca "f" {{.*}} init : !cir.ptr<!cir.bf16>
+// CIR: %[[BF16_LOAD:.*]] = cir.load{{.*}} %[[BF16_F]]
+// CIR: %[[BF16_DEC:.*]] = cir.fadd %[[BF16_LOAD]], %{{.*}} : !cir.bf16
// LLVM: define{{.*}} bfloat @_Z12bf16UPostDecDF16b({{.*}})
// LLVM: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
-// LLVM: %[[BF16_DEC:.*]] = fsub bfloat %[[BF16_LOAD]], 1.000000e+00
+// LLVM: %[[BF16_DEC:.*]] = fadd bfloat %[[BF16_LOAD]], -1.000000e+00
// OGCG: define{{.*}} bfloat @_Z12bf16UPostDecDF16b({{.*}})
// OGCG: %[[BF16_LOAD:.*]] = load bfloat, ptr %{{.*}}, align 2
@@ -1132,28 +1152,28 @@ void test_logical_not() {
b = !d;
}
-// CHECK: cir.func{{.*}} @_Z16test_logical_notv()
-// CHECK: %[[A:.*]] = cir.load{{.*}} %[[A_ADDR:.*]] : !cir.ptr<!s32i>, !s32i
-// CHECK: %[[A_BOOL:.*]] = cir.cast int_to_bool %[[A]] : !s32i -> !cir.bool
-// CHECK: %[[A_NOT:.*]] = cir.not %[[A_BOOL]] : !cir.bool
-// CHECK: %[[A_CAST:.*]] = cir.cast bool_to_int %[[A_NOT]] : !cir.bool -> !s32i
-// CHECK: cir.store{{.*}} %[[A_CAST]], %[[A_ADDR]] : !s32i, !cir.ptr<!s32i>
-// CHECK: %[[B:.*]] = cir.load{{.*}} %[[B_ADDR:.*]] : !cir.ptr<!cir.bool>, !cir.bool
-// CHECK: %[[B_NOT:.*]] = cir.not %[[B]] : !cir.bool
-// CHECK: cir.store{{.*}} %[[B_NOT]], %[[B_ADDR]] : !cir.bool, !cir.ptr<!cir.bool>
-// CHECK: %[[C:.*]] = cir.load{{.*}} %[[C_ADDR:.*]] : !cir.ptr<!cir.float>, !cir.float
-// CHECK: %[[C_BOOL:.*]] = cir.cast float_to_bool %[[C]] : !cir.float -> !cir.bool
-// CHECK: %[[C_NOT:.*]] = cir.not %[[C_BOOL]] : !cir.bool
-// CHECK: %[[C_CAST:.*]] = cir.cast bool_to_float %[[C_NOT]] : !cir.bool -> !cir.float
-// CHECK: cir.store{{.*}} %[[C_CAST]], %[[C_ADDR]] : !cir.float, !cir.ptr<!cir.float>
-// CHECK: %[[P:.*]] = cir.load{{.*}} %[[P_ADDR:.*]] : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
-// CHECK: %[[P_BOOL:.*]] = cir.cast ptr_to_bool %[[P]] : !cir.ptr<!s32i> -> !cir.bool
-// CHECK: %[[P_NOT:.*]] = cir.not %[[P_BOOL]] : !cir.bool
-// CHECK: cir.store{{.*}} %[[P_NOT]], %[[B_ADDR]] : !cir.bool, !cir.ptr<!cir.bool>
-// CHECK: %[[D:.*]] = cir.load{{.*}} %[[D_ADDR:.*]] : !cir.ptr<!cir.double>, !cir.double
-// CHECK: %[[D_BOOL:.*]] = cir.cast float_to_bool %[[D]] : !cir.double -> !cir.bool
-// CHECK: %[[D_NOT:.*]] = cir.not %[[D_BOOL]] : !cir.bool
-// CHECK: cir.store{{.*}} %[[D_NOT]], %[[B_ADDR]] : !cir.bool, !cir.ptr<!cir.bool>
+// CIR: cir.func{{.*}} @_Z16test_logical_notv()
+// CIR: %[[A:.*]] = cir.load{{.*}} %[[A_ADDR:.*]] : !cir.ptr<!s32i>, !s32i
+// CIR: %[[A_BOOL:.*]] = cir.cast int_to_bool %[[A]] : !s32i -> !cir.bool
+// CIR: %[[A_NOT:.*]] = cir.not %[[A_BOOL]] : !cir.bool
+// CIR: %[[A_CAST:.*]] = cir.cast bool_to_int %[[A_NOT]] : !cir.bool -> !s32i
+// CIR: cir.store{{.*}} %[[A_CAST]], %[[A_ADDR]] : !s32i, !cir.ptr<!s32i>
+// CIR: %[[B:.*]] = cir.load{{.*}} %[[B_ADDR:.*]] : !cir.ptr<!cir.bool>, !cir.bool
+// CIR: %[[B_NOT:.*]] = cir.not %[[B]] : !cir.bool
+// CIR: cir.store{{.*}} %[[B_NOT]], %[[B_ADDR]] : !cir.bool, !cir.ptr<!cir.bool>
+// CIR: %[[C:.*]] = cir.load{{.*}} %[[C_ADDR:.*]] : !cir.ptr<!cir.float>, !cir.float
+// CIR: %[[C_BOOL:.*]] = cir.cast float_to_bool %[[C]] : !cir.float -> !cir.bool
+// CIR: %[[C_NOT:.*]] = cir.not %[[C_BOOL]] : !cir.bool
+// CIR: %[[C_CAST:.*]] = cir.cast bool_to_float %[[C_NOT]] : !cir.bool -> !cir.float
+// CIR: cir.store{{.*}} %[[C_CAST]], %[[C_ADDR]] : !cir.float, !cir.ptr<!cir.float>
+// CIR: %[[P:.*]] = cir.load{{.*}} %[[P_ADDR:.*]] : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
+// CIR: %[[P_BOOL:.*]] = cir.cast ptr_to_bool %[[P]] : !cir.ptr<!s32i> -> !cir.bool
+// CIR: %[[P_NOT:.*]] = cir.not %[[P_BOOL]] : !cir.bool
+// CIR: cir.store{{.*}} %[[P_NOT]], %[[B_ADDR]] : !cir.bool, !cir.ptr<!cir.bool>
+// CIR: %[[D:.*]] = cir.load{{.*}} %[[D_ADDR:.*]] : !cir.ptr<!cir.double>, !cir.double
+// CIR: %[[D_BOOL:.*]] = cir.cast float_to_bool %[[D]] : !cir.double -> !cir.bool
+// CIR: %[[D_NOT:.*]] = cir.not %[[D_BOOL]] : !cir.bool
+// CIR: cir.store{{.*}} %[[D_NOT]], %[[B_ADDR]] : !cir.bool, !cir.ptr<!cir.bool>
// LLVM: define{{.*}} void @_Z16test_logical_notv()
// LLVM: %[[A:.*]] = load i32, ptr %[[A_ADDR:.*]], align 4
@@ -1214,13 +1234,13 @@ void f16NestedUPlus() {
_Float16 b = +(+a);
}
-// CHECK: cir.func{{.*}} @_Z14f16NestedUPlusv()
-// CHECK: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} : !cir.ptr<!cir.f16>
-// CHECK: %[[B_ADDR:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!cir.f16>
-// CHECK: %[[TMP_A:.*]] = cir.load{{.*}} %[[A_ADDR]] : !cir.ptr<!cir.f16>, !cir.f16
-// CHECK: %[[A_F32:.*]] = cir.cast floating %[[TMP_A]] : !cir.f16 -> !cir.float
-// CHECK: %[[RESULT:.*]] = cir.cast floating %[[A_F32]] : !cir.float -> !cir.f16
-// CHECK: cir.store{{.*}} %[[RESULT]], %[[B_ADDR]] : !cir.f16, !cir.ptr<!cir.f16>
+// CIR: cir.func{{.*}} @_Z14f16NestedUPlusv()
+// CIR: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} : !cir.ptr<!cir.f16>
+// CIR: %[[B_ADDR:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!cir.f16>
+// CIR: %[[TMP_A:.*]] = cir.load{{.*}} %[[A_ADDR]] : !cir.ptr<!cir.f16>, !cir.f16
+// CIR: %[[A_F32:.*]] = cir.cast floating %[[TMP_A]] : !cir.f16 -> !cir.float
+// CIR: %[[RESULT:.*]] = cir.cast floating %[[A_F32]] : !cir.float -> !cir.f16
+// CIR: cir.store{{.*}} %[[RESULT]], %[[B_ADDR]] : !cir.f16, !cir.ptr<!cir.f16>
// LLVM: define{{.*}} void @_Z14f16NestedUPlusv()
// LLVM: %[[A_ADDR:.*]] = alloca half, align 2
@@ -1243,15 +1263,15 @@ void f16NestedUMinus() {
_Float16 b = -(-a);
}
-// CHECK: cir.func{{.*}} @_Z15f16NestedUMinusv()
-// CHECK: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} : !cir.ptr<!cir.f16>
-// CHECK: %[[B_ADDR:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!cir.f16>
-// CHECK: %[[TMP_A:.*]] = cir.load{{.*}} %[[A_ADDR]] : !cir.ptr<!cir.f16>, !cir.f16
-// CHECK: %[[A_F32:.*]] = cir.cast floating %[[TMP_A]] : !cir.f16 -> !cir.float
-// CHECK: %[[A_MINUS:.*]] = cir.fneg %[[A_F32]] : !cir.float
-// CHECK: %[[RESULT_F32:.*]] = cir.fneg %[[A_MINUS]] : !cir.float
-// CHECK: %[[RESULT:.*]] = cir.cast floating %[[RESULT_F32]] : !cir.float -> !cir.f16
-// CHECK: cir.store{{.*}} %[[RESULT]], %[[B_ADDR]] : !cir.f16, !cir.ptr<!cir.f16>
+// CIR: cir.func{{.*}} @_Z15f16NestedUMinusv()
+// CIR: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} : !cir.ptr<!cir.f16>
+// CIR: %[[B_ADDR:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!cir.f16>
+// CIR: %[[TMP_A:.*]] = cir.load{{.*}} %[[A_ADDR]] : !cir.ptr<!cir.f16>, !cir.f16
+// CIR: %[[A_F32:.*]] = cir.cast floating %[[TMP_A]] : !cir.f16 -> !cir.float
+// CIR: %[[A_MINUS:.*]] = cir.fneg %[[A_F32]] : !cir.float
+// CIR: %[[RESULT_F32:.*]] = cir.fneg %[[A_MINUS]] : !cir.float
+// CIR: %[[RESULT:.*]] = cir.cast floating %[[RESULT_F32]] : !cir.float -> !cir.f16
+// CIR: cir.store{{.*}} %[[RESULT]], %[[B_ADDR]] : !cir.f16, !cir.ptr<!cir.f16>
// LLVM: define{{.*}} void @_Z15f16NestedUMinusv()
// LLVM: %[[A_ADDR:.*]] = alloca half, align 2
@@ -1272,3 +1292,150 @@ void f16NestedUMinus() {
// OGCG: %[[RESULT_F32:.*]] = fneg float %[[A_MINUS]]
// OGCG: %[[RESULT:.*]] = fptrunc float %[[RESULT_F32]] to half
// OGCG: store half %[[RESULT]], ptr %[[B_ADDR]], align 2
+
+// Unary inc/dec on vector types, covering the CIRGenExprScalar.cpp vector
+// branch:
+// * integer vectors go through emitIntIncOrDec -> cir.inc/cir.dec
+// * float vectors go through emitFloatIncOrDec -> cir.fadd
+
+typedef int vi4 __attribute__((vector_size(16)));
+typedef unsigned uvi4 __attribute__((vector_size(16)));
+typedef short vsh8 __attribute__((vector_size(16)));
+typedef float vf4 __attribute__((vector_size(16)));
+typedef double vd2 __attribute__((vector_size(16)));
+
+void vecIntIncDec(vi4 a) {
+ ++a;
+ --a;
+ a++;
+ a--;
+}
+// CIR-LABEL: @_Z12vecIntIncDecDv4_i
+// CIR: cir.inc %{{.+}} : !cir.vector<4 x !s32i>
+// CIR: cir.dec %{{.+}} : !cir.vector<4 x !s32i>
+// CIR: cir.inc %{{.+}} : !cir.vector<4 x !s32i>
+// CIR: cir.dec %{{.+}} : !cir.vector<4 x !s32i>
+
+// LLVM-LABEL: @_Z12vecIntIncDecDv4_i
+// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
+
+// OGCG-LABEL: @_Z12vecIntIncDecDv4_i
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
+
+void vecUIntIncDec(uvi4 b) {
+ ++b;
+ --b;
+ b++;
+ b--;
+}
+// CIR-LABEL: @_Z13vecUIntIncDecDv4_j
+// CIR: cir.inc %{{.+}} : !cir.vector<4 x !u32i>
+// CIR: cir.dec %{{.+}} : !cir.vector<4 x !u32i>
+// CIR: cir.inc %{{.+}} : !cir.vector<4 x !u32i>
+// CIR: cir.dec %{{.+}} : !cir.vector<4 x !u32i>
+
+// LLVM-LABEL: @_Z13vecUIntIncDecDv4_j
+// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: add <4 x i32> %{{.+}}, splat (i32 1)
+// LLVM: sub <4 x i32> %{{.+}}, splat (i32 1)
+
+// OGCG-LABEL: @_Z13vecUIntIncDecDv4_j
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 1)
+// OGCG: add <4 x i32> %{{.+}}, splat (i32 -1)
+
+void vecShortIncDec(vsh8 c) {
+ ++c;
+ --c;
+ c++;
+ c--;
+}
+// CIR-LABEL: @_Z14vecShortIncDecDv8_s
+// CIR: cir.inc %{{.+}} : !cir.vector<8 x !s16i>
+// CIR: cir.dec %{{.+}} : !cir.vector<8 x !s16i>
+// CIR: cir.inc %{{.+}} : !cir.vector<8 x !s16i>
+// CIR: cir.dec %{{.+}} : !cir.vector<8 x !s16i>
+
+// LLVM-LABEL: @_Z14vecShortIncDecDv8_s
+// LLVM: add <8 x i16> %{{.+}}, splat (i16 1)
+// LLVM: sub <8 x i16> %{{.+}}, splat (i16 1)
+// LLVM: add <8 x i16> %{{.+}}, splat (i16 1)
+// LLVM: sub <8 x i16> %{{.+}}, splat (i16 1)
+
+// OGCG-LABEL: @_Z14vecShortIncDecDv8_s
+// OGCG: add <8 x i16> %{{.+}}, splat (i16 1)
+// OGCG: add <8 x i16> %{{.+}}, splat (i16 -1)
+// OGCG: add <8 x i16> %{{.+}}, splat (i16 1)
+// OGCG: add <8 x i16> %{{.+}}, splat (i16 -1)
+
+void vecFloatIncDec(vf4 a) {
+ ++a;
+ --a;
+ a++;
+ a--;
+}
+// CIR-LABEL: @_Z14vecFloatIncDecDv4_f
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
+// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
+// CIR: %[[NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.float
+// CIR: %[[NEGONEVEC:.*]] = cir.vec.splat %[[NEGONE]] : !cir.float, !cir.vector<4 x !cir.float>
+// CIR: cir.fadd %{{.+}}, %[[NEGONEVEC]] : !cir.vector<4 x !cir.float>
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.float, !cir.vector<4 x !cir.float>
+// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<4 x !cir.float>
+// CIR: %[[NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.float
+// CIR: %[[NEGONEVEC:.*]] = cir.vec.splat %[[NEGONE]] : !cir.float, !cir.vector<4 x !cir.float>
+// CIR: cir.fadd %{{.+}}, %[[NEGONEVEC]] : !cir.vector<4 x !cir.float>
+
+// LLVM-LABEL: @_Z14vecFloatIncDecDv4_f
+// LLVM: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
+// LLVM: fadd <4 x float> %{{.+}}, splat (float -1.000000e+00)
+// LLVM: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
+// LLVM: fadd <4 x float> %{{.+}}, splat (float -1.000000e+00)
+
+// OGCG-LABEL: @_Z14vecFloatIncDecDv4_f
+// OGCG: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
+// OGCG: fadd <4 x float> %{{.+}}, splat (float -1.000000e+00)
+// OGCG: fadd <4 x float> %{{.+}}, splat (float 1.000000e+00)
+// OGCG: fadd <4 x float> %{{.+}}, splat (float -1.000000e+00)
+
+void vecDoubleIncDec(vd2 b) {
+ ++b;
+ --b;
+ b++;
+ b--;
+}
+// CIR-LABEL: @_Z15vecDoubleIncDecDv2_d
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
+// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
+// CIR: %[[NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.double
+// CIR: %[[NEGONEVEC:.*]] = cir.vec.splat %[[NEGONE]] : !cir.double, !cir.vector<2 x !cir.double>
+// CIR: cir.fadd %{{.+}}, %[[NEGONEVEC]] : !cir.vector<2 x !cir.double>
+// CIR: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.double
+// CIR: %[[ONEVEC:.*]] = cir.vec.splat %[[ONE]] : !cir.double, !cir.vector<2 x !cir.double>
+// CIR: cir.fadd %{{.+}}, %[[ONEVEC]] : !cir.vector<2 x !cir.double>
+// CIR: %[[NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.double
+// CIR: %[[NEGONEVEC:.*]] = cir.vec.splat %[[NEGONE]] : !cir.double, !cir.vector<2 x !cir.double>
+// CIR: cir.fadd %{{.+}}, %[[NEGONEVEC]] : !cir.vector<2 x !cir.double>
+
+// LLVM-LABEL: @_Z15vecDoubleIncDecDv2_d
+// LLVM: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
+// LLVM: fadd <2 x double> %{{.+}}, splat (double -1.000000e+00)
+// LLVM: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
+// LLVM: fadd <2 x double> %{{.+}}, splat (double -1.000000e+00)
+
+// OGCG-LABEL: @_Z15vecDoubleIncDecDv2_d
+// OGCG: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
+// OGCG: fadd <2 x double> %{{.+}}, splat (double -1.000000e+00)
+// OGCG: fadd <2 x double> %{{.+}}, splat (double 1.000000e+00)
+// OGCG: fadd <2 x double> %{{.+}}, splat (double -1.000000e+00)
>From 8e2e28359643b29e16ea25c0a2d01b4093b3e8e7 Mon Sep 17 00:00:00 2001
From: Haocong Lu <haocong.lu at witintech.com>
Date: Wed, 9 Sep 2026 15:26:39 +0800
Subject: [PATCH 3/3] [CIR] Fix failed case at CI
---
clang/test/CIR/CodeGenOpenACC/atomic-update.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/test/CIR/CodeGenOpenACC/atomic-update.cpp b/clang/test/CIR/CodeGenOpenACC/atomic-update.cpp
index da511723489e9..353db84000c02 100644
--- a/clang/test/CIR/CodeGenOpenACC/atomic-update.cpp
+++ b/clang/test/CIR/CodeGenOpenACC/atomic-update.cpp
@@ -53,8 +53,8 @@ void use(int x, unsigned int y, float f, HasOps ops) {
// CHECK-NEXT: cir.store %[[RECIPE_ARG]], %[[TEMP_ALLOCA]] : !cir.float, !cir.ptr<!cir.float>
//
// CHECK-NEXT: %[[TEMP_LOAD:.*]] = cir.load{{.*}} %[[TEMP_ALLOCA]] : !cir.ptr<!cir.float>, !cir.float
- // CHECK-NEXT: %[[ONE:.*]] = cir.const #cir.fp<1.000000e+00> : !cir.float
- // CHECK-NEXT: %[[INC:.*]] = cir.fsub %[[TEMP_LOAD]], %[[ONE]] : !cir.float
+ // CHECK-NEXT: %[[NEGONE:.*]] = cir.const #cir.fp<-1.000000e+00> : !cir.float
+ // CHECK-NEXT: %[[INC:.*]] = cir.fadd %[[TEMP_LOAD]], %[[NEGONE]] : !cir.float
// CHECK-NEXT: cir.store {{.*}}%[[INC]], %[[TEMP_ALLOCA]] : !cir.float, !cir.ptr<!cir.float>
//
// CHECK-NEXT: %[[TEMP_LOAD:.*]] = cir.load{{.*}} %[[TEMP_ALLOCA]] : !cir.ptr<!cir.float>, !cir.float
More information about the cfe-commits
mailing list