[llvm] r185755 - DAGCombiner: Don't drop extension behavior when shrinking a load when unsafe.

Benjamin Kramer benny.kra at gmail.com
Sun Jul 7 00:48:10 PDT 2013


On Sun, Jul 7, 2013 at 1:11 AM, Richard Smith <richard at metafoo.co.uk> wrote:
>
> On Sat, Jul 6, 2013 at 7:05 AM, Benjamin Kramer
> <benny.kra at googlemail.com> wrote:
> > Author: d0k
> > Date: Sat Jul  6 09:05:09 2013
> > New Revision: 185755
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=185755&view=rev
> > Log:
> > DAGCombiner: Don't drop extension behavior when shrinking a load when unsafe.
> >
> > ReduceLoadWidth unconditionally drops extensions from loads. Limit it to the
> > case when all of the bits the extension would otherwise produce are dropped by
> > the shrink. It would be possible to shrink the load in more cases by merging
> > the extensions, but this isn't trivial and a very rare case. I left a TODO for
> > that case.
> >
> > Fixes PR16551.
>
> Any chance this also fixes PR16528?


It does :)

- Ben

>
>
> > Modified:
> >     llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> >     llvm/trunk/test/CodeGen/X86/shrink-compare.ll
> >
> > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=185755&r1=185754&r2=185755&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> > +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sat Jul  6 09:05:09 2013
> > @@ -5220,6 +5220,13 @@ SDValue DAGCombiner::ReduceLoadWidth(SDN
> >    if (LN0->getNumValues() > 2)
> >      return SDValue();
> >
> > +  // If the load that we're shrinking is an extload and we're not just
> > +  // discarding the extension we can't simply shrink the load. Bail.
> > +  // TODO: It would be possible to merge the extensions in some cases.
> > +  if (LN0->getExtensionType() != ISD::NON_EXTLOAD &&
> > +      LN0->getMemoryVT().getSizeInBits() < ExtVT.getSizeInBits() + ShAmt)
> > +    return SDValue();
> > +
> >    EVT PtrType = N0.getOperand(1).getValueType();
> >
> >    if (PtrType == MVT::Untyped || PtrType.isExtended())
> >
> > Modified: llvm/trunk/test/CodeGen/X86/shrink-compare.ll
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/shrink-compare.ll?rev=185755&r1=185754&r2=185755&view=diff
> > ==============================================================================
> > --- llvm/trunk/test/CodeGen/X86/shrink-compare.ll (original)
> > +++ llvm/trunk/test/CodeGen/X86/shrink-compare.ll Sat Jul  6 09:05:09 2013
> > @@ -66,3 +66,26 @@ lor.end:
> >    %p = phi i1 [ true, %entry ], [ %tobool1, %lor.rhs ]
> >    ret i1 %p
> >  }
> > +
> > + at x = global { i8, i8, i8, i8, i8, i8, i8, i8 } { i8 1, i8 0, i8 0, i8 0, i8 1, i8 0, i8 0, i8 1 }, align 4
> > +
> > +; PR16551
> > +define void @test5(i32 %X) nounwind {
> > +entry:
> > +  %bf.load = load i56* bitcast ({ i8, i8, i8, i8, i8, i8, i8, i8 }* @x to i56*), align 4
> > +  %bf.lshr = lshr i56 %bf.load, 32
> > +  %bf.cast = trunc i56 %bf.lshr to i32
> > +  %cmp = icmp ne i32 %bf.cast, 1
> > +  br i1 %cmp, label %if.then, label %if.end
> > +
> > +if.then:
> > +  tail call void @bar() nounwind
> > +  br label %if.end
> > +
> > +if.end:
> > +  ret void
> > +
> > +; CHECK: test5:
> > +; CHECK-NOT: cmpl $1,{{.*}}x+4
> > +; CHECK: ret
> > +}
> >
> >
> > _______________________________________________
> > 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