https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/181325

>From 6e2447c1fb886cc4f4cb29d053f448b5b106e507 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Fri, 13 Feb 2026 08:26:21 +0100
Subject: [PATCH] [clang][bytecode] Fix multi-word complex division

---
 clang/lib/AST/ByteCode/Interp.h   | 6 ++----
 clang/test/AST/ByteCode/complex.c | 2 ++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 1bfa347a9016a..db9514486aa6b 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -481,10 +481,8 @@ inline bool Divc(InterpState &S, CodePtr OpPC) {
     const T &RHSR = RHS.elem<T>(0);
     const T &RHSI = RHS.elem<T>(1);
     unsigned Bits = LHSR.bitWidth();
-    const T Zero = T::from(0, Bits);
 
-    if (Compare(RHSR, Zero) == ComparisonCategoryResult::Equal &&
-        Compare(RHSI, Zero) == ComparisonCategoryResult::Equal) {
+    if (RHSR.isZero() && RHSI.isZero()) {
       const SourceInfo &E = S.Current->getSource(OpPC);
       S.FFDiag(E, diag::note_expr_divide_by_zero);
       return false;
@@ -507,7 +505,7 @@ inline bool Divc(InterpState &S, CodePtr OpPC) {
     if (T::add(A, B, Bits, &Den))
       return false;
 
-    if (Compare(Den, Zero) == ComparisonCategoryResult::Equal) {
+    if (Den.isZero()) {
       const SourceInfo &E = S.Current->getSource(OpPC);
       S.FFDiag(E, diag::note_expr_divide_by_zero);
       return false;
diff --git a/clang/test/AST/ByteCode/complex.c 
b/clang/test/AST/ByteCode/complex.c
index a39f83160ef8c..12c51f95ff7c6 100644
--- a/clang/test/AST/ByteCode/complex.c
+++ b/clang/test/AST/ByteCode/complex.c
@@ -28,3 +28,5 @@ void testComplexFloat(_Atomic(_Complex float) *fp) {
   _Complex float f = *fp;
   *fp = f;
 }
+
+void ZeroNeedsAlloc() { 9999999999999999999wb / 1wbi; } // both-warning 
2{{'_BitInt' suffix for literals is a C23 extension}}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to