[llvm-commits] [llvm] r41740 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-09-05-EqualGEP.ll

Chris Lattner clattner at apple.com
Wed Sep 5 19:01:16 PDT 2007


On Sep 5, 2007, at 6:10 PM, Nick Lewycky wrote:

> Author: nicholas
> Date: Wed Sep  5 20:10:22 2007
> New Revision: 41740
>
> URL: http://llvm.org/viewvc/llvm-project?rev=41740&view=rev
> Log:
> When the two operands of an icmp are equal, there are five possible  
> predicates
> that would make the icmp true. Fixes PR1637.

Thanks for fixing this Nicholas!  Instead of enumerating the ICMP  
opcodes, please use the isTrueWhenEqual function in InstCombine.cpp

Thanks!

-Chris

> Added:
>     llvm/trunk/test/Transforms/InstCombine/2007-09-05-EqualGEP.ll
> Modified:
>     llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ 
> Scalar/InstructionCombining.cpp?rev=41740&r1=41739&r2=41740&view=diff
>
> ====================================================================== 
> ========
> --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp  
> (original)
> +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed  
> Sep  5 20:10:22 2007
> @@ -4563,7 +4563,9 @@
>        if (NumDifferences == 0)   // SAME GEP?
>          return ReplaceInstUsesWith(I, // No comparison is needed  
> here.
>                                     ConstantInt::get(Type::Int1Ty,
> -                                                    Cond ==  
> ICmpInst::ICMP_EQ));
> +                                                    Cond ==  
> ICmpInst::ICMP_EQ ||
> +                     Cond == ICmpInst::ICMP_ULE || Cond ==  
> ICmpInst::ICMP_UGE ||
> +                     Cond == ICmpInst::ICMP_SLE || Cond ==  
> ICmpInst::ICMP_SGE));
>        else if (NumDifferences == 1) {
>          Value *LHSV = GEPLHS->getOperand(DiffOperand);
>          Value *RHSV = GEPRHS->getOperand(DiffOperand);
>
> Added: llvm/trunk/test/Transforms/InstCombine/2007-09-05-EqualGEP.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ 
> InstCombine/2007-09-05-EqualGEP.ll?rev=41740&view=auto
>
> ====================================================================== 
> ========
> --- llvm/trunk/test/Transforms/InstCombine/2007-09-05-EqualGEP.ll  
> (added)
> +++ llvm/trunk/test/Transforms/InstCombine/2007-09-05-EqualGEP.ll  
> Wed Sep  5 20:10:22 2007
> @@ -0,0 +1,10 @@
> +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i1  
> true}
> +; PR1637
> +
> +define i1 @f(i8* %arr) {
> +        %X = getelementptr i8* %arr, i32 1
> +        %Y = getelementptr i8* %arr, i32 1
> +        %test = icmp uge i8* %X, %Y
> +        ret i1 %test
> +}
> +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list