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

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 27 05:58:51 PDT 2026


================
@@ -993,11 +993,25 @@ 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 or smaller comparison
+  /// encoding at other sizes. This affects the ABI so be sure to coordinate
+  /// with other compiler vendors.
+  virtual MVT::SimpleValueType
+  getCmpLibcallReturnType(const DataLayout &DL) const {
----------------
arsenm wrote:

This ought to go in the type signature in RuntimeLibcallsInfo for the specific calls. it shouldn't require a new override function. The annoying bit is this is still manual c++ code since I haven't gotten around to tablegenifying that 

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


More information about the cfe-commits mailing list