[clang] [CIR] Allow boolean operands in cir.cmp (PR #206846)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 28 20:02:56 PDT 2026


adams381 wrote:

@andykaylor It does happen for the unscoped `enum : bool`, which gets the same `IntegralCast` to `int` as a plain `bool`.  Integral promotion is only defined for unscoped enumerations, so in `enum class E : bool` there's nothing to promote and both operands of `a == b` stay at type `E`.

CIRGenTypes converts an enum through its underlying type, so that operand arrives as `!cir.bool`, and classic CodeGen compares these values as i1 (`icmp eq i1`, `icmp ult i1` for `<`).  That makes `!cir.bool` look right to me and `cir.cmp`'s operand constraint the thing that was out of step.  If enums do get their own CIR type later, this is one entry to drop from `CIR_ComparableType`.

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


More information about the cfe-commits mailing list