Skip to content

[LV][VPlan] Add fast flags for selectRecipe #121023

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 3 commits into from
Jan 15, 2025

Conversation

LiqinWeng
Copy link
Contributor

@LiqinWeng LiqinWeng commented Dec 24, 2024

Change the inheritance of class VPWidenSelectRecipe to class VPRecipeWithIRFlags, which allows recipe of the select to pass the fastmath flags.The patch of #119847 will add the fastmath flag to for recipe

@llvmbot
Copy link
Member

llvmbot commented Dec 24, 2024

@llvm/pr-subscribers-vectorizers

@llvm/pr-subscribers-llvm-transforms

Author: LiqinWeng (LiqinWeng)

Changes

The patch of #119847 will add the fastmath flag to for recipe


Full diff: https://github.com/llvm/llvm-project/pull/121023.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+2-3)
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 6486c6745a6800..4f457e9876358b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1813,11 +1813,10 @@ class VPHistogramRecipe : public VPRecipeBase {
 };
 
 /// A recipe for widening select instructions.
-struct VPWidenSelectRecipe : public VPSingleDefRecipe {
+struct VPWidenSelectRecipe : public VPRecipeWithIRFlags {
   template <typename IterT>
   VPWidenSelectRecipe(SelectInst &I, iterator_range<IterT> Operands)
-      : VPSingleDefRecipe(VPDef::VPWidenSelectSC, Operands, &I,
-                          I.getDebugLoc()) {}
+      : VPRecipeWithIRFlags(VPDef::VPWidenSelectSC, Operands, I) {}
 
   ~VPWidenSelectRecipe() override = default;
 

@LiqinWeng
Copy link
Contributor Author

@Mel-Chen :)

@LiqinWeng
Copy link
Contributor Author

Any problems with this patch? @Mel-Chen @fhahn

Copy link
Contributor

@fhahn fhahn left a comment

Choose a reason for hiding this comment

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

Could you add a test case with a select with fast-math flags?

@LiqinWeng LiqinWeng force-pushed the pre-select-for-fmfs branch from 23ee671 to f51a584 Compare January 6, 2025 11:16
@LiqinWeng
Copy link
Contributor Author

LiqinWeng commented Jan 6, 2025

Could you add a test case with a select with fast-math flags?

done, pls give me LG:)

Copy link
Contributor

@Mel-Chen Mel-Chen left a comment

Choose a reason for hiding this comment

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

Don't we need to call setFlags() in execute()?

@LiqinWeng LiqinWeng force-pushed the pre-select-for-fmfs branch from 15c3b5d to c372a26 Compare January 12, 2025 04:50
@LiqinWeng
Copy link
Contributor Author

Don't we need to call setFlags() in execute()?
Need, fixed and added tests~

@LiqinWeng LiqinWeng changed the title [LV][VPlan] Change the inheritance of class VPWidenSelectRecipe to class VPRecipeWithIRFlags, which allows recipe of the select to pass the fastmath flags [LV][VPlan] Add fast flags for selectRecipe Jan 12, 2025
Copy link

github-actions bot commented Jan 12, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Change the inheritance of class VPWidenSelectRecipe to class VPRecipeWithIRFlags, which allows recipe of the select to pass the fastmath flags
The patch of llvm#119847 will add the fastmath flag to for recipe
@LiqinWeng LiqinWeng force-pushed the pre-select-for-fmfs branch from c372a26 to f4932cc Compare January 12, 2025 05:05
Comment on lines 3 to 5
; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize \
; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 \
; RUN: -riscv-v-vector-bits-min=128 -disable-output < %s 2>&1 | FileCheck --check-prefix=FAST %s
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move this to vplan-printing.ll? RISCV triple and other flags shouldn't be needed for the printing test (if they re needed, the test needs to be in the RISCV subdirectory otherwise it will fail when RISCV is not built

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, fixed ~

Comment on lines 4 to 5
; RUN: opt < %s -passes=loop-vectorize -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 \
; RUN: -riscv-v-vector-bits-min=128 -S | FileCheck --check-prefix=FAST %s
Copy link
Contributor

Choose a reason for hiding this comment

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

Is RISCV triple really needed? Better to use -force-vector-width; if RISCV is really needed, it should be moved to the RISCV subdir.

(Also doesn't need REQUIRES: asserts?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks,fixed:)

@LiqinWeng LiqinWeng force-pushed the pre-select-for-fmfs branch 2 times, most recently from 08ebef0 to 47d9df2 Compare January 13, 2025 02:56
@LiqinWeng LiqinWeng force-pushed the pre-select-for-fmfs branch from 47d9df2 to cbd50dd Compare January 13, 2025 03:01
@LiqinWeng
Copy link
Contributor Author

If there is no problem, can you give me LG:)

Copy link
Contributor

@fhahn fhahn left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

Copy link
Contributor

@Mel-Chen Mel-Chen left a comment

Choose a reason for hiding this comment

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

LG

@LiqinWeng LiqinWeng merged commit 0294dab into llvm:main Jan 15, 2025
8 checks passed
@LiqinWeng LiqinWeng deleted the pre-select-for-fmfs branch January 16, 2025 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants