[llvm] [X86] Remove redundant TEST after shifts when count is non-zero (PR #169069)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 10:04:43 PST 2025
================
@@ -386,3 +380,20 @@ define i32 @shl_var_self_select_amt_never_zero(i32 %a0, i32 %a1, i32 %a2, i32 %a
%r = select i1 %c, i32 %s, i32 %a2
ret i32 %r
}
+
+define range(i8 0, 2) i8 @no_test_emitted_when_assume_shift_amt_gt_zero(i64 noundef %0, i32 noundef %1) {
+; CHECK-LABEL: no_test_emitted_when_assume_shift_amt_gt_zero:
+; CHECK: # %bb.0:
+; CHECK-NEXT: movl %esi, %ecx
+; CHECK-NEXT: # kill: def $cl killed $cl killed $ecx
+; CHECK-NEXT: shlq %cl, %rdi
+; CHECK-NEXT: sete %al
+; CHECK-NEXT: retq
+ %3 = icmp sgt i32 %1, 0
+ tail call void @llvm.assume(i1 %3)
+ %4 = zext nneg i32 %1 to i64
+ %5 = shl i64 %0, %4
+ %6 = icmp eq i64 %5, 0
+ %7 = zext i1 %6 to i8
+ ret i8 %7
+}
----------------
arsenm wrote:
Should have more examples, and some negative tests. In a more realistic scenario, I would hope the assume would have been dropped and turned into a range attribute on %1
https://github.com/llvm/llvm-project/pull/169069
More information about the llvm-commits
mailing list