Richard Osborne
2013-Jun-28 13:13 UTC
[LLVMdev] Possible instruction combine bug with pointer icmp?
If I give instcombine the following IR: define i1 @f([1 x i8]* %a, [1 x i8]* %b) { %c = getelementptr [1 x i8]* %a, i32 0, i32 0 %d = getelementptr [1 x i8]* %b, i32 0, i32 0 %cmp = icmp ult i8* %c, %d ret i1 %cmp } It optimizes it into: define i1 @f([1 x i8]* %a, [1 x i8]* %b) { %cmp = icmp slt [1 x i8]* %a, %b ret i1 %cmp } Is this a bug, or are there some semantics of icmp or getelementptr I'm missing that mean it's OK to change this from an unsigned comparison to a signed comparison? -- Richard Osborne | XMOS http://www.xmos.com
Eli Friedman
2013-Jun-28 14:56 UTC
[LLVMdev] Possible instruction combine bug with pointer icmp?
On Fri, Jun 28, 2013 at 6:13 AM, Richard Osborne <richard at xmos.com> wrote:> If I give instcombine the following IR: > > define i1 @f([1 x i8]* %a, [1 x i8]* %b) { > %c = getelementptr [1 x i8]* %a, i32 0, i32 0 > %d = getelementptr [1 x i8]* %b, i32 0, i32 0 > %cmp = icmp ult i8* %c, %d > ret i1 %cmp > } > > It optimizes it into: > > define i1 @f([1 x i8]* %a, [1 x i8]* %b) { > %cmp = icmp slt [1 x i8]* %a, %b > ret i1 %cmp > } > > Is this a bug, or are there some semantics of icmp or getelementptr I'm > missing that mean it's OK to change this from an unsigned comparison to a > signed comparison? >Looks like a bug to me. -Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130628/3d2d5b8f/attachment.html>
Richard Osborne
2013-Jun-28 15:20 UTC
[LLVMdev] Possible instruction combine bug with pointer icmp?
On 28/06/13 15:56, Eli Friedman wrote:> On Fri, Jun 28, 2013 at 6:13 AM, Richard Osborne <richard at xmos.com > <mailto:richard at xmos.com>> wrote: > > If I give instcombine the following IR: > > define i1 @f([1 x i8]* %a, [1 x i8]* %b) { > %c = getelementptr [1 x i8]* %a, i32 0, i32 0 > %d = getelementptr [1 x i8]* %b, i32 0, i32 0 > %cmp = icmp ult i8* %c, %d > ret i1 %cmp > } > > It optimizes it into: > > define i1 @f([1 x i8]* %a, [1 x i8]* %b) { > %cmp = icmp slt [1 x i8]* %a, %b > ret i1 %cmp > } > > Is this a bug, or are there some semantics of icmp or > getelementptr I'm missing that mean it's OK to change this from an > unsigned comparison to a signed comparison? > > > Looks like a bug to me. > > -EliThanks for confirming this, I've filed it as PR16483: http://llvm.org/PR16483 -- Richard Osborne | XMOS http://www.xmos.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130628/112c1a35/attachment.html>