From 711b3402aafd607eeb9ec56395c78e98fe491e76 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 14 Nov 2004 07:33:16 +0000 Subject: [PATCH] Transform this: %X = alloca ... %Y = alloca ... X == Y into false. This allows us to simplify some stuff in eon (and probably many other C++ programs) where operator= was checking for self assignment. Folding this allows us to SROA several additional structs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17735 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 5af9aee165d..f1c1c3194b6 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1870,12 +1870,14 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) { if (isa(Op1)) // X setcc undef -> undef return ReplaceInstUsesWith(I, UndefValue::get(Type::BoolTy)); - // setcc , 0 - Global/Stack value addresses are never null! - if (isa(Op1) && - (isa(Op0) || isa(Op0))) + // setcc , - Global/Stack value + // addresses never equal each other! We already know that Op0 != Op1. + if ((isa(Op0) || isa(Op0) || + isa(Op0)) && + (isa(Op1) || isa(Op1) || + isa(Op1))) return ReplaceInstUsesWith(I, ConstantBool::get(!isTrueWhenEqual(I))); - // setcc's with boolean values can always be turned into bitwise operations if (Ty == Type::BoolTy) { switch (I.getOpcode()) {