+2007-07-23 Richard Sandiford <richard@codesourcery.com>
+
+ * config/mips/mips.c (override_options): Use mips_costs to derive
+ the default branch cost.
+ * config/mips/mips.h (BRANCH_COST): Use mips_branch_cost rather
+ than mips_costs.
+ * config/mips/mips.opt (mbranch-cost=): New option.
+ * doc/invoke.texi (-mbrach-cost): Document new MIPS option.
+
2007-07-23 Richard Sandiford <richard@codesourcery.com>
* config/mips/mips.h (GR_REG_CLASS_P, COP_REG_CLASS_P): Delete.
else
mips_cost = &mips_rtx_cost_data[mips_tune];
+ /* If the user hasn't specified a branch cost, use the processor's
+ default. */
+ if (mips_branch_cost == 0)
+ mips_branch_cost = mips_cost->branch_cost;
+
if ((target_flags_explicit & MASK_64BIT) != 0)
{
/* The user specified the size of the integer registers. Make sure
/* A C expression for the cost of a branch instruction. A value of
1 is the default; other values are interpreted relative to that. */
-#define BRANCH_COST mips_cost->branch_cost
+#define BRANCH_COST mips_branch_cost
#define LOGICAL_OP_NON_SHORT_CIRCUIT 0
/* If defined, modifies the length assigned to instruction INSN as a
Target RejectNegative Joined Var(mips_arch_string)
-march=ISA Generate code for the given ISA
+mbranch-cost=
+Target RejectNegative Joined UInteger Var(mips_branch_cost)
+-mbranch-cost=COST Set the cost of branches to roughly COST instructions
+
mbranch-likely
Target Report Mask(BRANCHLIKELY)
Use Branch Likely instructions, overriding the architecture default
-mfix-vr4120 -mno-fix-vr4120 -mfix-vr4130 -mno-fix-vr4130 @gol
-mfix-sb1 -mno-fix-sb1 @gol
-mflush-func=@var{func} -mno-flush-func @gol
--mbranch-likely -mno-branch-likely @gol
+-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely @gol
-mfp-exceptions -mno-fp-exceptions @gol
-mvr4130-align -mno-vr4130-align}
depends on the target GCC was configured for, but commonly is either
@samp{_flush_func} or @samp{__cpu_flush}.
+@item mbranch-cost=@var{num}
+@opindex mbranch-cost
+Set the cost of branches to roughly @var{num} ``simple'' instructions.
+This cost is only a heuristic and is not guaranteed to produce
+consistent results across releases. A zero cost redundantly selects
+the default, which is based on the @option{-mtune} setting.
+
@item -mbranch-likely
@itemx -mno-branch-likely
@opindex mbranch-likely
+2007-07-23 Richard Sandiford <richard@codesourcery.com>
+
+ * gcc.target/mips/branch-cost-1.c: New test.
+ * gcc.target/mips/branch-cost-2.c: Likewise.
+
2007-07-23 Christopher D. Rickett <crickett@lanl.gov>
PR fortran/32732
--- /dev/null
+/* { dg-mips-options "-mbranch-cost=1 -mips64 -O2" } */
+int
+foo (int x, int y, int z, int k)
+{
+ return x == k ? x + y : z - x;
+}
+/* { dg-final { scan-assembler-not "\t(movz|movn)\t" } } */
+/* { dg-final { scan-assembler "\t(bne|beq)\t" } } */
--- /dev/null
+/* { dg-mips-options "-mbranch-cost=10 -mips64 -O2" } */
+int
+foo (int x, int y, int z, int k)
+{
+ return x == k ? x + y : z - x;
+}
+/* { dg-final { scan-assembler "\t(movz|movn)\t" } } */
+/* { dg-final { scan-assembler-not "\t(bne|beq)\t" } } */