[clang] [compiler-rt] [llvm] [TargetLowering] Set the default `getCmpLibcallReturnType` to word size (PR #192441)
Alexander Richardson via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 26 15:24:12 PDT 2026
================
@@ -993,11 +993,23 @@ class LLVM_ABI TargetLoweringBase {
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
EVT VT) const;
+ /// Return the "preferred" register width on this target.
+ virtual unsigned getRegisterWidth(const DataLayout &DL) const {
+ // Currently we assume the register width matches the pointer width.
+ // NOTE: This should match Clang's `getRegisterWidth`.
+ return DL.getAddressSizeInBits(0u);
+ }
+
/// Return the ValueType for comparison libcalls. Comparison libcalls include
/// floating point comparison calls, and Ordered/Unordered check calls on
/// floating point numbers.
- virtual MVT::SimpleValueType getCmpLibcallReturnType() const {
- return MVT::i32; // return the default value
+ ///
+ /// This should match `CMP_RESULT` in `compiler-rt` and `CMPtype` in
+ /// `libgcc`. The default return is word-sized. Consider overriding on
+ /// targets that have a cheaper comparison at other sizes.
----------------
arichardson wrote:
```suggestion
/// targets that have a cheaper comparison at other sizes.
/// This affects the ABI so be sure to coordinate with
/// other compiler vendors.
```
Might be worth calling out that this needs to be consistent with GCC/other compilers?
https://github.com/llvm/llvm-project/pull/192441
More information about the cfe-commits
mailing list