[llvm] [AMDGPU][TargetLowering] Allow forming overflow op if it is legal (PR #156266)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 23 08:17:31 PDT 2025


================
@@ -3455,6 +3455,10 @@ class LLVM_ABI TargetLoweringBase {
   /// matching of other patterns.
   virtual bool shouldFormOverflowOp(unsigned Opcode, EVT VT,
                                     bool MathUsed) const {
+    // Form it if it is legal.
+    if (isOperationLegal(Opcode, VT))
+      return true;
+
----------------
AZero13 wrote:

Legal means has a matching machine instruction (I don't know of any exceptions to this), so at that point, if there is a machine instruction that does this all in one go (like AMDGPU seems to), then there should not be any cost to it? 

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


More information about the llvm-commits mailing list