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

Chris Lattner lattner at cs.uiuc.edu
Thu Sep 23 08:46:11 PDT 2004



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.245 -> 1.246
---
Log message:

Implement select.ll:test16: fold   load (select C, X, null)  -> load X


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

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.245 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.246
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.245	Tue Sep 21 16:35:23 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Thu Sep 23 10:46:00 2004
@@ -3071,6 +3071,20 @@
         return new SelectInst(SI->getCondition(), V1, V2);
       }
 
+      // load (select (cond, null, P)) -> load P
+      if (Constant *C = dyn_cast<Constant>(SI->getOperand(1)))
+        if (C->isNullValue()) {
+          LI.setOperand(0, SI->getOperand(2));
+          return &LI;
+        }
+
+      // load (select (cond, P, null)) -> load P
+      if (Constant *C = dyn_cast<Constant>(SI->getOperand(2)))
+        if (C->isNullValue()) {
+          LI.setOperand(0, SI->getOperand(1));
+          return &LI;
+        }
+
     } else if (PHINode *PN = dyn_cast<PHINode>(Op)) {
       // load (phi (&V1, &V2, &V3))  --> phi(load &V1, load &V2, load &V3)
       bool Safe = PN->getParent() == LI.getParent();






More information about the llvm-commits mailing list