[clang] [CIR] Upstream missing support for floating point unary operator (PR #193215)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 21 07:35:03 PDT 2026
================
@@ -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
+}
----------------
Lancern wrote:
Is this test related to the patch?
https://github.com/llvm/llvm-project/pull/193215
More information about the cfe-commits
mailing list