Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: src/IceTargetLoweringX86Base.h

Issue 1497033002: Fuse icmp/fcmp with select (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: unittests work Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceTargetLoweringX86Base.h
diff --git a/src/IceTargetLoweringX86Base.h b/src/IceTargetLoweringX86Base.h
index e2530edb0c960616adce3b150ab613a369efc73f..7d212f76bec0c362d1f6bfb685ce4caff1037cff 100644
--- a/src/IceTargetLoweringX86Base.h
+++ b/src/IceTargetLoweringX86Base.h
@@ -347,6 +347,12 @@ protected:
void _and(Variable *Dest, Operand *Src0) {
Context.insert(Traits::Insts::And::create(Func, Dest, Src0));
}
+ void _andnps(Variable *Dest, Operand *Src0) {
+ Context.insert(Traits::Insts::Andnps::create(Func, Dest, Src0));
+ }
+ void _andps(Variable *Dest, Operand *Src0) {
+ Context.insert(Traits::Insts::Andps::create(Func, Dest, Src0));
+ }
void _and_rmw(typename Traits::X86OperandMem *DestSrc0, Operand *Src1) {
Context.insert(Traits::Insts::AndRMW::create(Func, DestSrc0, Src1));
}
@@ -488,6 +494,11 @@ protected:
void _movp(Variable *Dest, Operand *Src0) {
Context.insert(Traits::Insts::Movp::create(Func, Dest, Src0));
}
+ void _movp_redefined(Variable *Dest, Operand *Src0) {
+ Inst *NewInst = Traits::Insts::Movp::create(Func, Dest, Src0);
+ NewInst->setDestRedefined();
+ Context.insert(NewInst);
+ }
void _movq(Variable *Dest, Operand *Src0) {
Context.insert(Traits::Insts::Movq::create(Func, Dest, Src0));
}
@@ -500,6 +511,12 @@ protected:
void _movzx(Variable *Dest, Operand *Src0) {
Context.insert(Traits::Insts::Movzx::create(Func, Dest, Src0));
}
+ void _maxss(Variable *Dest, Operand *Src0) {
+ Context.insert(Traits::Insts::Maxss::create(Func, Dest, Src0));
+ }
+ void _minss(Variable *Dest, Operand *Src0) {
+ Context.insert(Traits::Insts::Minss::create(Func, Dest, Src0));
+ }
void _mul(Variable *Dest, Variable *Src0, Operand *Src1) {
Context.insert(Traits::Insts::Mul::create(Func, Dest, Src0, Src1));
}
@@ -518,6 +535,9 @@ protected:
void _or(Variable *Dest, Operand *Src0) {
Context.insert(Traits::Insts::Or::create(Func, Dest, Src0));
}
+ void _orps(Variable *Dest, Operand *Src0) {
+ Context.insert(Traits::Insts::Orps::create(Func, Dest, Src0));
+ }
void _or_rmw(typename Traits::X86OperandMem *DestSrc0, Operand *Src1) {
Context.insert(Traits::Insts::OrRMW::create(Func, DestSrc0, Src1));
}
@@ -663,6 +683,9 @@ protected:
void _xor(Variable *Dest, Operand *Src0) {
Context.insert(Traits::Insts::Xor::create(Func, Dest, Src0));
}
+ void _xorps(Variable *Dest, Operand *Src0) {
+ Context.insert(Traits::Insts::Xorps::create(Func, Dest, Src0));
+ }
void _xor_rmw(typename Traits::X86OperandMem *DestSrc0, Operand *Src1) {
Context.insert(Traits::Insts::XorRMW::create(Func, DestSrc0, Src1));
}
@@ -753,29 +776,47 @@ private:
/// Emit the code for a combined operation and branch, or set the destination
/// variable of the operation if Br == nullptr.
John 2015/12/07 13:07:44 The comment needs to be updated.
sehr 2015/12/15 20:45:44 Done.
- void lowerIcmpAndBr(const InstIcmp *Icmp, const InstBr *Br);
- void lowerFcmpAndBr(const InstFcmp *Fcmp, const InstBr *Br);
- void lowerArithAndBr(const InstArithmetic *Arith, const InstBr *Br);
-
- /// Emit a setcc instruction if Br == nullptr; otherwise emit a branch.
- void setccOrBr(typename Traits::Cond::BrCond Condition, Variable *Dest,
- const InstBr *Br);
-
- /// Emit a mov [1|0] instruction if Br == nullptr; otherwise emit a branch.
- void movOrBr(bool IcmpResult, Variable *Dest, const InstBr *Br);
+ void lowerIcmpAndConsumer(const InstIcmp *Icmp, const Inst *Consumer);
+ void lowerFcmpAndConsumer(const InstFcmp *Fcmp, const Inst *Consumer);
+ void lowerArithAndConsumer(const InstArithmetic *Arith, const Inst *Consumer);
+
+ /// Emit a setcc instruction if Consumer == nullptr; otherwise emit a
+ /// specialized version of Consumer.
+ void setccOrConsumer(typename Traits::Cond::BrCond Condition, Variable *Dest,
+ const Inst *Consumer);
+
+ /// Emit a mov [1|0] instruction if Consumer == nullptr; otherwise emit a
+ /// specialized version of Consumer.
+ void movOrConsumer(bool IcmpResult, Variable *Dest, const Inst *Consumer);
+
+ /// Emit the code for instructions with a vector type.
+ void lowerIcmpVector(const InstIcmp *Icmp);
+ void lowerFcmpVector(const InstFcmp *Icmp);
+ void lowerSelectVector(const InstSelect *Inst);
+
+ /// Helpers for select lowering.
+ void lowerSelectMove(Variable *Dest, typename Traits::Cond::BrCond Cond,
+ Operand *SrcT, Operand *SrcF);
+ void lowerSelectIntMove(Variable *Dest, typename Traits::Cond::BrCond Cond,
+ Operand *SrcT, Operand *SrcF);
+ /// Generic helper to move an arbitrary type from Src to Dest.
+ void lowerMove(Variable *Dest, Operand *Src, bool IsRedefinition);
+
+ /// Optimizations for idiom recognition.
+ bool lowerOptimizeFcmpSelect(const InstFcmp *Fcmp, const InstSelect *Select);
/// Complains loudly if invoked because the cpu can handle 64-bit types
/// natively.
template <typename T = Traits>
typename std::enable_if<T::Is64Bit, void>::type lowerIcmp64(const InstIcmp *,
- const InstBr *) {
+ const Inst *) {
llvm::report_fatal_error(
"Hey, yo! This is x86-64. Watcha doin'? (lowerIcmp64)");
}
/// x86lowerIcmp64 handles 64-bit icmp lowering.
template <typename T = Traits>
typename std::enable_if<!T::Is64Bit, void>::type
- lowerIcmp64(const InstIcmp *Icmp, const InstBr *Br);
+ lowerIcmp64(const InstIcmp *Icmp, const Inst *Consumer);
BoolFolding FoldingInfo;
};

Powered by Google App Engine
This is Rietveld 408576698