[llvm] [DAG] Constant Folding for U/SMUL_LOHI (PR #69437)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 02:33:48 PDT 2023


================
@@ -2619,37 +2619,38 @@ define i64 @v_test_udiv64_mulhi_fold(i64 %arg) {
 ; VI-LABEL: v_test_udiv64_mulhi_fold:
 ; VI:       ; %bb.0:
 ; VI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; VI-NEXT:    v_mov_b32_e32 v4, 0xa7c5
-; VI-NEXT:    v_mul_u32_u24_e32 v3, 0x500, v4
-; VI-NEXT:    v_mul_hi_u32_u24_e32 v2, 0x500, v4
-; VI-NEXT:    v_add_u32_e32 v3, vcc, 0x4237, v3
-; VI-NEXT:    v_addc_u32_e32 v5, vcc, 0, v2, vcc
-; VI-NEXT:    v_add_u32_e32 v6, vcc, 0xa9000000, v3
-; VI-NEXT:    s_mov_b32 s6, 0xfffe7960
-; VI-NEXT:    v_mad_u64_u32 v[2:3], s[4:5], v6, s6, 0
-; VI-NEXT:    v_addc_u32_e32 v7, vcc, v5, v4, vcc
-; VI-NEXT:    v_mul_lo_u32 v4, v7, s6
+; VI-NEXT:    s_mov_b32 s4, 0x346d900
+; VI-NEXT:    s_add_u32 s4, 0x4237, s4
----------------
Pierre-vh wrote:

Not yet, it looks like this:
```
      t420: v2i32 = BUILD_VECTOR Constant:i32<16951>, Constant:i32<0>
    t421: i64 = bitcast t420
      t414: v2i32 = BUILD_VECTOR Constant:i32<54974720>, Constant:i32<0>
    t415: i64 = bitcast t414
  t190: i64 = add t421, t415
```
We can't do a generic combine for the bitcast I think. I tried it and it caused loops. I think the easiest would be to make a DAG equivalent of the GISel helper that looks through splats and just returns the value directly.

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


More information about the llvm-commits mailing list