Merge pull request #6722 from ReinUsesLisp/xmad-opts

shader: Fold integer FMA from Nvidia's pattern
This commit is contained in:
bunnei 2021-07-29 18:45:37 -07:00 committed by GitHub
commit a98f14e9b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 196 additions and 15 deletions

View file

@ -57,6 +57,7 @@ public:
[[nodiscard]] IR::Inst* Inst() const;
[[nodiscard]] IR::Inst* InstRecursive() const;
[[nodiscard]] IR::Inst* TryInstRecursive() const;
[[nodiscard]] IR::Value Resolve() const;
[[nodiscard]] IR::Reg Reg() const;
[[nodiscard]] IR::Pred Pred() const;
@ -308,6 +309,13 @@ inline IR::Inst* Value::InstRecursive() const {
return inst;
}
inline IR::Inst* Value::TryInstRecursive() const {
if (IsIdentity()) {
return inst->Arg(0).TryInstRecursive();
}
return type == Type::Opaque ? inst : nullptr;
}
inline IR::Value Value::Resolve() const {
if (IsIdentity()) {
return inst->Arg(0).Resolve();