[llvm] [WebAssembly] Optimize away mask of 63 for shl ( zext (and i32 63))) (PR #152397)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 27 00:19:13 PST 2025
================
@@ -101,6 +105,9 @@ def : Pat<(shl I64:$lhs, (and I64:$rhs, 63)), (SHL_I64 I64:$lhs, I64:$rhs)>;
def : Pat<(sra I64:$lhs, (and I64:$rhs, 63)), (SHR_S_I64 I64:$lhs, I64:$rhs)>;
def : Pat<(srl I64:$lhs, (and I64:$rhs, 63)), (SHR_U_I64 I64:$lhs, I64:$rhs)>;
+def : Pat<(shl I64:$lhs, (zext(shiftMask64FromI32 I32:$rhs))),
+ (SHL_I64 I64:$lhs, (I64_EXTEND_U_I32 I32:$rhs))>;
----------------
lukel97 wrote:
Oh woops that should indeed by SHL_I64 not SHR_U_I64. And you're right, I thought that i32 was a subregister of i64 but it's not so looks like we always need the i64_extend_u_i32!
https://github.com/llvm/llvm-project/pull/152397
More information about the llvm-commits
mailing list