Wrong value for sext i1 true in BasicAliasAnalysis

Yin Ma yinma at codeaurora.org
Wed Dec 10 10:54:42 PST 2014


Hi Hal,

I have created a simple test case for this case.
opt -basicaa -gvn -S q.ll 

q.bad.ll shows the problem 
loop.exit:                                        ; preds = %loop.body, %loop.body.2
  store i32 %inc.i7 <-- %inc.i7 is the wrong value because
AA mistakenly compute the GEP due to sext the i1 true.

Please take a look.

Thanks,

Yin 
-----Original Message-----
From: Hal Finkel [mailto:hfinkel at anl.gov] 
Sent: Tuesday, December 09, 2014 10:21 AM
To: Yin Ma
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: Wrong value for sext i1 true in BasicAliasAnalysis

Hi Yin,

Do you have a test case for this? I don't understand where this special case comes from. And if we do have a special case here, it seems this should be noted in the LangRef (which currently says only, "If the offsets have a different width from the pointer, they are sign-extended or truncated to the width of the pointer."). And, in fact, the LangRef documentation for the sext instructions says, "When sign extending from i1, the extension always results in -1 or 0."

Thanks again,
Hal

----- Original Message -----
> From: "Yin Ma" <yinma at codeaurora.org>
> To: llvm-commits at cs.uiuc.edu
> Cc: hfinkel at anl.gov
> Sent: Monday, December 8, 2014 4:49:34 PM
> Subject: Wrong value for sext i1 true in BasicAliasAnalysis
> 
> 
> 
> 
> Hi Hal,
> 
> 
> 
> How are you doing. For your patch db1e51359, you changed offset 
> computation
> 
> from zext to sext. However, I came across a case that expression 
> contains i1 true to i32.
> 
> true is value 1 for offset. if it is sext to 32bit, the result of sext 
> will not be 1. Instead, it will
> 
> be -1. Sext true is a special case. This will make AA check failed 
> when one GEP contains
> 
> i1 true to i32 expression but the other GEP doesn’t.
> 
> 
> 
> I attached my change. How do you think? If it is valid patch, please 
> merge it to the tip.
> 
> 
> 
> Thanks,
> 
> 
> 
> Yin

--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
-------------- next part --------------
A non-text attachment was scrubbed...
Name: q.ll
Type: application/octet-stream
Size: 1625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141210/90586f3c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: q.bad.ll
Type: application/octet-stream
Size: 1638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141210/90586f3c/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sext_true.diff
Type: application/octet-stream
Size: 850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141210/90586f3c/attachment-0002.obj>


More information about the llvm-commits mailing list