[llvm] [AArch64] AArch64TargetLowering::computeKnownBitsForTargetNode - add support for AArch64ISD::MOV/MVN constants (PR #154039)

Yatao Wang via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 18 21:16:12 PDT 2025


================
@@ -8,14 +8,14 @@ define <4 x i16> @fold_urem_vec_1(<4 x i16> %x) {
 ; CHECK-NEXT:    ldr d1, [x8, :lo12:.LCPI0_0]
 ; CHECK-NEXT:    adrp x8, .LCPI0_1
 ; CHECK-NEXT:    ldr d2, [x8, :lo12:.LCPI0_1]
-; CHECK-NEXT:    adrp x8, .LCPI0_2
+; CHECK-NEXT:    mov x8, #-9223372036854775808 // =0x8000000000000000
 ; CHECK-NEXT:    ushl v1.4h, v0.4h, v1.4h
+; CHECK-NEXT:    fmov d3, x8
+; CHECK-NEXT:    adrp x8, .LCPI0_2
 ; CHECK-NEXT:    umull v1.4s, v1.4h, v2.4h
-; CHECK-NEXT:    movi d2, #0000000000000000
 ; CHECK-NEXT:    shrn v1.4h, v1.4s, #16
-; CHECK-NEXT:    fneg d2, d2
----------------
ningxinr wrote:

Suppose I add fneg(zero) as a canonical constant pattern on a different branch than this and this file stays unchanged, should I expect the move and fneg gets folded into say one single `fmov -0.0` instead? 

I tried a few things including the one proposed above in file `llvm/lib/Target/AArch64/AArch64ISelLowering.cpp`, I also tried to add `ISD::FNEG` as a case in `AArch64TargetLowering::computeKnownBitsForTargetNode` directly, but nothing seems to change the test result of this file at all. 

Should the change affect this fneg at all? Or shall I create my own test instead?

Thanks for your help! :)

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


More information about the llvm-commits mailing list