[clang] [CIR] Fix failing tests after bool load change (PR #194468)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 27 14:49:20 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Andy Kaylor (andykaylor)
<details>
<summary>Changes</summary>
This fixes CIR tests that were failing as a result of the change in how bool load values are truncated in
https://github.com/llvm/llvm-project/pull/193783
---
Full diff: https://github.com/llvm/llvm-project/pull/194468.diff
7 Files Affected:
- (modified) clang/test/CIR/CodeGen/binop.cpp (+4-4)
- (modified) clang/test/CIR/CodeGen/cmp.cpp (+4-4)
- (modified) clang/test/CIR/CodeGen/complex.cpp (+2-2)
- (modified) clang/test/CIR/CodeGen/if.cpp (+5-5)
- (modified) clang/test/CIR/CodeGen/ternary-throw.cpp (+4-4)
- (modified) clang/test/CIR/CodeGen/ternary.cpp (+3-3)
- (modified) clang/test/CIR/CodeGen/unary.cpp (+1-1)
``````````diff
diff --git a/clang/test/CIR/CodeGen/binop.cpp b/clang/test/CIR/CodeGen/binop.cpp
index f55ff858bf79e..c4f116ae64345 100644
--- a/clang/test/CIR/CodeGen/binop.cpp
+++ b/clang/test/CIR/CodeGen/binop.cpp
@@ -632,22 +632,22 @@ void b1(bool a, bool b) {
// OGCG: %[[ZEXT1:.*]] = zext i1 %[[ARG1]] to i8
// OGCG: store i8 %[[ZEXT1]], ptr %[[B_ADDR]]
// OGCG: %[[A_VAL:.*]] = load i8, ptr %[[A_ADDR]]
-// OGCG: %[[A_BOOL:.*]] = trunc i8 %[[A_VAL]] to i1
+// OGCG: %[[A_BOOL:.*]] = icmp ne i8 %[[A_VAL]], 0
// OGCG: br i1 %[[A_BOOL]], label %[[AND_TRUE:.+]], label %[[AND_MERGE:.+]]
// OGCG: [[AND_TRUE]]:
// OGCG: %[[B_VAL:.*]] = load i8, ptr %[[B_ADDR]]
-// OGCG: %[[B_BOOL:.*]] = trunc i8 %[[B_VAL]] to i1
+// OGCG: %[[B_BOOL:.*]] = icmp ne i8 %[[B_VAL]], 0
// OGCG: br label %[[AND_MERGE:.+]]
// OGCG: [[AND_MERGE]]:
// OGCG: %[[AND_PHI:.*]] = phi i1 [ false, %[[ENTRY]] ], [ %[[B_BOOL]], %[[AND_TRUE]] ]
// OGCG: %[[ZEXT_AND:.*]] = zext i1 %[[AND_PHI]] to i8
// OGCG: store i8 %[[ZEXT_AND]], ptr %[[X]]
// OGCG: %[[X_VAL:.*]] = load i8, ptr %[[X]]
-// OGCG: %[[X_BOOL:.*]] = trunc i8 %[[X_VAL]] to i1
+// OGCG: %[[X_BOOL:.*]] = icmp ne i8 %[[X_VAL]], 0
// OGCG: br i1 %[[X_BOOL]], label %[[OR_MERGE:.+]], label %[[OR_FALSE:.+]]
// OGCG: [[OR_FALSE]]:
// OGCG: %[[B_VAL2:.*]] = load i8, ptr %[[B_ADDR]]
-// OGCG: %[[B_BOOL2:.*]] = trunc i8 %[[B_VAL2]] to i1
+// OGCG: %[[B_BOOL2:.*]] = icmp ne i8 %[[B_VAL2]], 0
// OGCG: br label %[[OR_MERGE]]
// OGCG: [[OR_MERGE]]:
// OGCG: %[[OR_PHI:.*]] = phi i1 [ true, %[[AND_MERGE]] ], [ %[[B_BOOL2]], %[[OR_FALSE]] ]
diff --git a/clang/test/CIR/CodeGen/cmp.cpp b/clang/test/CIR/CodeGen/cmp.cpp
index 1d84020509a94..1e8569bf576e5 100644
--- a/clang/test/CIR/CodeGen/cmp.cpp
+++ b/clang/test/CIR/CodeGen/cmp.cpp
@@ -454,11 +454,11 @@ void bool_cmp(bool a, bool b) {
// OGCG: store i8 %[[B_INIT]], ptr %[[B_PTR]]
// OGCG: %[[A1:.*]] = load i8, ptr %[[A_PTR]]
-// OGCG: %[[A1_TRUNC:.*]] = trunc i8 %[[A1]] to i1
-// OGCG: %[[A1_EXT:.*]] = zext i1 %[[A1_TRUNC]] to i32
+// OGCG: %[[A1_BOOL:.*]] = icmp ne i8 %[[A1]], 0
+// OGCG: %[[A1_EXT:.*]] = zext i1 %[[A1_BOOL]] to i32
// OGCG: %[[B1:.*]] = load i8, ptr %[[B_PTR]]
-// OGCG: %[[B1_TRUNC:.*]] = trunc i8 %[[B1]] to i1
-// OGCG: %[[B1_EXT:.*]] = zext i1 %[[B1_TRUNC]] to i32
+// OGCG: %[[B1_BOOL:.*]] = icmp ne i8 %[[B1]], 0
+// OGCG: %[[B1_EXT:.*]] = zext i1 %[[B1_BOOL]] to i32
// OGCG: %[[CMP1:.*]] = icmp sgt i32 %[[A1_EXT]], %[[B1_EXT]]
// OGCG: %[[CMP1_BOOL:.*]] = zext i1 %[[CMP1]] to i8
// OGCG: store i8 %[[CMP1_BOOL]], ptr %[[X_PTR]]
diff --git a/clang/test/CIR/CodeGen/complex.cpp b/clang/test/CIR/CodeGen/complex.cpp
index 1bbc8558cb540..a9a5f2550b88b 100644
--- a/clang/test/CIR/CodeGen/complex.cpp
+++ b/clang/test/CIR/CodeGen/complex.cpp
@@ -721,7 +721,7 @@ void foo27(bool cond, int _Complex a, int _Complex b) {
// OGCG: %[[COND:.*]] = alloca i8, align 1
// OGCG: %[[RESULT:.*]] = alloca { i32, i32 }, align 4
// OGCG: %[[TMP_COND:.*]] = load i8, ptr %[[COND]], align 1
-// OGCG: %[[COND_VAL:.*]] = trunc i8 %[[TMP_COND]] to i1
+// OGCG: %[[COND_VAL:.*]] = icmp ne i8 %[[TMP_COND]], 0
// OGCG: br i1 %[[COND_VAL]], label %[[TRUE_BB:.*]], label %[[FALSE_BB:.*]]
// OGCG: [[TRUE_BB]]:
// OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[COMPLEX_A]], i32 0, i32 0
@@ -1387,7 +1387,7 @@ void real_on_scalar_bool() {
// OGCG: %[[A_ADDR:.*]] = alloca i8, align 1
// OGCG: %[[B_ADDR:.*]] = alloca i8, align 1
// OGCG: %[[TMP_A:.*]] = load i8, ptr %[[A_ADDR]], align 1
-// OGCG: %[[TMP_A_I1:.*]] = trunc i8 %[[TMP_A]] to i1
+// OGCG: %[[TMP_A_I1:.*]] = icmp ne i8 %[[TMP_A]], 0
// OGCG: %[[TMP_A_I8:.*]] = zext i1 %[[TMP_A_I1]] to i8
// OGCG: store i8 %[[TMP_A_I8]], ptr %[[B_ADDR]], align 1
diff --git a/clang/test/CIR/CodeGen/if.cpp b/clang/test/CIR/CodeGen/if.cpp
index fc281bd362015..b5e0feeccb25e 100644
--- a/clang/test/CIR/CodeGen/if.cpp
+++ b/clang/test/CIR/CodeGen/if.cpp
@@ -50,7 +50,7 @@ int if0(bool a) {
// OGCG: %[[STOREDV:.*]] = zext i1 %a to i8
// OGCG: store i8 %[[STOREDV]], ptr %[[A_ADDR]], align 1
// OGCG: %[[LOADTMP:.*]] = load i8, ptr %[[A_ADDR]], align 1
-// OGCG: %[[LOADEDV:.*]] = trunc i8 %[[LOADTMP]] to i1
+// OGCG: %[[LOADEDV:.*]] = icmp ne i8 %[[LOADTMP]], 0
// OGCG: br i1 %[[LOADEDV]], label %[[THEN_LABEL:.*]], label %[[END_LABEL:.*]]
// OGCG: [[THEN_LABEL]]:
// OGCG: store i32 2, ptr %[[RETVAL]], align 4
@@ -232,8 +232,8 @@ void if2(int a, bool b, bool c) {
// OGCG: [[IF_THEN]]:
// OGCG: store i32 3, ptr %[[X]], align 4
// OGCG: %[[B_LOAD:.*]] = load i8, ptr %[[B_ADDR]], align 1
-// OGCG: %[[B_TRUNC:.*]] = trunc i8 %[[B_LOAD]] to i1
-// OGCG: br i1 %[[B_TRUNC]], label %[[IF_THEN2:.*]], label %[[IF_END:.*]]
+// OGCG: %[[B_BOOL:.*]] = icmp ne i8 %[[B_LOAD]], 0
+// OGCG: br i1 %[[B_BOOL]], label %[[IF_THEN2:.*]], label %[[IF_END:.*]]
// OGCG: [[IF_THEN2]]:
// OGCG: store i32 8, ptr %[[X]], align 4
// OGCG: br label %[[IF_END]]
@@ -241,8 +241,8 @@ void if2(int a, bool b, bool c) {
// OGCG: br label %[[IF_END6:.*]]
// OGCG: [[IF_ELSE]]:
// OGCG: %[[C_LOAD:.*]] = load i8, ptr %[[C_ADDR]], align 1
-// OGCG: %[[C_TRUNC:.*]] = trunc i8 %[[C_LOAD]] to i1
-// OGCG: br i1 %[[C_TRUNC]], label %[[IF_THEN4:.*]], label %[[IF_END5:.*]]
+// OGCG: %[[C_BOOL:.*]] = icmp ne i8 %[[C_LOAD]], 0
+// OGCG: br i1 %[[C_BOOL]], label %[[IF_THEN4:.*]], label %[[IF_END5:.*]]
// OGCG: [[IF_THEN4]]:
// OGCG: store i32 14, ptr %[[X]], align 4
// OGCG: br label %[[IF_END5]]
diff --git a/clang/test/CIR/CodeGen/ternary-throw.cpp b/clang/test/CIR/CodeGen/ternary-throw.cpp
index 52b69d476f3f2..3a0d221d608a0 100644
--- a/clang/test/CIR/CodeGen/ternary-throw.cpp
+++ b/clang/test/CIR/CodeGen/ternary-throw.cpp
@@ -56,7 +56,7 @@ const int& test_cond_throw_false(bool flag) {
// OGCG: %[[A:.*]] = alloca i32
// OGCG: store i32 10, ptr %[[A]]
// OGCG: %{{.*}} = load i8, ptr %{{.*}}
-// OGCG: %[[BOOL:.*]] = trunc i8 %{{.*}} to i1
+// OGCG: %[[BOOL:.*]] = icmp ne i8 %{{.*}}, 0
// OGCG: br i1 %[[BOOL]], label %[[TRUE_BB:.*]], label %[[FALSE_BB:.*]]
// OGCG: [[TRUE_BB]]:
// OGCG: br label %[[END:.*]]
@@ -119,7 +119,7 @@ const int& test_cond_throw_true(bool flag) {
// OGCG: %[[A:.*]] = alloca i32
// OGCG: store i32 10, ptr %[[A]]
// OGCG: %{{.*}} = load i8, ptr %{{.*}}
-// OGCG: %[[BOOL:.*]] = trunc i8 %{{.*}} to i1
+// OGCG: %[[BOOL:.*]] = icmp ne i8 %{{.*}}, 0
// OGCG: br i1 %[[BOOL]], label %[[TRUE_BB:.*]], label %[[FALSE_BB:.*]]
// OGCG: [[TRUE_BB]]:
// OGCG: %{{.*}} = call{{.*}} ptr @__cxa_allocate_exception
@@ -291,7 +291,7 @@ int test_agg_cond_throw_false(bool flag, struct s6 a1, struct s6 a2) {
// OGCG: %[[A2:.*]] = alloca %struct.s6
// OGCG: %{{.*}} = alloca i8
// OGCG: %[[LOAD:.*]] = load i8, ptr %{{.*}}
-// OGCG: %[[BOOL:.*]] = trunc i8 %[[LOAD]] to i1
+// OGCG: %[[BOOL:.*]] = icmp ne i8 %[[LOAD]], 0
// OGCG: br i1 %[[BOOL]], label %[[TRUE_BB:.*]], label %[[FALSE_BB:.*]]
// OGCG: [[TRUE_BB]]:
// OGCG: br label %[[END:.*]]
@@ -356,7 +356,7 @@ int test_agg_cond_throw_true(bool flag, struct s6 a1, struct s6 a2) {
// OGCG: %[[A2:.*]] = alloca %struct.s6
// OGCG: %{{.*}} = alloca i8
// OGCG: %[[LOAD:.*]] = load i8, ptr %{{.*}}
-// OGCG: %[[BOOL:.*]] = trunc i8 %[[LOAD]] to i1
+// OGCG: %[[BOOL:.*]] = icmp ne i8 %[[LOAD]], 0
// OGCG: br i1 %[[BOOL]], label %[[TRUE_BB:.*]], label %[[FALSE_BB:.*]]
// OGCG: [[TRUE_BB]]:
// OGCG: %[[EXC:.*]] = call{{.*}} ptr @__cxa_allocate_exception
diff --git a/clang/test/CIR/CodeGen/ternary.cpp b/clang/test/CIR/CodeGen/ternary.cpp
index c4eaa1f43ea77..51b9ab7c7db40 100644
--- a/clang/test/CIR/CodeGen/ternary.cpp
+++ b/clang/test/CIR/CodeGen/ternary.cpp
@@ -185,7 +185,7 @@ void test_cond_lvalue_assign(bool flag) {
// OGCG: %[[A:.*]] = alloca i32
// OGCG: %[[B:.*]] = alloca i32
// OGCG: %[[FLAG_VAL:.*]] = load i8, ptr %[[FLAG]]
-// OGCG: %[[COND:.*]] = trunc i8 %[[FLAG_VAL]] to i1
+// OGCG: %[[COND:.*]] = icmp ne i8 %[[FLAG_VAL]], 0
// OGCG: br i1 %[[COND]], label %[[TRUE_BB:.*]], label %[[FALSE_BB:.*]]
// OGCG: [[TRUE_BB]]:
// OGCG: br label %[[MERGE_BB:.*]]
@@ -237,7 +237,7 @@ int& test_cond_lvalue_ref(bool cond, int x, int y) {
// OGCG: %[[X:.*]] = alloca i32
// OGCG: %[[Y:.*]] = alloca i32
// OGCG: %[[COND_VAL:.*]] = load i8, ptr %[[COND]]
-// OGCG: %[[BOOL:.*]] = trunc i8 %[[COND_VAL]] to i1
+// OGCG: %[[BOOL:.*]] = icmp ne i8 %[[COND_VAL]], 0
// OGCG: br i1 %[[BOOL]], label %[[TRUE_BB:.*]], label %[[FALSE_BB:.*]]
// OGCG: [[TRUE_BB]]:
// OGCG: br label %[[MERGE_BB:.*]]
@@ -292,7 +292,7 @@ void test_cond_lvalue_compound(bool flag) {
// OGCG: %[[A:.*]] = alloca i32
// OGCG: %[[B:.*]] = alloca i32
// OGCG: %[[FLAG_VAL:.*]] = load i8, ptr %[[FLAG]]
-// OGCG: %[[BOOL:.*]] = trunc i8 %[[FLAG_VAL]] to i1
+// OGCG: %[[BOOL:.*]] = icmp ne i8 %[[FLAG_VAL]], 0
// OGCG: br i1 %[[BOOL]], label %[[TRUE_BB:.*]], label %[[FALSE_BB:.*]]
// OGCG: [[TRUE_BB]]:
// OGCG: br label %[[MERGE_BB:.*]]
diff --git a/clang/test/CIR/CodeGen/unary.cpp b/clang/test/CIR/CodeGen/unary.cpp
index 4446fe5ceb1a4..2af96583fe34b 100644
--- a/clang/test/CIR/CodeGen/unary.cpp
+++ b/clang/test/CIR/CodeGen/unary.cpp
@@ -533,7 +533,7 @@ void test_logical_not() {
// OGCG: %[[A_CAST:.*]] = zext i1 %[[A_NOT]] to i32
// OGCG: store i32 %[[A_CAST]], ptr %[[A_ADDR]], align 4
// OGCG: %[[B:.*]] = load i8, ptr %[[B_ADDR:.*]], align 1
-// OGCG: %[[B_BOOL:.*]] = trunc i8 %[[B]] to i1
+// OGCG: %[[B_BOOL:.*]] = icmp ne i8 %[[B]], 0
// OGCG: %[[B_NOT:.*]] = xor i1 %[[B_BOOL]], true
// OGCG: %[[B_CAST:.*]] = zext i1 %[[B_NOT]] to i8
// OGCG: store i8 %[[B_CAST]], ptr %[[B_ADDR]], align 1
``````````
</details>
https://github.com/llvm/llvm-project/pull/194468
More information about the cfe-commits
mailing list