Open
Description
https://zig.godbolt.org/z/f3ac4Moxr
SelectionDAG has 12 nodes:
t0: ch,glue = EntryToken
t2: v4i16,ch = CopyFromReg t0, Register:v4i16 %0
t5: v4i32 = zero_extend t2
t4: v4i16,ch = CopyFromReg t0, Register:v4i16 %1
t6: v4i32 = zero_extend t4
t13: v4i32 = abdu t5, t6
t9: v4i16 = truncate t13
t11: ch,glue = CopyToReg t0, Register:v4i16 $d0, t9
t12: ch = AArch64ISD::RET_GLUE t11, Register:v4i16 $d0, t11:1
If a ABD node has sufficient leading zero/sign bits then it should still work in a truncated type - it doesn't have to be from a zext/sext node specifically so computeKnownBits/ComputeNumSignBits should probably be used.
- Create alive2 links to prove when abd patterns can be safely truncated
- Add test coverage (using aarch64 intrinsics is probably easiest as that will always start from ISD::ABDU/S nodes)
- Add suitable folds in DAGCombiner::visitTRUNCATE - including legality checks