[llvm] [SelectionDAG][RISCV] Fix break of vnsrl pattern in issue #94265 (PR #95563)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 29 01:49:13 PDT 2024


================
@@ -4339,6 +4339,21 @@ class TargetLowering : public TargetLoweringBase {
     return isTypeLegal(VT);
   }
 
+  /// Same as isTypeDesirableForOp(unsigned Opc, EVT VT), but also check if
+  /// the target is 'desirable' to truncate or extend OldVT to NewVT only using
+  /// the given node type, without the need of explicit trunc or ext. e.g. On
+  /// RISC-V Vector extension, vnsrl.wi can directly convert <n x i32> to <n x
+  /// i16> when shifting, with no extra trunc operations needed.
+  virtual bool isTypeDesirableForOpWithCast(unsigned Opc, EVT NewVT,
+                                            EVT OldVT) const {
----------------
Fros1er wrote:

There are tons of usage of isTypeDesirableForOp, we need to make change everywhere if the parameter changes. Besides, as far as I know, it's rare for instructions to truncate operand while doing other jobs. Updating the existing one to NewVT + OldVT may be unnecessary for most of the cases.

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


More information about the llvm-commits mailing list