[llvm] [DAG] SelectionDAG::canCreateUndefOrPoison - Mark AVGFLOORS and AVGCEILS as safe (PR #148191)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 02:25:59 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:
Yes, a hadd-freeze.ll file should be fine - please get the patch updated to allow us to review the diffs. I'm expecting you will need to come up with a different approach for signed hadd tests as otherwise they will just fold to unsigned variants if they are known poisitive.
https://github.com/llvm/llvm-project/pull/148191
More information about the llvm-commits
mailing list