-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[WebAssembly] Add patterns for relaxed madd #147487
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
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
683fae7
Precommit test for #121311
badumbatish b1c4c01
[WASM] Optimize fma when relaxed and ffast-math
badumbatish 4aa43a1
[WASM] Fix nits for PR 147487
badumbatish 02569b6
[WASM] Add more vector widths for PR 147487
badumbatish 63dc901
Use tablegen instead of cpp, relax only seperate fmul fadd
badumbatish 19b72e4
Resolve PR review
badumbatish 13f9f79
Added test case for fp16, refactor pattern support in tablegen to mul…
badumbatish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
|
||
; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128,+relaxed-simd | FileCheck %s | ||
target triple = "wasm32" | ||
define <4 x float> @fma_vector_4xf32_seperate(<4 x float> %a, <4 x float> %b, <4 x float> %c) { | ||
; CHECK-LABEL: fma_vector_4xf32_seperate: | ||
; CHECK: .functype fma_vector_4xf32_seperate (v128, v128, v128) -> (v128) | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: f32x4.relaxed_madd $push0=, $2, $1, $0 | ||
; CHECK-NEXT: return $pop0 | ||
entry: | ||
%mul.i = fmul fast <4 x float> %b, %a | ||
%add.i = fadd fast <4 x float> %mul.i, %c | ||
badumbatish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ret <4 x float> %add.i | ||
} | ||
|
||
define <4 x float> @fma_vector_4xf32_llvm(<4 x float> %a, <4 x float> %b, <4 x float> %c) { | ||
; CHECK-LABEL: fma_vector_4xf32_llvm: | ||
; CHECK: .functype fma_vector_4xf32_llvm (v128, v128, v128) -> (v128) | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: f32x4.relaxed_madd $push0=, $0, $1, $2 | ||
; CHECK-NEXT: return $pop0 | ||
entry: | ||
%fma = tail call fast <4 x float> @llvm.fma(<4 x float> %a, <4 x float> %b, <4 x float> %c) | ||
ret <4 x float> %fma | ||
} | ||
|
||
|
||
define <8 x float> @fma_vector_8xf32_seperate(<8 x float> %a, <8 x float> %b, <8 x float> %c) { | ||
; CHECK-LABEL: fma_vector_8xf32_seperate: | ||
; CHECK: .functype fma_vector_8xf32_seperate (i32, v128, v128, v128, v128, v128, v128) -> () | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: f32x4.relaxed_madd $push0=, $6, $4, $2 | ||
; CHECK-NEXT: v128.store 16($0), $pop0 | ||
; CHECK-NEXT: f32x4.relaxed_madd $push1=, $5, $3, $1 | ||
; CHECK-NEXT: v128.store 0($0), $pop1 | ||
; CHECK-NEXT: return | ||
entry: | ||
%mul.i = fmul fast <8 x float> %b, %a | ||
%add.i = fadd fast <8 x float> %mul.i, %c | ||
ret <8 x float> %add.i | ||
} | ||
|
||
define <8 x float> @fma_vector_8xf32_llvm(<8 x float> %a, <8 x float> %b, <8 x float> %c) { | ||
; CHECK-LABEL: fma_vector_8xf32_llvm: | ||
; CHECK: .functype fma_vector_8xf32_llvm (i32, v128, v128, v128, v128, v128, v128) -> () | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: f32x4.relaxed_madd $push0=, $2, $4, $6 | ||
; CHECK-NEXT: v128.store 16($0), $pop0 | ||
; CHECK-NEXT: f32x4.relaxed_madd $push1=, $1, $3, $5 | ||
; CHECK-NEXT: v128.store 0($0), $pop1 | ||
; CHECK-NEXT: return | ||
entry: | ||
%fma = tail call fast <8 x float> @llvm.fma(<8 x float> %a, <8 x float> %b, <8 x float> %c) | ||
ret <8 x float> %fma | ||
} | ||
|
||
|
||
define <2 x double> @fma_vector_2xf64_seperate(<2 x double> %a, <2 x double> %b, <2 x double> %c) { | ||
; CHECK-LABEL: fma_vector_2xf64_seperate: | ||
; CHECK: .functype fma_vector_2xf64_seperate (v128, v128, v128) -> (v128) | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: f64x2.relaxed_madd $push0=, $2, $1, $0 | ||
; CHECK-NEXT: return $pop0 | ||
entry: | ||
%mul.i = fmul fast <2 x double> %b, %a | ||
%add.i = fadd fast <2 x double> %mul.i, %c | ||
ret <2 x double> %add.i | ||
} | ||
|
||
define <2 x double> @fma_vector_2xf64_llvm(<2 x double> %a, <2 x double> %b, <2 x double> %c) { | ||
; CHECK-LABEL: fma_vector_2xf64_llvm: | ||
; CHECK: .functype fma_vector_2xf64_llvm (v128, v128, v128) -> (v128) | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: f64x2.relaxed_madd $push0=, $0, $1, $2 | ||
; CHECK-NEXT: return $pop0 | ||
entry: | ||
%fma = tail call fast <2 x double> @llvm.fma(<2 x double> %a, <2 x double> %b, <2 x double> %c) | ||
ret <2 x double> %fma | ||
} | ||
|
||
|
||
define float @fma_scalar_f32_seperate(float %a, float %b, float %c) { | ||
; CHECK-LABEL: fma_scalar_f32_seperate: | ||
; CHECK: .functype fma_scalar_f32_seperate (f32, f32, f32) -> (f32) | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: f32.mul $push0=, $1, $0 | ||
; CHECK-NEXT: f32.add $push1=, $pop0, $2 | ||
; CHECK-NEXT: return $pop1 | ||
entry: | ||
%mul.i = fmul fast float %b, %a | ||
%add.i = fadd fast float %mul.i, %c | ||
ret float %add.i | ||
} | ||
|
||
define float @fma_scalar_f32_llvm(float %a, float %b, float %c) { | ||
; CHECK-LABEL: fma_scalar_f32_llvm: | ||
; CHECK: .functype fma_scalar_f32_llvm (f32, f32, f32) -> (f32) | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: call $push0=, fmaf, $0, $1, $2 | ||
; CHECK-NEXT: return $pop0 | ||
entry: | ||
%fma = tail call fast float @llvm.fma(float %a, float %b, float %c) | ||
ret float %fma | ||
} | ||
|
||
|
||
define double @fma_scalar_f64_seperate(double %a, double %b, double %c) { | ||
; CHECK-LABEL: fma_scalar_f64_seperate: | ||
; CHECK: .functype fma_scalar_f64_seperate (f64, f64, f64) -> (f64) | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: f64.mul $push0=, $1, $0 | ||
; CHECK-NEXT: f64.add $push1=, $pop0, $2 | ||
; CHECK-NEXT: return $pop1 | ||
entry: | ||
%mul.i = fmul fast double %b, %a | ||
%add.i = fadd fast double %mul.i, %c | ||
ret double %add.i | ||
} | ||
|
||
define double @fma_scalar_f64_llvm(double %a, double %b, double %c) { | ||
; CHECK-LABEL: fma_scalar_f64_llvm: | ||
; CHECK: .functype fma_scalar_f64_llvm (f64, f64, f64) -> (f64) | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: call $push0=, fma, $0, $1, $2 | ||
; CHECK-NEXT: return $pop0 | ||
entry: | ||
%fma = tail call fast double @llvm.fma(double %a, double %b, double %c) | ||
ret double %fma | ||
} | ||
badumbatish marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.