[clang] [llvm] [RISCV] Add sifive-p470 processor (PR #102022)

2024-08-07 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/102022 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add Syntacore SCR5 RV32/64 processors definition (PR #102285)

2024-08-07 Thread Yingwei Zheng via cfe-commits
@@ -378,6 +378,32 @@ def SYNTACORE_SCR4_RV64 : RISCVProcessorModel<"syntacore-scr4-rv64", FeatureStdExtC], [TuneNoDefaultUnroll, FeaturePostRAScheduler]>; +def SYNTACORE_SCR5_RV32 :

[clang] [llvm] [RISCV] Add Hazard3 CPU (PR #102452)

2024-08-08 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: It looks like a toy project :( The RTL design is not frozen. https://github.com/llvm/llvm-project/pull/102452 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] [UBSan] Diagnose assumption violation (PR #104741)

2024-08-19 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw created https://github.com/llvm/llvm-project/pull/104741 This patch extends [D34590](https://reviews.llvm.org/D34590) to check assumption violations. >From e2ce302a0d3649594ff1a6b94420f815d0e1acde Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Mon, 19 Aug 2024

[clang] [llvm] [RISCV] Add CSRs and an instruction for Smctr and Ssctr extensions. (PR #105148)

2024-08-20 Thread Yingwei Zheng via cfe-commits
@@ -1054,6 +1054,19 @@ def FeatureStdExtSupm : RISCVExperimentalExtension<"supm", 1, 0, "'Supm' (Indicates User-mode Pointer Masking)">; +def FeatureStdExtSmctr +: RISCVExperimentalExtension<"smctr", 1, 0, +

[clang] [llvm] [RISCV] Add CSRs and an instruction for Smctr and Ssctr extensions. (PR #105148)

2024-08-20 Thread Yingwei Zheng via cfe-commits
@@ -839,6 +839,14 @@ def HLV_D : HLoad_r<0b0110110, 0b0, "hlv.d">, Sched<[]>; def HSV_D : HStore_rr<0b0110111, "hsv.d">, Sched<[]>; } +let Predicates = [HasStdExtSmctrOrSsctr] in { +def SCTRCLR : Priv<"sctrclr", 0b0001000>, Sched<[]> { dtcxzyw wrote:

[clang] [llvm] [RISCV] Add CSRs and an instruction for Smctr and Ssctr extensions. (PR #105148)

2024-08-20 Thread Yingwei Zheng via cfe-commits
@@ -1054,6 +1054,19 @@ def FeatureStdExtSupm : RISCVExperimentalExtension<"supm", 1, 0, "'Supm' (Indicates User-mode Pointer Masking)">; +def FeatureStdExtSmctr +: RISCVExperimentalExtension<"smctr", 1, 0, +

[clang] [llvm] [RISCV] Add CSRs and an instruction for Smctr and Ssctr extensions. (PR #105148)

2024-08-20 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/105148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Remove experimental for Ssqosid ext (PR #105476)

2024-08-21 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/105476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [ValueTracking] use KnownBits to compute fpclass from bitcast (PR #97762)

2024-08-22 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: Reverse ping :) https://github.com/llvm/llvm-project/pull/97762 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-22 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/94352 >From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 4 Jun 2024 21:08:27 +0800 Subject: [PATCH 1/5] [RISCV] Add support for getHostCPUFeatures using hwprobe Co-a

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-22 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/94352 >From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 4 Jun 2024 21:08:27 +0800 Subject: [PATCH 1/6] [RISCV] Add support for getHostCPUFeatures using hwprobe Co-a

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-22 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: I have no idea about why it corrupts StringMap. Sad :( ![image](https://github.com/llvm/llvm-project/assets/15650457/fd427068-6ca0-4ecb-a340-48c51e5629a6) https://github.com/llvm/llvm-project/pull/94352 ___ cfe-commits mailing list cfe

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-23 Thread Yingwei Zheng via cfe-commits
@@ -1571,7 +1571,9 @@ StringRef sys::getHostCPUName() { #if defined(__linux__) std::unique_ptr P = getProcCpuinfoContent(); StringRef Content = P ? P->getBuffer() : ""; - return detail::getHostCPUNameForRISCV(Content); + StringRef Name = detail::getHostCPUNameForRISCV(Con

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-23 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/94352 >From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 4 Jun 2024 21:08:27 +0800 Subject: [PATCH 1/7] [RISCV] Add support for getHostCPUFeatures using hwprobe Co-a

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/94352 >From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 4 Jun 2024 21:08:27 +0800 Subject: [PATCH 1/8] [RISCV] Add support for getHostCPUFeatures using hwprobe Co-a

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/94352 >From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 4 Jun 2024 21:08:27 +0800 Subject: [PATCH 1/9] [RISCV] Add support for getHostCPUFeatures using hwprobe Co-a

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > > I have no idea about why it corrupts StringMap. Sad :( > > ![image](https://private-user-images.githubusercontent.com/15650457/341986439-fd427068-6ca0-4ecb-a340-48c51e5629a6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb25

[clang] [llvm] [RISCV] Remove experimental from Ztso. (PR #96465)

2024-06-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw created https://github.com/llvm/llvm-project/pull/96465 Ztso 1.0 was ratified in January 2023. Documentation: https://github.com/riscv/riscv-isa-manual/blob/main/src/ztso-st-ext.adoc >From 34670ab55ccecb1a2c7d92f809c9cae0df4150c6 Mon Sep 17 00:00:00 2001 From: Yingw

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: See https://github.com/llvm/llvm-project/pull/96465 https://github.com/llvm/llvm-project/pull/94352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Remove experimental from Ztso. (PR #96465)

2024-06-24 Thread Yingwei Zheng via cfe-commits
@@ -365,24 +365,30 @@ // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZFHMIN %s // RV32-ZFHMIN: "-target-feature" "+zfhmin" -// RUN: not %clang --target=riscv32-unknown-elf -march=rv32iztso -### %s \ +// RUN: not %clang --target=riscv32-unknown-elf -march=rv32izalasr

[clang] [llvm] [RISCV] Remove experimental from Ztso. (PR #96465)

2024-06-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw closed https://github.com/llvm/llvm-project/pull/96465 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/94352 >From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 4 Jun 2024 21:08:27 +0800 Subject: [PATCH 01/10] [RISCV] Add support for getHostCPUFeatures using hwprobe C

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/94352 >From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 4 Jun 2024 21:08:27 +0800 Subject: [PATCH 01/11] [RISCV] Add support for getHostCPUFeatures using hwprobe C

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
@@ -2002,6 +2003,76 @@ bool sys::getHostCPUFeatures(StringMap &Features) { return true; } +#elif defined(__linux__) && defined(__riscv) +// struct riscv_hwprobe +struct RISCVHwProbe { + int64_t Key; + uint64_t Value; +}; +bool sys::getHostCPUFeatures(StringMap &Features) {

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw edited https://github.com/llvm/llvm-project/pull/94352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
@@ -2002,6 +2003,76 @@ bool sys::getHostCPUFeatures(StringMap &Features) { return true; } +#elif defined(__linux__) && defined(__riscv) +// struct riscv_hwprobe +struct RISCVHwProbe { + int64_t Key; + uint64_t Value; +}; +bool sys::getHostCPUFeatures(StringMap &Features) {

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits
@@ -2002,6 +2003,76 @@ bool sys::getHostCPUFeatures(StringMap &Features) { return true; } +#elif defined(__linux__) && defined(__riscv) +// struct riscv_hwprobe +struct RISCVHwProbe { + int64_t Key; + uint64_t Value; +}; +bool sys::getHostCPUFeatures(StringMap &Features) {

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-26 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: Any thoughts? Hopefully I can catch up with the 19 release :) https://github.com/llvm/llvm-project/pull/94352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-27 Thread Yingwei Zheng via cfe-commits
@@ -2002,6 +2003,76 @@ bool sys::getHostCPUFeatures(StringMap &Features) { return true; } +#elif defined(__linux__) && defined(__riscv) +// struct riscv_hwprobe +struct RISCVHwProbe { + int64_t Key; + uint64_t Value; +}; +bool sys::getHostCPUFeatures(StringMap &Features) {

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-27 Thread Yingwei Zheng via cfe-commits
@@ -83,8 +83,14 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, // and other features (ex. mirco architecture feature) from mcpu if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) { StringRef CPU = A->getValue(); -if (CPU == "nat

[clang] [llvm] [Pipelines] Move IPSCCP after inliner pipeline (PR #96620)

2024-06-27 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > This patch causes some significant performance regressions on llvm-test-suite > (rv64gc-O3-thinlto): > > Name Before After Ratio > SingleSource/Benchmarks/Shootout/Shootout-random 2.150161677 > 3.300161641 + 53.5% > SingleSource/Benchmarks/Polybench/linear-alg

[clang] [llvm] [Pipelines] Move IPSCCP after inliner pipeline (PR #96620)

2024-06-27 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > Does that mean it has a negative net effect, or its neutral It is neutral. > (in which case the original motivating case should be enough). But this patch may have an impact on compile time. https://github.com/llvm/llvm-project/pull/96620 ___

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-27 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/94352 >From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 4 Jun 2024 21:08:27 +0800 Subject: [PATCH 01/12] [RISCV] Add support for getHostCPUFeatures using hwprobe C

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-27 Thread Yingwei Zheng via cfe-commits
@@ -83,8 +83,14 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, // and other features (ex. mirco architecture feature) from mcpu if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) { StringRef CPU = A->getValue(); -if (CPU == "nat

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-27 Thread Yingwei Zheng via cfe-commits
@@ -83,8 +83,14 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, // and other features (ex. mirco architecture feature) from mcpu if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) { StringRef CPU = A->getValue(); -if (CPU == "nat

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-27 Thread Yingwei Zheng via cfe-commits
@@ -290,8 +290,24 @@ StringRef riscv::getRISCVArch(const llvm::opt::ArgList &Args, // 2. Get march (isa string) based on `-mcpu=` if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) { StringRef CPU = A->getValue(); -if (CPU == "native") +if (CPU == "nativ

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-27 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/94352 >From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 4 Jun 2024 21:08:27 +0800 Subject: [PATCH 01/13] [RISCV] Add support for getHostCPUFeatures using hwprobe C

[clang] [llvm] [RISCV] Add Syntacore SCR7 processor definition (PR #108406)

2024-09-12 Thread Yingwei Zheng via cfe-commits
@@ -502,3 +502,28 @@ // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr5-rv64 | FileCheck -check-prefix=MTUNE-SYNTACORE-SCR5-RV64 %s // MTUNE-SYNTACORE-SCR5-RV64: "-tune-cpu" "syntacore-scr5-rv64" + +// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=synt

[clang] [llvm] [RISCV] Add Syntacore SCR7 processor definition (PR #108406)

2024-09-13 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LG https://github.com/llvm/llvm-project/pull/108406 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [polly] [NFC] Rename `Intrinsic::getDeclaration` to `getOrInsertDeclaration` (PR #111752)

2024-10-12 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > TBH I am wondering if we should revert this rename. I don't think it's a good > idea to reuse getDeclaration with substantially different semantics, and if > we're not reusing it, then there's not much point to rename... > > Instead of having getOrInsertDeclaration + getDeclar

[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-10-10 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > Failed Tests (2): Clang :: Driver/print-supported-extensions-riscv.c Clang :: Preprocessor/riscv-target-features.c https://github.com/llvm/llvm-project/pull/111837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-10-10 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > > > > Personally I don't like to add a privileged extension if it doesn't > > > > introduce new CSRs/instructions. > > > > > > > > > I'd actually put that on the > > > [agenda](https://docs.google.com/document/d/1G3ocHm2zE6AYTS2N3_3w2UxFnSEyKkcF57siLWe-NVs/edit?tab=t.0) > > >

[clang] [llvm] [InstCombine] Infer nusw + nneg -> nuw for getelementptr (PR #111144)

2024-10-05 Thread Yingwei Zheng via cfe-commits
@@ -3096,6 +3096,15 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) { } } + // nusw + nneg -> nuw + if (GEP.hasNoUnsignedSignedWrap() && !GEP.hasNoUnsignedWrap() && + all_of(GEP.indices(), [&](Value *Idx) { +return isKnown

[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-10-10 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw commented: Personally I don't like to add a privileged extension if it doesn't introduce new CSRs/instructions. https://github.com/llvm/llvm-project/pull/111837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:

[clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-14 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw commented: Middle-end/CodeGen/RISC-V changes LGTM. https://github.com/llvm/llvm-project/pull/80309 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-14 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: `APInt::getAllOnes` will assert if `BitWidth == 0`. ``` [--] 6 tests from APFloatTest [ RUN ] APFloatTest.MinimumNumber [ OK ] APFloatTest.MinimumNumber (0 ms) [ RUN ] APFloatTest.Float8E8M0FNUValues ADTTests: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm

[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-10-25 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: @T-Tie Can you fill in the PR description? Then I will merge this patch :) https://github.com/llvm/llvm-project/pull/111837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[clang] [clang][RISCV] Support `norelax` attribute for RISCV (PR #115981)

2024-11-12 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: cc @cyyself https://github.com/llvm/llvm-project/pull/115981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-09-18 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw requested changes to this pull request. Reproducer: ``` ; bin/opt -passes=inline reduced.ll -S target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" define i64 @caller(ptr %p1,

[clang] [lldb] [llvm] [mlir] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-09-22 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: https://github.com/llvm/llvm-project/blob/62f737f7409b5d2b33c746158c62f14e5bb78aed/llvm/lib/Transforms/Utils/SimplifyCFG.cpp#L6516 We should allow truncations here. ``` ; bin/opt -passes='simplifycfg' reduced.ll -S target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:6

[clang] [RISCV] Implement validateGlobalRegisterVariable. (PR #109596)

2024-09-22 Thread Yingwei Zheng via cfe-commits
@@ -486,3 +486,15 @@ bool RISCVTargetInfo::validateCpuSupports(StringRef Feature) const { bool RISCVTargetInfo::isValidFeatureName(StringRef Name) const { return llvm::RISCVISAInfo::isSupportedExtensionFeature(Name); } + +bool RISCVTargetInfo::validateGlobalRegisterVariable(

[clang] [RISCV] Implement validateGlobalRegisterVariable. (PR #109596)

2024-09-22 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw edited https://github.com/llvm/llvm-project/pull/109596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [RISCV] Implement validateGlobalRegisterVariable. (PR #109596)

2024-09-22 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/109596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [Loads] Check context instruction for context-sensitive derefability (PR #109277)

2024-09-20 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. Nice catch! https://github.com/llvm/llvm-project/pull/109277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] [UBSan] Diagnose assumption violation (PR #104741)

2024-09-25 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > -fsanitize=address,fuzzer I think it is not related to this patch. It only works with `-fsanitize=builtin` or `-fsanitize=undefined`. https://github.com/llvm/llvm-project/pull/104741 ___ cfe-commits mailing list cfe-commits@lists.ll

[clang] [compiler-rt] [Clang][compiler-rt][UBSan] Improve `__ubsan_handle_invalid_builtin` (PR #109088)

2024-09-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw closed https://github.com/llvm/llvm-project/pull/109088 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] [UBSan] Diagnose assumption violation (PR #104741)

2024-09-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw closed https://github.com/llvm/llvm-project/pull/104741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] [UBSan] Diagnose assumption violation (PR #104741)

2024-09-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/104741 >From fdadb0fdc2288b18d4dfe4f4510d057a7552ee39 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Mon, 19 Aug 2024 15:22:39 +0800 Subject: [PATCH 1/3] [UBSan] Diagnose assumption violation --- clang/lib/CodeGe

[clang] [llvm] [CVP] Infer range return attribute (PR #99620)

2024-09-20 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM. Thank you! https://github.com/llvm/llvm-project/pull/99620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [CVP] Infer range return attribute (PR #99620)

2024-09-19 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: Missing fold: https://alive2.llvm.org/ce/z/2rmc3h See https://github.com/dtcxzyw/llvm-opt-benchmark/pull/1342#discussion_r1767033125 https://github.com/llvm/llvm-project/pull/99620 ___ cfe-commits mailing list cfe-commits@lists.llvm.or

[clang] [compiler-rt] [UBSan] Diagnose assumption violation (PR #104741)

2024-09-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/104741 >From fdadb0fdc2288b18d4dfe4f4510d057a7552ee39 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Mon, 19 Aug 2024 15:22:39 +0800 Subject: [PATCH 1/4] [UBSan] Diagnose assumption violation --- clang/lib/CodeGe

[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-11-07 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw closed https://github.com/llvm/llvm-project/pull/111837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [InstCombine] Fold `X Pred C2 ? X BOp C1 : C2 BOp C1` to `min/max(X, C2) BOp C1` (PR #116888)

2024-11-29 Thread Yingwei Zheng via cfe-commits
@@ -1898,6 +1882,56 @@ static Instruction *foldSelectICmpEq(SelectInst &SI, ICmpInst *ICI, return nullptr; } +/// Fold `X Pred C2 ? X BOp C1 : C2 BOp C1` to `min/max(X, C2) BOp C1`. +/// This allows for better canonicalization. +static Value *foldSelectWithConstOpToBinOp(IC

[clang] [llvm] [InstCombine] Fold `X Pred C2 ? X BOp C1 : C2 BOp C1` to `min/max(X, C2) BOp C1` (PR #116888)

2024-11-28 Thread Yingwei Zheng via cfe-commits
@@ -1898,6 +1882,56 @@ static Instruction *foldSelectICmpEq(SelectInst &SI, ICmpInst *ICI, return nullptr; } +/// Fold `X Pred C2 ? X BOp C1 : C2 BOp C1` to `min/max(X, C2) BOp C1`. +/// This allows for better canonicalization. +static Value *foldSelectWithConstOpToBinOp(IC

[clang] [llvm] [LoongArch] Support LA V1.1 feature ld-seq-sa that don't generate dbar 0x700. (PR #116762)

2024-11-23 Thread Yingwei Zheng via cfe-commits
@@ -2011,8 +2011,9 @@ const StringMap sys::getHostCPUFeatures() { const StringMap sys::getHostCPUFeatures() { unsigned long hwcap = getauxval(AT_HWCAP); bool HasFPU = hwcap & (1UL << 3); // HWCAP_LOONGARCH_FPU - uint32_t cpucfg2 = 0x2; + const uint32_t cpucfg2 = 0x2, cpuc

[clang] [compiler-rt] [Clang][compiler-rt][UBSan] Remove `BuiltinCheckKind` (PR #109088)

2024-09-17 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw created https://github.com/llvm/llvm-project/pull/109088 This patch removes unneeded enum `BuiltinCheckKind` and fixes a copy-paste mistake in `__ubsan_handle_invalid_builtin`. Address comment https://github.com/llvm/llvm-project/pull/104741#discussion_r1764323722.

[clang] [llvm] [IR] Allow fast math flags on fptrunc and fpext (PR #115894)

2024-11-13 Thread Yingwei Zheng via cfe-commits
@@ -1875,13 +1873,17 @@ Instruction *InstCombinerImpl::visitFPTrunc(FPTruncInst &FPT) { // fptrunc (select Cond, (fpext X), Y --> select Cond, X, (fptrunc Y) Value *NarrowY = Builder.CreateFPTrunc(Y, Ty); Value *Sel = Builder.CreateSelect(Cond, X, NarrowY, "n

[clang] [llvm] [IR] Allow fast math flags on fptrunc and fpext (PR #115894)

2024-11-14 Thread Yingwei Zheng via cfe-commits
@@ -1875,13 +1873,17 @@ Instruction *InstCombinerImpl::visitFPTrunc(FPTruncInst &FPT) { // fptrunc (select Cond, (fpext X), Y --> select Cond, X, (fptrunc Y) Value *NarrowY = Builder.CreateFPTrunc(Y, Ty); Value *Sel = Builder.CreateSelect(Cond, X, NarrowY, "n

[clang] [llvm] [InstCombine] Fold `X > C2 ? X + C1 : C2 + C1` to `max(X, C2) + C1` (PR #116888)

2024-11-25 Thread Yingwei Zheng via cfe-commits
@@ -1898,6 +1882,55 @@ static Instruction *foldSelectICmpEq(SelectInst &SI, ICmpInst *ICI, return nullptr; } +// Turn select (Cmp X C1) (BOp X C2) C3 +// -> BOp (min/max X C1) C2 +// iff C3 == BOp C1 C2 +// Fold `select` with a const operand to a binary operation. +// Thi

[clang] [llvm] [InstCombine] Fold `X > C2 ? X + C1 : C2 + C1` to `max(X, C2) + C1` (PR #116888)

2024-11-25 Thread Yingwei Zheng via cfe-commits
@@ -1182,6 +1182,10 @@ SelectPatternResult matchDecomposedSelectPattern( /// minimum/maximum flavor. CmpInst::Predicate getMinMaxPred(SelectPatternFlavor SPF, bool Ordered = false); +/// Convert given `SPF` to equivalent min/max intrinsic. +/// Caller must ensure `SPF` is a m

[clang] [llvm] [InstCombine] Fold `X > C2 ? X + C1 : C2 + C1` to `max(X, C2) + C1` (PR #116888)

2024-11-25 Thread Yingwei Zheng via cfe-commits
@@ -1793,10 +1793,9 @@ define i32 @not_uadd_sat(i32 %x, i32 %y) { define i32 @not_uadd_sat2(i32 %x, i32 %y) { ; CHECK-LABEL: @not_uadd_sat2( -; CHECK-NEXT:[[A:%.*]] = add i32 [[X:%.*]], -2 -; CHECK-NEXT:[[C:%.*]] = icmp ugt i32 [[X]], 1 -; CHECK-NEXT:[[R:%.*]] = se

[clang] [llvm] [InstCombine] Fold `X Pred C2 ? X BOp C1 : C2 BOp C1` to `min/max(X, C2) BOp C1` (PR #116888)

2024-11-25 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw edited https://github.com/llvm/llvm-project/pull/116888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [InstCombine] Fold `X > C2 ? X + C1 : C2 + C1` to `max(X, C2) + C1` (PR #116888)

2024-11-25 Thread Yingwei Zheng via cfe-commits
@@ -1898,6 +1882,55 @@ static Instruction *foldSelectICmpEq(SelectInst &SI, ICmpInst *ICI, return nullptr; } +// Turn select (Cmp X C1) (BOp X C2) C3 dtcxzyw wrote: ```suggestion /// Turn select (Cmp X C1) (BOp X C2) C3 ``` Use `///` for header comments.

[clang] [llvm] [InstCombine] Fold `X Pred C2 ? X BOp C1 : C2 BOp C1` to `min/max(X, C2) BOp C1` (PR #116888)

2024-11-29 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM. Thank you! Please wait for additional approval from other reviewers :) https://github.com/llvm/llvm-project/pull/116888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[clang] [llvm] [ConstantFolding] Infer getelementptr nuw flag (PR #119214)

2024-12-09 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/119214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separators

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separators

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separators

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw edited https://github.com/llvm/llvm-project/pull/120352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM. Thank you! Please update the PR description and wait for additional approval from other reviewers. https://github.com/llvm/llvm-project/pull/120352 ___ cfe-commits mailing list cfe-commits@

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-24 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,72 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separators

[clang] [llvm] [RISCV] Add a generic OOO CPU (PR #120712)

2025-02-06 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw edited https://github.com/llvm/llvm-project/pull/120712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [RISCV] Add a generic OOO CPU (PR #120712)

2025-02-06 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM. Thank you! Please wait for additional approval from other reviewers :) https://github.com/llvm/llvm-project/pull/120712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[clang] [llvm] [RISCV] Add a generic OOO CPU (PR #120712)

2025-02-06 Thread Yingwei Zheng via cfe-commits
@@ -0,0 +1,500 @@ +//===-- RISCVSchedGenericOOO.td - Generic O3 Processor -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] [RISCV] Add a generic OOO CPU (PR #120712)

2025-02-06 Thread Yingwei Zheng via cfe-commits
@@ -0,0 +1,500 @@ +//===-- RISCVSchedGenericOOO.td - Generic O3 Processor -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] [ValueTracking] Handle flipped strictness cases in `matchSelectPattern` (PR #121958)

2025-02-01 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/121958 >From c67349c8d79333d574a753d7afb10489cafb008d Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Tue, 7 Jan 2025 23:48:53 +0800 Subject: [PATCH 1/4] [InstCombine] Add pre-commit tests. NFC. --- llvm/test/Tran

[clang] [llvm] [InstCombine] Infer nuw for gep inbounds from base of object (PR #119225)

2024-12-09 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/119225 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [InstCombine] Infer nuw for gep inbounds from base of object (PR #119225)

2024-12-12 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > Seems that this change causes Segment Fault on multiple targets including > aarch64, loongarch64 and riscv64. > > This is detected by a LoongArch > [buildbot](https://lab.llvm.org/staging/#/builders/20/builds/6282) and > manually checked on aarch64 and riscv64 QEMUs. > > I w

[clang] [llvm] [InstCombine] Infer nuw for gep inbounds from base of object (PR #119225)

2024-12-12 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > huffbench.c:319:10: runtime error: left shift of negative value -93 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior huffbench.c:319:10 https://github.com/llvm/llvm-project/pull/119225 ___ cfe-commits mailing list cfe-commits@l

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-18 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw edited https://github.com/llvm/llvm-project/pull/120352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-18 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,102 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separator

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-18 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,102 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separator

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-18 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,102 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separator

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-18 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw commented: Please give me more time to understand the implementation... https://github.com/llvm/llvm-project/pull/120352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-18 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,102 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separator

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-18 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,102 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separator

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-19 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > I'd have expected the simplest case to be solved suboptimally with a few > range intersections in ValueTracking, but this seems like a nice extension, > if that's the appropriate direction and compile-time acceptable. This patch increases the compile time by ~0.02%. It should

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-20 Thread Yingwei Zheng via cfe-commits
@@ -1520,15 +1520,101 @@ ConstantRange ConstantRange::binaryNot() const { return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this); } +/// Estimate the 'bit-masked AND' operation's lower bound. +/// +/// E.g., given two ranges as follows (single quotes are separator

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-23 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: > I'm thinking if I need to add a new test mode to test the optimal lower > (upper) bound only for AND (OR). If you cannot make it optimal for all non-wrapped cases, please just add some special cases (e.g., `[7, 14) & [-1, 0) = [7, 14)`) before `TestBinaryOpExhaustive`. htt

<    1   2   3   4   5   6   7   >