[clang] clang/CodeGen/RISCV: test lowering of math builtins (PR #71399)

2023-11-06 Thread Ramkumar Ramachandra via cfe-commits

https://github.com/artagnon created 
https://github.com/llvm/llvm-project/pull/71399

Ever since 98c90a1 (ISel: introduce vector ISD::LRINT, ISD::LLRINT; custom 
RISCV lowering) landed, there have been several discussions on how the lrint 
and llrint libcalls would lower to LLVM IR via clang on RV32 and RV64, in an 
effort to enable vectorization of lrint and llrint via SLPVectorizer and 
LoopVectorize. This patch adds a new math-builtins.c test to the RISC-V target 
to test the lowering of all math libcalls, including lrint and llrint.

>From 1f495f0002c2aaa788823726943945309271401c Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra 
Date: Mon, 6 Nov 2023 13:34:25 +
Subject: [PATCH] clang/CodeGen/RISCV: test lowering of math builtins

Ever since 98c90a1 (ISel: introduce vector ISD::LRINT, ISD::LLRINT;
custom RISCV lowering) landed, there have been several discussions on
how the lrint and llrint libcalls would lower to LLVM IR via clang on
RV32 and RV64, in an effort to enable vectorization of lrint and llrint
via SLPVectorizer and LoopVectorize. This patch adds a new
math-builtins.c test to the RISC-V target to test the lowering of all
math libcalls, including lrint and llrint.
---
 clang/test/CodeGen/RISCV/math-builtins.c | 459 +++
 clang/test/CodeGen/{ => X86}/math-builtins.c |   0
 2 files changed, 459 insertions(+)
 create mode 100644 clang/test/CodeGen/RISCV/math-builtins.c
 rename clang/test/CodeGen/{ => X86}/math-builtins.c (100%)

diff --git a/clang/test/CodeGen/RISCV/math-builtins.c 
b/clang/test/CodeGen/RISCV/math-builtins.c
new file mode 100644
index 000..9630d62f0f48292
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/math-builtins.c
@@ -0,0 +1,459 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck 
--check-prefix=RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - | FileCheck 
--check-prefix=RV64 %s
+
+float ceilf(float);
+double ceil(double);
+long double ceill(long double);
+float copysignf(float, float);
+double copysign(double, double);
+long double copysignl(long double, long double);
+float cosf(float);
+double cos(double);
+long double cosl(long double);
+float expf(float);
+double exp(double);
+long double expl(long double);
+float exp2f(float);
+double exp2(double);
+long double exp2l(long double);
+float fabsf(float);
+double fabs(double);
+long double fabsl(long double);
+float floorf(float);
+double floor(double);
+long double floorl(long double);
+float fmaxf(float, float);
+double fmax(double, double);
+long double fmaxl(long double, long double);
+float fminf(float, float);
+double fmin(double, double);
+long double fminl(long double, long double);
+float fmodf(float, float);
+double fmod(double, double);
+long double fmodl(long double, long double);
+float logf(float);
+double log(double);
+long double logl(long double);
+float log10f(float);
+double log10(double);
+long double log10l(long double);
+float log2f(float);
+double log2(double);
+long double log2l(long double);
+float nearbyintf(float);
+double nearbyint(double);
+long double nearbyintl(long double);
+float powf(float, float);
+double pow(double, double);
+long double powl(long double, long double);
+float rintf(float);
+double rint(double);
+long double rintl(long double);
+long lrintf(float);
+long lrint(double);
+long lrintl(long double);
+long long llrintf(float);
+long long llrint(double);
+long long llrintl(long double);
+float roundf(float);
+double round(double);
+long double roundl(long double);
+long lroundf(float);
+long lround(double);
+long lroundl(long double);
+long long llroundf(float);
+long long llround(double);
+long long llroundl(long double);
+float roundevenf(float);
+double roundeven(double);
+long double roundevenl(long double);
+float sinf(float);
+double sin(double);
+long double sinl(long double);
+float sqrtf(float);
+double sqrt(double);
+long double sqrtl(long double);
+float truncf(float);
+double trunc(double);
+long double truncl(long double);
+
+// RV32-LABEL: define dso_local void @test(
+// RV32-SAME: float noundef [[FARG:%.*]], double noundef [[DARG:%.*]], fp128 
noundef [[LDARG:%.*]]) #[[ATTR0:[0-9]+]] {
+// RV32-NEXT:  entry:
+// RV32-NEXT:[[FARG_ADDR:%.*]] = alloca float, align 4
+// RV32-NEXT:[[DARG_ADDR:%.*]] = alloca double, align 8
+// RV32-NEXT:[[LDARG_ADDR:%.*]] = alloca fp128, align 16
+// RV32-NEXT:store float [[FARG]], ptr [[FARG_ADDR]], align 4
+// RV32-NEXT:store double [[DARG]], ptr [[DARG_ADDR]], align 8
+// RV32-NEXT:store fp128 [[LDARG]], ptr [[LDARG_ADDR]], align 16
+// RV32-NEXT:[[TMP0:%.*]] = load float, ptr [[FARG_ADDR]], align 4
+// RV32-NEXT:[[TMP1:%.*]] = call float @llvm.ceil.f32(float [[TMP0]])
+// RV32-NEXT:[[TMP2:%.*]] = load double, ptr [[DARG_ADDR]], align 8
+// RV32-NEXT:[[TMP3:%.*]] = call double @llvm.ceil.f64(double [[TMP2]])
+// RV32-NEXT:  

