[clang] Fix cir vec cmp fold (PR #202502)

Aayush Shrivastava via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 10 03:08:40 PDT 2026


================
@@ -3509,7 +3535,9 @@ OpFoldResult cir::VecCmpOp::fold(FoldAdaptor adaptor) {
     }
     }
 
-    elements[i] = cir::IntAttr::get(getType().getElementType(), cmpResult);
+    // Vector comparison results are 0 (false) or -1 / all-ones (true).
----------------
iamaayushrivastava wrote:

You're right that for `!cir.int<s, 1>` results, -1 and 1 are the same bit pattern (all-ones at width 1). Added a comment clarifying that for 1-bit element types, -1 and 0 are still the correct true/false bit patterns, since -1 and 1 have the same representation at width 1. Thank you for the suggestion.

https://github.com/llvm/llvm-project/pull/202502


More information about the cfe-commits mailing list