[llvm] r259375 - [InstCombine] Don't transform (X+INT_MAX)>=(Y+INT_MAX) -> (X<=Y)

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 11:18:25 PST 2016


The bug is at least four years old so it isn't a regression.  However, the
fix is quite low risk.  I think it cannot hurt to merge it in to 3.8

On Mon, Feb 1, 2016 at 11:06 AM, Hans Wennborg <hans at chromium.org> wrote:

> 3.8?
>
> On Mon, Feb 1, 2016 at 9:37 AM, David Majnemer via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: majnemer
> > Date: Mon Feb  1 11:37:56 2016
> > New Revision: 259375
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=259375&view=rev
> > Log:
> > [InstCombine] Don't transform (X+INT_MAX)>=(Y+INT_MAX) -> (X<=Y)
> >
> > This miscompile came about because we tried to use a transform which was
> > only appropriate for xor operators when addition was present.
> >
> > This fixes PR26407.
> >
> > Modified:
> >     llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> >     llvm/trunk/test/Transforms/InstCombine/icmp.ll
> >
> > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=259375&r1=259374&r2=259375&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> (original)
> > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon
> Feb  1 11:37:56 2016
> > @@ -3877,7 +3877,7 @@ Instruction *InstCombiner::visitICmpInst
> >                                  BO1->getOperand(0));
> >            }
> >
> > -          if (CI->isMaxValue(true)) {
> > +          if (BO0->getOpcode() == Instruction::Xor &&
> CI->isMaxValue(true)) {
> >              ICmpInst::Predicate Pred = I.isSigned()
> >                                             ? I.getUnsignedPredicate()
> >                                             : I.getSignedPredicate();
> >
> > Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=259375&r1=259374&r2=259375&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original)
> > +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Mon Feb  1 11:37:56
> 2016
> > @@ -1672,3 +1672,15 @@ define i1 @cmp_slt_rhs_inc(float %x, i32
> >    %cmp = icmp slt i32 %conv, %inc
> >    ret i1 %cmp
> >  }
> > +
> > +; CHECK-LABEL: @PR26407
> > +; CHECK-NEXT: %[[addx:.*]] = add i32 %x, 2147483647
> > +; CHECK-NEXT: %[[addy:.*]] = add i32 %y, 2147483647
> > +; CHECK-NEXT: %[[cmp:.*]] = icmp uge i32 %[[addx]], %[[addy]]
> > +; CHECK-NEXT: ret i1 %[[cmp]]
> > +define i1 @PR26407(i32 %x, i32 %y) {
> > +  %addx = add i32 %x, 2147483647
> > +  %addy = add i32 %y, 2147483647
> > +  %cmp = icmp uge i32 %addx, %addy
> > +  ret i1 %cmp
> > +}
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160201/641e426e/attachment.html>


More information about the llvm-commits mailing list