[llvm-branch-commits] [llvm] adf3135 - Revert "[InstCombine] Fold `icmp pred (inttoptr X), (inttoptr Y) -> icmp pred X, Y`"
Author: Vitaly Buka Date: 2024-01-13T00:46:37-08:00 New Revision: adf313575882898bc2cda09f891b80aa1a2786f2 URL: https://github.com/llvm/llvm-project/commit/adf313575882898bc2cda09f891b80aa1a2786f2 DIFF: https://github.com/llvm/llvm-project/commit/adf313575882898bc2cda09f891b80aa1a2786f2.diff LOG: Revert "[InstCombine] Fold `icmp pred (inttoptr X), (inttoptr Y) -> icmp pred X, Y`" Added: Modified: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/test/Transforms/InstCombine/cast_ptr.ll Removed: diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index da94bb1d2a8f36..7c1aff445524de 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -5703,15 +5703,6 @@ Instruction *InstCombinerImpl::foldICmpWithCastOp(ICmpInst &ICmp) { return new ICmpInst(ICmp.getPredicate(), Op0Src, NewOp1); } - // Turn icmp pred (inttoptr x), (inttoptr y) into icmp pred x, y - if (CastOp0->getOpcode() == Instruction::IntToPtr && - CompatibleSizes(DestTy, SrcTy)) { -Value *Op1Src; -if (match(ICmp.getOperand(1), m_IntToPtr(m_Value(Op1Src))) && -Op1Src->getType() == SrcTy) - return new ICmpInst(ICmp.getPredicate(), Op0Src, Op1Src); - } - if (Instruction *R = foldICmpWithTrunc(ICmp)) return R; diff --git a/llvm/test/Transforms/InstCombine/cast_ptr.ll b/llvm/test/Transforms/InstCombine/cast_ptr.ll index 8865af0a34a401..5c6c012064e05b 100644 --- a/llvm/test/Transforms/InstCombine/cast_ptr.ll +++ b/llvm/test/Transforms/InstCombine/cast_ptr.ll @@ -113,51 +113,6 @@ define i1 @test4(i32 %A) { ret i1 %C } -define i1 @test4_icmp_with_var(i32 %A1, i32 %A2) { -; CHECK-LABEL: @test4_icmp_with_var( -; CHECK-NEXT:[[C:%.*]] = icmp ugt i32 [[A1:%.*]], [[A2:%.*]] -; CHECK-NEXT:ret i1 [[C]] -; - %B1 = inttoptr i32 %A1 to ptr - %B2 = inttoptr i32 %A2 to ptr - %C = icmp ugt ptr %B1, %B2 - ret i1 %C -} - -define i1 @test4_cmp_with_nonnull_constant(i32 %A) { -; CHECK-LABEL: @test4_cmp_with_nonnull_constant( -; CHECK-NEXT:[[C:%.*]] = icmp eq i32 [[A:%.*]], 1 -; CHECK-NEXT:ret i1 [[C]] -; - %B = inttoptr i32 %A to ptr - %C = icmp eq ptr %B, inttoptr (i32 1 to ptr) - ret i1 %C -} - -define i1 @test4_cmp_eq_0_or_1(i32 %x) { -; CHECK-LABEL: @test4_cmp_eq_0_or_1( -; CHECK-NEXT:[[OR:%.*]] = icmp ult i32 [[X:%.*]], 2 -; CHECK-NEXT:ret i1 [[OR]] -; - %cast = inttoptr i32 %x to ptr - %tobool = icmp eq i32 %x, 0 - %cmp = icmp eq ptr %cast, inttoptr (i32 1 to ptr) - %or = or i1 %tobool, %cmp - ret i1 %or -} - -define i1 @test4_icmp_with_var_mismatched_type(i32 %A1, i64 %A2) { -; CHECK-LABEL: @test4_icmp_with_var_mismatched_type( -; CHECK-NEXT:[[TMP1:%.*]] = trunc i64 [[A2:%.*]] to i32 -; CHECK-NEXT:[[C:%.*]] = icmp ult i32 [[TMP1]], [[A1:%.*]] -; CHECK-NEXT:ret i1 [[C]] -; - %B1 = inttoptr i32 %A1 to ptr - %B2 = inttoptr i64 %A2 to ptr - %C = icmp ugt ptr %B1, %B2 - ret i1 %C -} - define i1 @test4_as2(i16 %A) { ; CHECK-LABEL: @test4_as2( ; CHECK-NEXT:[[C:%.*]] = icmp eq i16 [[A:%.*]], 0 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] [libcxxabi] [lldb] [libcxx] [libc] [llvm] [flang] [clang-tools-extra] [clang] [compiler-rt] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/77759 >From 67ea0e5df3c4919030c963c969d8f9cda0b5996b Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 9 Jan 2024 12:25:10 -0600 Subject: [PATCH] [Flang][OpenMP] Handle SECTION construct from within SECTIONS Introduce `createSectionOp`, invoke it from the SECTIONS construct for each nested SECTION construct. This makes it unnecessary to embed OpenMPSectionConstruct inside of OpenMPSectionConstruct anymore. Recursive lowering [3/5] --- flang/lib/Lower/OpenMP.cpp | 57 +- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index 496b4ba27a0533..aa315d7ab280e2 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -2379,6 +2379,18 @@ genParallelOp(Fortran::lower::AbstractConverter &converter, procBindKindAttr); } +static mlir::omp::SectionOp +genSectionOp(Fortran::lower::AbstractConverter &converter, + Fortran::lower::pft::Evaluation &eval, + mlir::Location currentLocation, + const Fortran::parser::OmpClauseList §ionsClauseList) { + // Currently only private/firstprivate clause is handled, and + // all privatization is done within `omp.section` operations. + return genOpWithBody(converter, eval, currentLocation, + /*outerCombined=*/false, + §ionsClauseList); +} + static mlir::omp::SingleOp genSingleOp(Fortran::lower::AbstractConverter &converter, Fortran::lower::pft::Evaluation &eval, @@ -3375,35 +3387,6 @@ genOMP(Fortran::lower::AbstractConverter &converter, genNestedEvaluations(converter, eval); } -static void -genOMP(Fortran::lower::AbstractConverter &converter, - Fortran::lower::SymMap &symTable, Fortran::lower::pft::Evaluation &eval, - const Fortran::parser::OpenMPSectionConstruct §ionConstruct) { - mlir::Location currentLocation = converter.getCurrentLocation(); - const Fortran::parser::OpenMPConstruct *parentOmpConstruct = - eval.parentConstruct->getIf(); - assert(parentOmpConstruct && - "No enclosing parent OpenMPConstruct on SECTION construct"); - const Fortran::parser::OpenMPSectionsConstruct *sectionsConstruct = - std::get_if( - &parentOmpConstruct->u); - assert(sectionsConstruct && "SECTION construct must have parent" - "SECTIONS construct"); - const Fortran::parser::OmpClauseList §ionsClauseList = - std::get( - std::get( - sectionsConstruct->t) - .t); - // Currently only private/firstprivate clause is handled, and - // all privatization is done within `omp.section` operations. - symTable.pushScope(); - genOpWithBody(converter, eval, currentLocation, - /*outerCombined=*/false, - §ionsClauseList); - genNestedEvaluations(converter, eval); - symTable.popScope(); -} - static void genOMP(Fortran::lower::AbstractConverter &converter, Fortran::lower::SymMap &symTable, Fortran::lower::pft::Evaluation &eval, @@ -3447,7 +3430,18 @@ genOMP(Fortran::lower::AbstractConverter &converter, /*reductions=*/nullptr, allocateOperands, allocatorOperands, nowaitClauseOperand); - genNestedEvaluations(converter, eval); + const auto §ionBlocks = + std::get(sectionsConstruct.t); + auto &firOpBuilder = converter.getFirOpBuilder(); + auto ip = firOpBuilder.saveInsertionPoint(); + for (const auto &[nblock, neval] : + llvm::zip(sectionBlocks.v, eval.getNestedEvaluations())) { +symTable.pushScope(); +genSectionOp(converter, neval, currentLocation, sectionsClauseList); +genNestedEvaluations(converter, neval); +symTable.popScope(); +firOpBuilder.restoreInsertionPoint(ip); + } } static void @@ -3562,7 +3556,8 @@ static void genOMP(Fortran::lower::AbstractConverter &converter, genOMP(converter, symTable, eval, sectionsConstruct); }, [&](const Fortran::parser::OpenMPSectionConstruct §ionConstruct) { -genOMP(converter, symTable, eval, sectionConstruct); +// SECTION constructs are handled as a part of SECTIONS. +llvm_unreachable("Unexpected standalone OMP SECTION"); }, [&](const Fortran::parser::OpenMPLoopConstruct &loopConstruct) { genOMP(converter, symTable, eval, semanticsContext, loopConstruct); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [llvm] [compiler-rt] [libc] [lldb] [clang-tools-extra] [libcxxabi] [clang] [lld] [flang] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/77759 >From 67ea0e5df3c4919030c963c969d8f9cda0b5996b Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 9 Jan 2024 12:25:10 -0600 Subject: [PATCH 1/2] [Flang][OpenMP] Handle SECTION construct from within SECTIONS Introduce `createSectionOp`, invoke it from the SECTIONS construct for each nested SECTION construct. This makes it unnecessary to embed OpenMPSectionConstruct inside of OpenMPSectionConstruct anymore. Recursive lowering [3/5] --- flang/lib/Lower/OpenMP.cpp | 57 +- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index 496b4ba27a0533..aa315d7ab280e2 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -2379,6 +2379,18 @@ genParallelOp(Fortran::lower::AbstractConverter &converter, procBindKindAttr); } +static mlir::omp::SectionOp +genSectionOp(Fortran::lower::AbstractConverter &converter, + Fortran::lower::pft::Evaluation &eval, + mlir::Location currentLocation, + const Fortran::parser::OmpClauseList §ionsClauseList) { + // Currently only private/firstprivate clause is handled, and + // all privatization is done within `omp.section` operations. + return genOpWithBody(converter, eval, currentLocation, + /*outerCombined=*/false, + §ionsClauseList); +} + static mlir::omp::SingleOp genSingleOp(Fortran::lower::AbstractConverter &converter, Fortran::lower::pft::Evaluation &eval, @@ -3375,35 +3387,6 @@ genOMP(Fortran::lower::AbstractConverter &converter, genNestedEvaluations(converter, eval); } -static void -genOMP(Fortran::lower::AbstractConverter &converter, - Fortran::lower::SymMap &symTable, Fortran::lower::pft::Evaluation &eval, - const Fortran::parser::OpenMPSectionConstruct §ionConstruct) { - mlir::Location currentLocation = converter.getCurrentLocation(); - const Fortran::parser::OpenMPConstruct *parentOmpConstruct = - eval.parentConstruct->getIf(); - assert(parentOmpConstruct && - "No enclosing parent OpenMPConstruct on SECTION construct"); - const Fortran::parser::OpenMPSectionsConstruct *sectionsConstruct = - std::get_if( - &parentOmpConstruct->u); - assert(sectionsConstruct && "SECTION construct must have parent" - "SECTIONS construct"); - const Fortran::parser::OmpClauseList §ionsClauseList = - std::get( - std::get( - sectionsConstruct->t) - .t); - // Currently only private/firstprivate clause is handled, and - // all privatization is done within `omp.section` operations. - symTable.pushScope(); - genOpWithBody(converter, eval, currentLocation, - /*outerCombined=*/false, - §ionsClauseList); - genNestedEvaluations(converter, eval); - symTable.popScope(); -} - static void genOMP(Fortran::lower::AbstractConverter &converter, Fortran::lower::SymMap &symTable, Fortran::lower::pft::Evaluation &eval, @@ -3447,7 +3430,18 @@ genOMP(Fortran::lower::AbstractConverter &converter, /*reductions=*/nullptr, allocateOperands, allocatorOperands, nowaitClauseOperand); - genNestedEvaluations(converter, eval); + const auto §ionBlocks = + std::get(sectionsConstruct.t); + auto &firOpBuilder = converter.getFirOpBuilder(); + auto ip = firOpBuilder.saveInsertionPoint(); + for (const auto &[nblock, neval] : + llvm::zip(sectionBlocks.v, eval.getNestedEvaluations())) { +symTable.pushScope(); +genSectionOp(converter, neval, currentLocation, sectionsClauseList); +genNestedEvaluations(converter, neval); +symTable.popScope(); +firOpBuilder.restoreInsertionPoint(ip); + } } static void @@ -3562,7 +3556,8 @@ static void genOMP(Fortran::lower::AbstractConverter &converter, genOMP(converter, symTable, eval, sectionsConstruct); }, [&](const Fortran::parser::OpenMPSectionConstruct §ionConstruct) { -genOMP(converter, symTable, eval, sectionConstruct); +// SECTION constructs are handled as a part of SECTIONS. +llvm_unreachable("Unexpected standalone OMP SECTION"); }, [&](const Fortran::parser::OpenMPLoopConstruct &loopConstruct) { genOMP(converter, symTable, eval, semanticsContext, loopConstruct); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)
https://github.com/koachan updated https://github.com/llvm/llvm-project/pull/77196 >From f4830825ebea96f71fb1b9d1f1192114291b093c Mon Sep 17 00:00:00 2001 From: Koakuma Date: Sun, 14 Jan 2024 10:35:24 +0700 Subject: [PATCH] Add nounwind to test cases Created using spr 1.3.4 --- llvm/test/CodeGen/SPARC/getpcx-call.ll | 14 +++--- llvm/test/CodeGen/SPARC/getpcx-rdpc.ll | 14 +++--- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/llvm/test/CodeGen/SPARC/getpcx-call.ll b/llvm/test/CodeGen/SPARC/getpcx-call.ll index 63d6649f89c4fa..0f162f1cd0bb7a 100644 --- a/llvm/test/CodeGen/SPARC/getpcx-call.ll +++ b/llvm/test/CodeGen/SPARC/getpcx-call.ll @@ -10,14 +10,10 @@ @value = external global i32 -define i32 @testCall() #0 { +define i32 @testCall() nounwind #0 { ; SPARC-LABEL: testCall: -; SPARC: .cfi_startproc -; SPARC-NEXT: ! %bb.0: +; SPARC: ! %bb.0: ; SPARC-NEXT:save %sp, -96, %sp -; SPARC-NEXT:.cfi_def_cfa_register %fp -; SPARC-NEXT:.cfi_window_save -; SPARC-NEXT:.cfi_register %o7, %i7 ; SPARC-NEXT: .Ltmp0: ; SPARC-NEXT:call .Ltmp1 ; SPARC-NEXT: .Ltmp2: @@ -33,12 +29,8 @@ define i32 @testCall() #0 { ; SPARC-NEXT:restore ; ; SPARC64-LABEL: testCall: -; SPARC64: .cfi_startproc -; SPARC64-NEXT: ! %bb.0: +; SPARC64: ! %bb.0: ; SPARC64-NEXT:save %sp, -128, %sp -; SPARC64-NEXT:.cfi_def_cfa_register %fp -; SPARC64-NEXT:.cfi_window_save -; SPARC64-NEXT:.cfi_register %o7, %i7 ; SPARC64-NEXT: .Ltmp0: ; SPARC64-NEXT:call .Ltmp1 ; SPARC64-NEXT: .Ltmp2: diff --git a/llvm/test/CodeGen/SPARC/getpcx-rdpc.ll b/llvm/test/CodeGen/SPARC/getpcx-rdpc.ll index 4596d8d6824153..cb51502f7b0690 100644 --- a/llvm/test/CodeGen/SPARC/getpcx-rdpc.ll +++ b/llvm/test/CodeGen/SPARC/getpcx-rdpc.ll @@ -10,14 +10,10 @@ @value = external global i32 -define i32 @testRdpc() #0 { +define i32 @testRdpc() nounwind #0 { ; SPARC-LABEL: testRdpc: -; SPARC: .cfi_startproc -; SPARC-NEXT: ! %bb.0: +; SPARC: ! %bb.0: ; SPARC-NEXT:save %sp, -96, %sp -; SPARC-NEXT:.cfi_def_cfa_register %fp -; SPARC-NEXT:.cfi_window_save -; SPARC-NEXT:.cfi_register %o7, %i7 ; SPARC-NEXT: .Ltmp0: ; SPARC-NEXT:call .Ltmp1 ; SPARC-NEXT: .Ltmp2: @@ -33,12 +29,8 @@ define i32 @testRdpc() #0 { ; SPARC-NEXT:restore ; ; SPARC64-LABEL: testRdpc: -; SPARC64: .cfi_startproc -; SPARC64-NEXT: ! %bb.0: +; SPARC64: ! %bb.0: ; SPARC64-NEXT:save %sp, -128, %sp -; SPARC64-NEXT:.cfi_def_cfa_register %fp -; SPARC64-NEXT:.cfi_window_save -; SPARC64-NEXT:.cfi_register %o7, %i7 ; SPARC64-NEXT: .Ltmp0: ; SPARC64-NEXT:rd %pc, %o7 ; SPARC64-NEXT: .Ltmp2: ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)
@@ -0,0 +1,51 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -relocation-model=pic -mtriple=sparc | FileCheck --check-prefix=SPARC %s +; RUN: llc < %s -relocation-model=pic -mtriple=sparcv9 | FileCheck --check-prefix=SPARC64 %s + +;; SPARC32 and SPARC64 for classic UltraSPARCs implement GETPCX +;; with a fake `call`. +;; All other SPARC64 targets implement it with `rd %pc, %o7`. +;; Need to do the tests in separate files because apparently `tune-cpu` +;; attribute applies to the entire file at once. + +@value = external global i32 + +define i32 @testCall() nounwind #0 { +; SPARC-LABEL: testCall: +; SPARC: ! %bb.0: +; SPARC-NEXT:save %sp, -96, %sp +; SPARC-NEXT: .Ltmp0: +; SPARC-NEXT:call .Ltmp1 +; SPARC-NEXT: .Ltmp2: +; SPARC-NEXT:sethi %hi(_GLOBAL_OFFSET_TABLE_+(.Ltmp2-.Ltmp0)), %i0 +; SPARC-NEXT: .Ltmp1: +; SPARC-NEXT:or %i0, %lo(_GLOBAL_OFFSET_TABLE_+(.Ltmp1-.Ltmp0)), %i0 +; SPARC-NEXT:add %i0, %o7, %i0 +; SPARC-NEXT:sethi %hi(value), %i1 +; SPARC-NEXT:add %i1, %lo(value), %i1 +; SPARC-NEXT:ld [%i0+%i1], %i0 +; SPARC-NEXT:ld [%i0], %i0 +; SPARC-NEXT:ret +; SPARC-NEXT:restore +; +; SPARC64-LABEL: testCall: +; SPARC64: ! %bb.0: +; SPARC64-NEXT:save %sp, -128, %sp +; SPARC64-NEXT: .Ltmp0: +; SPARC64-NEXT:call .Ltmp1 +; SPARC64-NEXT: .Ltmp2: +; SPARC64-NEXT:sethi %hi(_GLOBAL_OFFSET_TABLE_+(.Ltmp2-.Ltmp0)), %i0 +; SPARC64-NEXT: .Ltmp1: +; SPARC64-NEXT:or %i0, %lo(_GLOBAL_OFFSET_TABLE_+(.Ltmp1-.Ltmp0)), %i0 +; SPARC64-NEXT:add %i0, %o7, %i0 +; SPARC64-NEXT:sethi %hi(value), %i1 +; SPARC64-NEXT:add %i1, %lo(value), %i1 +; SPARC64-NEXT:ldx [%i0+%i1], %i0 +; SPARC64-NEXT:ld [%i0], %i0 +; SPARC64-NEXT:ret +; SPARC64-NEXT:restore + %1 = load i32, i32* @value s-barannikov wrote: ```suggestion %1 = load i32, ptr @value ``` I thought it does not compile anymore :thinking: https://github.com/llvm/llvm-project/pull/77196 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)
https://github.com/s-barannikov approved this pull request. https://github.com/llvm/llvm-project/pull/77196 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits