[llvm] [DAGCombiner] Fold patterm for srl-shl-zext (PR #138290)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri May 2 08:06:22 PDT 2025
================
@@ -0,0 +1,40 @@
+; RUN: llc < %s -mtriple=nvptx64 | FileCheck %s
+
+define i64 @test1(i64 %x, i32 %y) {
+;
+; srl (or (x, shl(zext(y),c1)),c1) -> or(srl(x,c1), zext(y))
+; c1 <= leadingzeros(zext(y))
+;
+; CHECK-LABEL: test1
+; CHECK: ld.param.u64 %[[X:rd[0-9]+]], [test1_param_0];
+; CHECK: ld.param.u32 %[[Y:rd[0-9]+]], [test1_param_1];
+; CHECK: shr.u64 %[[SHR:rd[0-9]+]], %[[X]], 5;
+; CHECK: or.b64 %[[OR:rd[0-9]+]], %[[SHR]], %[[Y]];
+; CHECK: st.param.b64 [func_retval0], %[[OR]];
+;
+ %ext = zext i32 %y to i64
+ %shl = shl i64 %ext, 5
+ %or = or i64 %x, %shl
----------------
arsenm wrote:
code has and and xor but those aren't tested here. Also should test vector cases, and negative tests for multiple uses, and not enough known bits
https://github.com/llvm/llvm-project/pull/138290
More information about the llvm-commits
mailing list