[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon May 24 23:32:01 PDT 2004


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.203 -> 1.204

---
Log message:

Implement instcombine/cast.ll:test16:
Canonicalize cast X to bool into a setne instruction


---
Diffs of the changes:  (+5 -0)

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.203 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.204
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.203	Thu May 13 15:56:34 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Mon May 24 23:29:21 2004
@@ -1996,6 +1996,11 @@
     }
   }
 
+  // If this is a cast to bool, turn it into the appropriate setne instruction.
+  if (CI.getType() == Type::BoolTy)
+    return BinaryOperator::create(Instruction::SetNE, CI.getOperand(0),
+                       Constant::getNullValue(CI.getOperand(0)->getType()));
+
   // If casting the result of a getelementptr instruction with no offset, turn
   // this into a cast of the original pointer!
   //





More information about the llvm-commits mailing list