[clang] [clang] Implement -fstrict-bool (PR #160790)
Bruno De Fraine via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 10 03:18:42 PST 2025
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/160790 at github.com>
brunodf-snps wrote:
> The diff is [here](https://github.com/swiftlang/llvm-project/compare/apple-fcloutier/139397212...swiftlang:llvm-project:apple-fcloutier/139397212-O0?expand=1).
I was a bit surprised by this diff. Your description says this affects the -O0 behavior, but I think it rather affects the codegen for `-fstrict-bool` (which is the default)? Before this would be range metadata + truncate, now it is range metadata + nonzero. (The effect of -O0 was always that the range metadata is omitted.)
I suppose that the LLVM optimizer can know that truncate and nonzero on an i8 in the range [0,2[ is the same thing, but this does seem to trigger different code: https://godbolt.org/z/e6YavTMx8
This does not seem wise, I think -O -fstrict-bool (the default), should stick to range metadata + truncate.
Also, this diff changes the behavior for `BitInt(1)`. As remarked before, this type both has `isBitInt()` and `hasBooleanRepresentation()`. I don't know if this is deliberate.
https://github.com/llvm/llvm-project/pull/160790
More information about the cfe-commits
mailing list