[llvm] [DAG] Peek through bitcasts when canonicalizing constants to the RHS on commutable instructions (PR #112682)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 03:15:39 PDT 2024


================
@@ -2668,8 +2668,8 @@ SDValue DAGCombiner::visitADDLike(SDNode *N) {
     return C;
 
   // canonicalize constant to RHS
-  if (DAG.isConstantIntBuildVectorOrConstantInt(N0) &&
-      !DAG.isConstantIntBuildVectorOrConstantInt(N1))
+  if (DAG.isConstantIntBuildVectorOrConstantInt(peekThroughBitcasts(N0)) &&
----------------
RKSimon wrote:

Yes, although we would need to make it return bool instead of the SDNode (which is barely used tbh).

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


More information about the llvm-commits mailing list