[clang] [llvm] [PPC] Implement BCD assist builtins (PR #101390)

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 2 05:41:28 PDT 2024


================
@@ -0,0 +1,58 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux -O2 -target-cpu pwr7 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -O2 -target-cpu pwr7 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -O2 -target-cpu pwr7 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define{{.*}} i64 @cdtbcd_test(i64
+// CHECK:         [[CONV:%.*]] = trunc i64 {{.*}} to i32
+// CHECK-NEXT:    [[TMP0:%.*]] = tail call i32 @llvm.ppc.cdtbcd(i32 [[CONV]])
+// CHECK-NEXT:    [[CONV1:%.*]] = zext i32 [[TMP0]] to i64
+// CHECK-NEXT:    ret i64 [[CONV1]]
+long long cdtbcd_test(long long ll) {
+    return __builtin_cdtbcd (ll);
----------------
chenzheng1030 wrote:

Hmm, for compatibility with GCC, maybe this is right. But this is not good as in clang we are also providing `__cdtbcd()` for 64 bit inputs. Using GCC's 32-bit version will cause sacrifice of accuracy. I am not sure, for this case, should we add at least a warning and remind the user the other one can be used?

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


More information about the llvm-commits mailing list