[llvm] [RISCV] Convert vector.reduce.or + cttz.elts to vfirst (PR #175952)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 14 05:47:59 PST 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp b/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
index 9163339ce..f8472911d 100644
--- a/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
+++ b/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
@@ -362,15 +362,17 @@ bool RISCVCodeGenPrepare::convertVFirstPattern(IntrinsicInst &II) {
if (EVL->getType() != XLenTy)
EVL = Builder.CreateZExt(EVL, XLenTy);
- Value *VFirst = Builder.CreateIntrinsic(
- Intrinsic::riscv_vfirst_mask, {Cond->getType(), XLenTy}, {Cond, Mask, EVL});
+ Value *VFirst =
+ Builder.CreateIntrinsic(Intrinsic::riscv_vfirst_mask,
+ {Cond->getType(), XLenTy}, {Cond, Mask, EVL});
// Replace reduce.or with (icmp sge (vfirst), 0)
// vfirst returns -1 if no element is set.
Value *Found = Builder.CreateICmpSGE(VFirst, ConstantInt::get(XLenTy, 0));
II.replaceAllUsesWith(Found);
- // Replace cttz.elts with the vfirst result (with appropriate type adjustment).
+ // Replace cttz.elts with the vfirst result (with appropriate type
+ // adjustment).
Value *VFirstCasted = Builder.CreateZExtOrTrunc(VFirst, CttzElts->getType());
CttzElts->replaceAllUsesWith(VFirstCasted);
``````````
</details>
https://github.com/llvm/llvm-project/pull/175952
More information about the llvm-commits
mailing list