[llvm] [DAG] SelectionDAG::canCreateUndefOrPoison - Mark AVGFLOORS and AVGCEILS as safe (PR #148191)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 07:33:47 PDT 2025


================
@@ -0,0 +1,16 @@
+; RUN: llc < %s -march=arm64 -mcpu=apple-m1 | FileCheck %s
+
+; CHECK-LABEL: avg:
+; CHECK:       add
+; CHECK:       lsr
+; CHECK:       ret
+
+define zeroext i8 @avg(i8 noundef zeroext %a, i8 noundef zeroext %b) {
+entry:
+  %conv = zext i8 %a to i16
+  %conv1 = zext i8 %b to i16
+  %add = add nuw nsw i16 %conv1, %conv
+  %div3 = lshr i16 %add, 1
+  %conv2 = trunc nuw i16 %div3 to i8
+  ret i8 %conv2
+}
----------------
RKSimon wrote:

Once #148634 lands, you should be able to quickly remove avgfloor-u8.ll and add suitable test coverage to hadd-combine.ll similar to @src (call them something like @haddu_freeze/@rhaddu_freeze etc.).

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


More information about the llvm-commits mailing list