[PATCH] Make InstCombineCasts.cpp:OptimizeIntToFloatBitCast endian safe

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Tue Mar 26 04:12:29 PDT 2013


Chris Lattner <clattner at apple.com> wrote on 26.03.2013 00:19:59:
> On Mar 25, 2013, at 12:58 PM, Ulrich Weigand
> <Ulrich.Weigand at de.ibm.com> wrote:
> >
> > The computation of "Elt" above looks to be correct only for
little-endian
> > platforms ...
> >
> > If I disable the whole OptimizeIntToFloatBitCast optimization, I get
the
> > correct result again.
>
> Yes, this does look endian unsafe.  I'd be fine with you disabling
> this when targeting a big-endian system.  It would be nice to
> generalize the code, but it isn't critical at all.

Hmm, this seems to be relatively straightforward after all.
The attached patch fixes the problem for me, and keeps the
optimization enabled for big-endian platforms as well.

OK to commit?

Bye,
Ulrich

(See attached file: diff-llvm-instcombine-endianfix)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff-llvm-instcombine-endianfix
Type: application/octet-stream
Size: 1394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130326/74d43947/attachment.obj>


More information about the llvm-commits mailing list