[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 05:42:49 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:

If I changed this, this would affect a lot more than amdgpu, and that includes a few regressions, which have to be handled in separate PRs. @arsenm This sounds like a good stopgap for now.

Also, isLegal is good because even if in some backend that doesn't exist, it is legal for vectors, how is this logic wrong? isLegal is the right way to do this before vectors even if in practice it is not.

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


More information about the llvm-commits mailing list