[llvm] [GlobalISel] Add G_SUB for computeNumSignBits (PR #158384)

Yatao Wang via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 09:53:46 PDT 2025


================
@@ -177,6 +177,51 @@ TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_VASHR) {
   EXPECT_EQ(DAG->ComputeNumSignBits(Fr2), 5u);
 }
 
+TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_SUB) {
----------------
ningxinr wrote:

> I don't know if we have tests like this already but if not this could be a separate patch.

If you meant `ComputeNumSignBits` unit tests for other opcodes, then yes, there are a couple for `ZERO/SIGN_EXTEND_VECTOR*` and others. For example, right above the added test for SUB, there is the `ComputeNumSignBits_VASHR`.

I only added selection dag test because 1) I haven't found any existing unit test for `ComputeNumSignBits` and `SUB`, 2) I want to have some sort of verification that both processes produce similar results. 

https://github.com/llvm/llvm-project/pull/158384


More information about the llvm-commits mailing list