[clang] clang/CodeGen/RISCV: test lowering of math builtins (PR #71399)

2023-11-06 Thread Ramkumar Ramachandra via cfe-commits

artagnon wrote:

The main takeaways here:
- There is only ever an i64 variant of llrint produced, and we have tested 
codegen of that on RV32 and RV64.
- Only an i32 variant of lrint is produced on RV32, and an i64 variant on RV64. 
We have tested the codegen of both.

Hence, I would conclude that #70926 is closed justifiably, and #69945 is safe 
to re-land with respect to RISC-V (there have been some other fixes to it that 
have already landed).

https://github.com/llvm/llvm-project/pull/71399
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang/CodeGen/RISCV: test lowering of math builtins (PR #71399)

2023-11-14 Thread Ramkumar Ramachandra via cfe-commits

artagnon wrote:

Gentle ping.

https://github.com/llvm/llvm-project/pull/71399
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang/CodeGen/RISCV: test lowering of math builtins (PR #71399)

2023-11-22 Thread Ramkumar Ramachandra via cfe-commits

https://github.com/artagnon closed 
https://github.com/llvm/llvm-project/pull/71399
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 59edb43 - clang/APINotes: squelch a -Wparantheses warning (NFC)

2023-11-24 Thread Ramkumar Ramachandra via cfe-commits

Author: Ramkumar Ramachandra
Date: 2023-11-24T09:43:37Z
New Revision: 59edb432256064ee4f66c3a30fd4875030c5166b

URL: 
https://github.com/llvm/llvm-project/commit/59edb432256064ee4f66c3a30fd4875030c5166b
DIFF: 
https://github.com/llvm/llvm-project/commit/59edb432256064ee4f66c3a30fd4875030c5166b.diff

LOG: clang/APINotes: squelch a -Wparantheses warning (NFC)

Added: 


Modified: 
clang/include/clang/APINotes/APINotesManager.h

Removed: 




diff  --git a/clang/include/clang/APINotes/APINotesManager.h 
b/clang/include/clang/APINotes/APINotesManager.h
index 823b52ed28b5981..c19082fdb597d84 100644
--- a/clang/include/clang/APINotes/APINotesManager.h
+++ b/clang/include/clang/APINotes/APINotesManager.h
@@ -159,7 +159,7 @@ class APINotesManager {
   ArrayRef getCurrentModuleReaders() const {
 bool HasPublic = CurrentModuleReaders[ReaderKind::Public];
 bool HasPrivate = CurrentModuleReaders[ReaderKind::Private];
-assert(!HasPrivate || HasPublic && "private module requires public 
module");
+assert(!HasPrivate || (HasPublic && "private module requires public 
module"));
 if (!HasPrivate && !HasPublic)
   return {};
 return ArrayRef(CurrentModuleReaders).slice(0, HasPrivate ? 2 : 1);



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2f1399c - clang/APINotes: fix parenthesization of &&, ||

2023-11-29 Thread Ramkumar Ramachandra via cfe-commits

Author: Ramkumar Ramachandra
Date: 2023-11-29T18:53:30Z
New Revision: 2f1399c73f52aac77afbdd2ba53dd9f1dcbb7c98

URL: 
https://github.com/llvm/llvm-project/commit/2f1399c73f52aac77afbdd2ba53dd9f1dcbb7c98
DIFF: 
https://github.com/llvm/llvm-project/commit/2f1399c73f52aac77afbdd2ba53dd9f1dcbb7c98.diff

LOG: clang/APINotes: fix parenthesization of &&, ||

Follow up on 59edb43 (clang/APINotes: squelch a -Wparantheses warning
(NFC)) to fix parenthesization, as requested by David Blaikie.

Added: 


Modified: 
clang/include/clang/APINotes/APINotesManager.h

Removed: 




diff  --git a/clang/include/clang/APINotes/APINotesManager.h 
b/clang/include/clang/APINotes/APINotesManager.h
index c19082fdb597d84..18375c9e51a173b 100644
--- a/clang/include/clang/APINotes/APINotesManager.h
+++ b/clang/include/clang/APINotes/APINotesManager.h
@@ -159,7 +159,7 @@ class APINotesManager {
   ArrayRef getCurrentModuleReaders() const {
 bool HasPublic = CurrentModuleReaders[ReaderKind::Public];
 bool HasPrivate = CurrentModuleReaders[ReaderKind::Private];
-assert(!HasPrivate || (HasPublic && "private module requires public 
module"));
+assert((!HasPrivate || HasPublic) && "private module requires public 
module");
 if (!HasPrivate && !HasPublic)
   return {};
 return ArrayRef(CurrentModuleReaders).slice(0, HasPrivate ? 2 : 1);



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libc] [compiler-rt] [llvm] [flang] [clang] [libcxx] [msan] Intercept mallinfo2 (PR #73729)

2023-11-29 Thread Ramkumar Ramachandra via cfe-commits

artagnon wrote:

Hi, this commit broke the buildbot:

```
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/compiler-rt/test/msan/Linux/mallinfo.cpp:12:26:
 error: invalid use of incomplete type 'mallinfo2'
   12 |   struct mallinfo2 mi2 = mallinfo2();
  |  ^~~
```

https://github.com/llvm/llvm-project/pull/73729
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits