Skip to content

[NewPM][Hexagon] Add HexagonPassRegistry.def #86244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions llvm/lib/Target/Hexagon/HexagonPassRegistry.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===- HexagonPassRegistry.def - Registry of Hexagon passes -----*- C++--*-===//
//
// 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: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is used as the registry of passes that are part of the
// Hexagon backend.
//
//===----------------------------------------------------------------------===//

// NOTE: NO INCLUDE GUARD DESIRED!

#ifndef LOOP_PASS
#define LOOP_PASS(NAME, CREATE_PASS)
#endif
LOOP_PASS("hexagon-loop-idiom", HexagonLoopIdiomRecognitionPass())
LOOP_PASS("hexagon-vlcr", HexagonVectorLoopCarriedReusePass())
#undef LOOP_PASS
3 changes: 3 additions & 0 deletions llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ HexagonTargetMachine::getSubtargetImpl(const Function &F) const {

void HexagonTargetMachine::registerPassBuilderCallbacks(
PassBuilder &PB, bool PopulateClassToPassNames) {
#define GET_PASS_REGISTRY "HexagonPassRegistry.def"
#include "llvm/Passes/TargetPassRegistry.inc"

PB.registerLateLoopOptimizationsEPCallback(
[=](LoopPassManager &LPM, OptimizationLevel Level) {
LPM.addPass(HexagonLoopIdiomRecognitionPass());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: opt < %s -hexagon-vlcr | opt -passes=adce -S | FileCheck %s
; RUN: opt -mtriple=hexagon-- -passes='loop(hexagon-vlcr),adce' -S %s | FileCheck %s

; CHECK: %.hexagon.vlcr = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B
; ModuleID = 'hexagon_vector_loop_carried_reuse.c'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: opt < %s -march=hexagon -hexagon-vlcr | opt -passes=adce -S | FileCheck %s
; RUN: opt -mtriple hexagon-- -passes='loop(hexagon-vlcr),adce' -S %s | FileCheck %s

; CHECK: %v32.hexagon.vlcr = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: opt < %s -hexagon-vlcr | opt -passes=adce -S | FileCheck %s
; RUN: opt -mtriple=hexagon-- -passes='loop(hexagon-vlcr),adce' -S %s | FileCheck %s

; CHECK-NOT: %.hexagon.vlcr
; ModuleID = 'hexagon_vector_loop_carried_reuse.c'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: opt -hexagon-vlcr < %s -S | FileCheck %s
; RUN: opt -mtriple=hexagon-- -passes=hexagon-vlcr -S %s | FileCheck %s

; Test that reuse doesn't occur due to two shufflevectors with different masks.

Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/Hexagon/hvx-loopidiom-memcpy.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt -march=hexagon -hexagon-loop-idiom -S < %s | FileCheck %s
; RUN: opt -mtriple=hexagon-- -p hexagon-loop-idiom -disable-memcpy-idiom -S < %s | FileCheck %s

; Make sure we don't convert load/store loops into memcpy if the access type
; is a vector. Using vector instructions is generally better in such cases.
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/CodeGen/Hexagon/loop-idiom/hexagon-memmove1.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
; Check for recognizing the "memmove" idiom.
; RUN: opt -hexagon-loop-idiom -S -mtriple hexagon-unknown-elf < %s \
; RUN: | FileCheck %s
; RUN: opt -p hexagon-loop-idiom -S -mtriple hexagon-unknown-elf < %s \
; RUN: | FileCheck %s
; CHECK: call void @llvm.memmove

; Function Attrs: norecurse nounwind
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/CodeGen/Hexagon/loop-idiom/hexagon-memmove2.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
; RUN: opt -hexagon-loop-idiom -S -mtriple hexagon-unknown-elf < %s \
; RUN: | FileCheck %s
; RUN: opt -p hexagon-loop-idiom -S -mtriple hexagon-unknown-elf < %s \
; RUN: | FileCheck %s

define void @PR14241(ptr %s, i64 %size) #0 {
; Ensure that we don't form a memcpy for strided loops. Briefly, when we taught
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/Hexagon/loop-idiom/lcssa.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: opt -S -hexagon-loop-idiom < %s | opt -S -passes='loop(loop-deletion),gvn'
; RUN: opt -mtriple hexagon-- -S -passes='loop(hexagon-loop-idiom,loop-deletion),gvn'
; REQUIRES: asserts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this REQUIRES doesn't make sense, we should run it under all configurations...

same for the other tests here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this test should be run under all configurations. REQUIRES should be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, but should be done in a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll push a patch to remove REQUIRES.


; This tests that the HexagonLoopIdiom pass does not mark LCSSA information
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an issue. the new PM loop infra assumes that loops are always in LCSSA form. either the pass needs to ensure the loops are in LCSSA form, or perhaps it can just call a helper method

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll push a patch to make sure LCSSA form is preserved.

Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/Hexagon/loop-idiom/memmove-rt-check.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt -hexagon-loop-idiom -S < %s | FileCheck %s
; RUN: opt -p hexagon-loop-idiom -S < %s | FileCheck %s

; Make sure that we generate correct runtime checks.

Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/Hexagon/loop-idiom/nullptr-crash.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt -hexagon-loop-idiom -mtriple hexagon-unknown-elf < %s
; RUN: opt -p hexagon-loop-idiom -mtriple hexagon-unknown-elf < %s
; REQUIRES: asserts

target triple = "hexagon"
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/Hexagon/loop-idiom/pmpy-infinite-loop.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt -march=hexagon -hexagon-loop-idiom -S < %s | FileCheck %s
; RUN: opt -march=hexagon -p hexagon-loop-idiom -S < %s | FileCheck %s
; CHECK-LABEL: define void @fred

; Check that this test does not crash.
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/Hexagon/loop-idiom/pmpy-long-loop.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt -march=hexagon -hexagon-loop-idiom -S < %s | FileCheck %s
; RUN: opt -march=hexagon -p hexagon-loop-idiom -S < %s | FileCheck %s
;
; The number of nested selects caused the simplification loop to take
; more than the maximum number of iterations. This caused the compiler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt -march=hexagon -hexagon-loop-idiom -S < %s | FileCheck %s
; RUN: opt -march=hexagon -p hexagon-loop-idiom -S < %s | FileCheck %s
; REQUIRES: asserts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Please remove REQUIRES.

;
; Check for sane output, this used to crash.
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/CodeGen/Hexagon/loop-idiom/pmpy.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
; RUN: opt -hexagon-loop-idiom < %s -mtriple=hexagon-unknown-unknown -S \
; RUN: | FileCheck %s
; RUN: opt -p hexagon-loop-idiom < %s -mtriple=hexagon-unknown-unknown -S \
; RUN: | FileCheck %s

target triple = "hexagon"

Expand Down