[llvm] Lowering `~x | (x - 1)` to `~blsi(x)` (PR #186722)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 16 18:48:14 PDT 2026
================
@@ -0,0 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi -filetype=asm | FileCheck %s
+
+define i64 @foo(i64 %x) {
+; CHECK-LABEL: foo:
+; CHECK: # %bb.0:
+; CHECK-NEXT: blsiq %rdi, %rax
+; CHECK-NEXT: notq %rax
+; CHECK-NEXT: retq
+ %neg = sub i64 0, %x
+ %and = and i64 %x, %neg
+ %not = xor i64 %and, -1
+ ret i64 %not
+}
----------------
user1342234 wrote:
Done, thanks
https://github.com/llvm/llvm-project/pull/186722
More information about the llvm-commits
mailing list