[llvm] [clang] [InstCombine] Use zext's nneg flag for icmp folding (PR #70845)

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

[llvm] [clang] [InstCombine] Use zext's nneg flag for icmp folding (PR #70845)

2023-11-12 Thread Léonard Oest O'Leary via cfe-commits
leo-ard wrote: > Do you have the access to merge PR? No I don't. Thanks for the time and insightful comments ! https://github.com/llvm/llvm-project/pull/70845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Léonard Oest O'Leary via cfe-commits
@@ -0,0 +1,111 @@ +; RUN: opt < %s -O3 -S | FileCheck %s +; See issue #55013 and PR #70845 for more details. +; This test comes from the following C program, compiled with clang +; +;; short vecreduce_smin_v2i16(int n, short* v) +;; { +;; short p = 0; +;; for (int i = 0; i <

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Léonard Oest O'Leary via cfe-commits
https://github.com/leo-ard updated https://github.com/llvm/llvm-project/pull/70845 From 00d0c18b5414ffe7222e1ee0ad5ecfdb8783704e Mon Sep 17 00:00:00 2001 From: leo-ard Date: Mon, 30 Oct 2023 18:01:27 -0400 Subject: [PATCH 01/16] Add NonNeg check for InstCombine ---

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Yingwei Zheng via cfe-commits
@@ -0,0 +1,145 @@ +; RUN: opt < %s --O3 -S | FileCheck %s dtcxzyw wrote: My command: `bin/opt -S -O3 -print-changed min_max.ll` Then I got IR after the SROA pass :) https://github.com/llvm/llvm-project/pull/70845 ___

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw commented: LGTM https://github.com/llvm/llvm-project/pull/70845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Yingwei Zheng via cfe-commits
@@ -0,0 +1,111 @@ +; RUN: opt < %s -O3 -S | FileCheck %s +; See issue #55013 and PR #70845 for more details. +; This test comes from the following C program, compiled with clang +; +;; short vecreduce_smin_v2i16(int n, short* v) +;; { +;; short p = 0; +;; for (int i = 0; i <

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

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

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Yingwei Zheng via cfe-commits
@@ -0,0 +1,112 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 +; RUN: opt < %s -O3 -S | FileCheck %s +; See issue #55013 and PR #70845 for more details. +; This test comes from the following C program, compiled with clang +;

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,145 @@ +; RUN: opt < %s --O3 -S | FileCheck %s nikic wrote: You need to use `-O2 -Xclang -disable-llvm-optzns`, or manually drop the `optnone` attributes. https://github.com/llvm/llvm-project/pull/70845

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Léonard Oest O'Leary via cfe-commits
@@ -0,0 +1,145 @@ +; RUN: opt < %s --O3 -S | FileCheck %s leo-ard wrote: How did you get the SSA form ? I wasn't able to do it on my side. Here are the commands that I did : ```bash > build_release/bin/clang -S -emit-llvm min_max.c -fno-discard-value-names -o

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Léonard Oest O'Leary via cfe-commits
@@ -247,6 +355,19 @@ define i1 @sext_zext_uge_op0_wide(i16 %x, i8 %y) { ret i1 %c } + +define i1 @sext_zext_nneg_uge_op0_wide(i16 %x, i8 %y) { +; CHECK-LABEL: @sext_zext_nneg_uge_op0_wide( +; CHECK-NEXT:[[TMP1:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT:[[C:%.*]]

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Nikita Popov via cfe-commits
@@ -247,6 +355,19 @@ define i1 @sext_zext_uge_op0_wide(i16 %x, i8 %y) { ret i1 %c } + +define i1 @sext_zext_nneg_uge_op0_wide(i16 %x, i8 %y) { +; CHECK-LABEL: @sext_zext_nneg_uge_op0_wide( +; CHECK-NEXT:[[TMP1:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT:[[C:%.*]]

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Yingwei Zheng via cfe-commits
@@ -0,0 +1,145 @@ +; RUN: opt < %s --O3 -S | FileCheck %s dtcxzyw wrote: ``` define i16 @vecreduce_smin_v2i16(i32 %n, ptr %v) { entry: br label %for.cond for.cond: %p.0 = phi i16 [ 0, %entry ], [ %conv8, %for.inc ] %i.0 = phi i32 [ 0, %entry ], [ %inc,

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw requested changes to this pull request. https://github.com/llvm/llvm-project/pull/70845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Yingwei Zheng via cfe-commits
@@ -0,0 +1,145 @@ +; RUN: opt < %s --O3 -S | FileCheck %s dtcxzyw wrote: ```suggestion ; RUN: opt < %s -O3 -S | FileCheck %s ``` https://github.com/llvm/llvm-project/pull/70845 ___ cfe-commits mailing list

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-11 Thread Yingwei Zheng via cfe-commits
@@ -0,0 +1,145 @@ +; RUN: opt < %s --O3 -S | FileCheck %s dtcxzyw wrote: Could you please: 1. Convert this IR into SSA form as @nikic mentioned. 2. Drop unused attributes. 3. Re-generate tests with `llvm/utils/update_test_checks.py`.

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

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

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-10 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 3f906f513edea5c21867586d92151c4268230fe4 3f2ad99f9a6d177ea2747bfc0e559aad1faf8639 --

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-10 Thread Léonard Oest O'Leary via cfe-commits
@@ -0,0 +1,175 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 +; See PR-70845 for more details +; RUN: opt < %s -S -passes=instcombine | FileCheck %s + + +define signext i32 @sext_sext(i16 %x, i16 %y) {

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-10 Thread Léonard Oest O'Leary via cfe-commits
@@ -247,6 +355,19 @@ define i1 @sext_zext_uge_op0_wide(i16 %x, i8 %y) { ret i1 %c } + +define i1 @sext_zext_nneg_uge_op0_wide(i16 %x, i8 %y) { +; CHECK-LABEL: @sext_zext_nneg_uge_op0_wide( +; CHECK-NEXT:[[TMP1:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT:[[C:%.*]]

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-10 Thread Léonard Oest O'Leary via cfe-commits
@@ -0,0 +1,175 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 +; See PR-70845 for more details +; RUN: opt < %s -S -passes=instcombine | FileCheck %s + + +define signext i32 @sext_sext(i16 %x, i16 %y) { +; CHECK-LABEL: define

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-10 Thread Léonard Oest O'Leary via cfe-commits
https://github.com/leo-ard updated https://github.com/llvm/llvm-project/pull/70845 From 00d0c18b5414ffe7222e1ee0ad5ecfdb8783704e Mon Sep 17 00:00:00 2001 From: leo-ard Date: Mon, 30 Oct 2023 18:01:27 -0400 Subject: [PATCH 01/12] Add NonNeg check for InstCombine ---

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-08 Thread Yingwei Zheng via cfe-commits
@@ -0,0 +1,126 @@ +; RUN: opt < %s --O3 -S | FileCheck %s + +define signext i16 @vecreduce_smax_v2i16(i32 noundef %0, ptr noundef %1) #0 { dtcxzyw wrote: Could you please reduce the test case and move it into `InstCombine`?

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

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

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-08 Thread Yingwei Zheng via cfe-commits
@@ -5587,11 +5587,20 @@ Instruction *InstCombinerImpl::foldICmpWithZextOrSext(ICmpInst ) { return new ICmpInst(ICmp.getPredicate(), Builder.CreateOr(X, Y), Constant::getNullValue(X->getType())); + // Treat "zext nneg" as "sext" +

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-08 Thread Léonard Oest O'Leary via cfe-commits
leo-ard wrote: @nikic ping:) https://github.com/llvm/llvm-project/pull/70845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-01 Thread Léonard Oest O'Leary via cfe-commits
https://github.com/leo-ard updated https://github.com/llvm/llvm-project/pull/70845 From 6bb97fd48d59b7f79fdf90a2b27e9220f417fac7 Mon Sep 17 00:00:00 2001 From: leo-ard Date: Mon, 30 Oct 2023 18:01:27 -0400 Subject: [PATCH 1/9] Add NonNeg check for InstCombine ---

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-01 Thread Léonard Oest O'Leary via cfe-commits
leo-ard wrote: Thanks for taking the time to review the PR. I just added another test in PhaseOrdering to make sure that the min/max intrinsics are generated https://github.com/llvm/llvm-project/pull/70845 ___ cfe-commits mailing list

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-01 Thread Léonard Oest O'Leary via cfe-commits
@@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -O2 -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s leo-ard wrote: Out of curiosity, why is end-to-end codegen with clang not used ? Is it too unstable ? https://github.com/llvm/llvm-project/pull/70845

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-01 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,185 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --tool ./bin/opt --version 3 +; See PRXXX for more details +; RUN-./bin/opt: opt < %s -S -passes=ipsccp | FileCheck %s nikic wrote: This is an ipsccp test in

[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

2023-11-01 Thread Nikita Popov via cfe-commits
@@ -5587,11 +5587,17 @@ Instruction *InstCombinerImpl::foldICmpWithZextOrSext(ICmpInst ) { return new ICmpInst(ICmp.getPredicate(), Builder.CreateOr(X, Y), Constant::getNullValue(X->getType())); + // Treat "zext nneg" as "sext" +