[llvm] [InstCombine] Reducing rust i128::midpoint instructions (PR #99614)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 20 09:01:58 PDT 2024


RKSimon wrote:

This is just a avgflooru node, which DAG can already recognise and handle.
```
Optimized lowered selection DAG: %bb.0 'src:start'
SelectionDAG has 22 nodes:
  t0: ch,glue = EntryToken
    t20: i64 = extract_element t27, Constant:i64<0>
  t23: ch,glue = CopyToReg t0, Register:i64 $rax, t20
    t18: i64 = extract_element t27, Constant:i64<1>
  t25: ch,glue = CopyToReg t23, Register:i64 $rdx, t18, t23:1
      t6: i64,ch = CopyFromReg t0, Register:i64 %2
      t8: i64,ch = CopyFromReg t0, Register:i64 %3
    t10: i128 = build_pair t6, t8
      t2: i64,ch = CopyFromReg t0, Register:i64 %0
      t4: i64,ch = CopyFromReg t0, Register:i64 %1
    t9: i128 = build_pair t2, t4
  t27: i128 = avgflooru t10, t9
  t26: ch = X86ISD::RET_GLUE t25, TargetConstant:i32<0>, Register:i64 $rax, Register:i64 $rdx, t25:1
```
What we're missing is better legalization handling in DAGTypeLegalizer::ExpandIntRes_AVG - your code expansion should work pretty well in there instead of InstCombine, where we shouldn't be making assumptions about type legality.

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


More information about the llvm-commits mailing list