[PATCH] D129431: [TargetLowering][RISCV] Make expandCTLZ work for non-power of 2 types.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 12 11:37:10 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8eaf00e04dba: [TargetLowering][RISCV] Make expandCTLZ work for non-power of 2 types. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129431/new/

https://reviews.llvm.org/D129431

Files:
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/test/CodeGen/RISCV/pr56457.ll


Index: llvm/test/CodeGen/RISCV/pr56457.ll
===================================================================
--- llvm/test/CodeGen/RISCV/pr56457.ll
+++ llvm/test/CodeGen/RISCV/pr56457.ll
@@ -18,6 +18,9 @@
 ; CHECK-NEXT:    slli a1, a0, 49
 ; CHECK-NEXT:    srli a1, a1, 53
 ; CHECK-NEXT:    or a0, a0, a1
+; CHECK-NEXT:    slli a1, a0, 49
+; CHECK-NEXT:    srli a1, a1, 57
+; CHECK-NEXT:    or a0, a0, a1
 ; CHECK-NEXT:    not a0, a0
 ; CHECK-NEXT:    slli a0, a0, 49
 ; CHECK-NEXT:    srli a0, a0, 49
Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -7850,7 +7850,7 @@
   // return popcount(~x);
   //
   // Ref: "Hacker's Delight" by Henry Warren
-  for (unsigned i = 0; (1U << i) <= (NumBitsPerElt / 2); ++i) {
+  for (unsigned i = 0; (1U << i) < NumBitsPerElt; ++i) {
     SDValue Tmp = DAG.getConstant(1ULL << i, dl, ShVT);
     Op = DAG.getNode(ISD::OR, dl, VT, Op,
                      DAG.getNode(ISD::SRL, dl, VT, Op, Tmp));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129431.444028.patch
Type: text/x-patch
Size: 1120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220712/3855ef8f/attachment.bin>


More information about the llvm-commits mailing list