[clang] [compiler-rt] [llvm] [TargetLowering] Set the default `getCmpLibcallReturnType` to word size (PR #192441)

Trevor Gross via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 27 01:23:16 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.
----------------
tgross35 wrote:

Makes sense to me. Applied in a29b4d265b50bad2a7708b71e364b96d8701500c.

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


More information about the cfe-commits mailing list