Subzero: Use a setcc sequence for better icmp lowering.
For an example like:
%a = icmp eq i32 %b, %c
The original icmp lowering sequence for i8/i16/i32 was something like:
cmpl b, c
movb 1, a
je label
movb 0, a
label:
The improved sequence is:
cmpl b, c
sete a
In O2 mode, this doesn't help when successive compare/branch instructions are fused, but it does help when the boolean result needs to be saved and later used.
BUG= none
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/1118353005
diff --git a/src/IceInstX8632.h b/src/IceInstX8632.h
index fca32c6..4ea2b36 100644
--- a/src/IceInstX8632.h
+++ b/src/IceInstX8632.h
@@ -242,6 +242,7 @@
Rol,
Sar,
Sbb,
+ Setcc,
Shl,
Shld,
Shr,
@@ -1585,6 +1586,30 @@
~InstX8632Ret() override {}
};
+// Conditional set-byte instruction.
+class InstX8632Setcc : public InstX8632 {
+ InstX8632Setcc() = delete;
+ InstX8632Setcc(const InstX8632Cmov &) = delete;
+ InstX8632Setcc &operator=(const InstX8632Setcc &) = delete;
+
+public:
+ static InstX8632Setcc *create(Cfg *Func, Variable *Dest,
+ CondX86::BrCond Cond) {
+ return new (Func->allocate<InstX8632Setcc>())
+ InstX8632Setcc(Func, Dest, Cond);
+ }
+ void emit(const Cfg *Func) const override;
+ void emitIAS(const Cfg *Func) const override;
+ void dump(const Cfg *Func) const override;
+ static bool classof(const Inst *Inst) { return isClassof(Inst, Setcc); }
+
+private:
+ InstX8632Setcc(Cfg *Func, Variable *Dest, CondX86::BrCond Cond);
+ ~InstX8632Setcc() override {}
+
+ const CondX86::BrCond Condition;
+};
+
// Exchanging Add instruction. Exchanges the first operand (destination
// operand) with the second operand (source operand), then loads the sum
// of the two values into the destination operand. The destination may be