[llvm-commits] CVS: llvm-gcc/gcc/llvm-representation.h llvm-representation.c
Chris Lattner
lattner at cs.uiuc.edu
Fri May 7 11:56:03 PDT 2004
Changes in directory llvm-gcc/gcc:
llvm-representation.h updated: 1.5 -> 1.6
llvm-representation.c updated: 1.6 -> 1.7
---
Log message:
Improve compile times with llvm-gcc by folding conditional branches into
unconditional branches when the condition is obviously a constant.
---
Diffs of the changes: (+12 -1)
Index: llvm-gcc/gcc/llvm-representation.h
diff -u llvm-gcc/gcc/llvm-representation.h:1.5 llvm-gcc/gcc/llvm-representation.h:1.6
--- llvm-gcc/gcc/llvm-representation.h:1.5 Fri May 7 11:22:58 2004
+++ llvm-gcc/gcc/llvm-representation.h Fri May 7 11:55:49 2004
@@ -200,6 +200,11 @@
llvm_instruction *create_binary_inst(const char *Name, enum InstOpcode Opc,
llvm_value *Op1, llvm_value *Op2);
llvm_instruction *create_uncond_branch(struct llvm_basicblock *Dest);
+
+/* create_cond_branch - Create a conditional branch on Val to the two blocks.
+ * Be aware that if Val is a constant, this will actually return an
+ * unconditional branch.
+ */
llvm_instruction *create_cond_branch(llvm_value *Val,
struct llvm_basicblock *TrueBlock,
struct llvm_basicblock *FalseBlock);
Index: llvm-gcc/gcc/llvm-representation.c
diff -u llvm-gcc/gcc/llvm-representation.c:1.6 llvm-gcc/gcc/llvm-representation.c:1.7
--- llvm-gcc/gcc/llvm-representation.c:1.6 Fri May 7 11:22:57 2004
+++ llvm-gcc/gcc/llvm-representation.c Fri May 7 11:55:49 2004
@@ -572,7 +572,13 @@
llvm_instruction *create_cond_branch(llvm_value *Cond,
llvm_basicblock *TrueBlock,
llvm_basicblock *FalseBlock) {
- llvm_instruction *New = llvm_instruction_new(VoidTy, "", O_Br, 3);
+ llvm_instruction *New;
+ if (Cond == llvm_constant_bool_true)
+ return create_uncond_branch(TrueBlock);
+ else if (Cond == llvm_constant_bool_false)
+ return create_uncond_branch(FalseBlock);
+
+ New = llvm_instruction_new(VoidTy, "", O_Br, 3);
New->Operands[0] = Cond;
New->Operands[1] = D2V(TrueBlock);
New->Operands[2] = D2V(FalseBlock);
More information about the llvm-commits
mailing list