<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Dec 29, 2011, at 10:52 AM, Reid Kleckner wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I think Chris is saying that the and is necessary because with your i1 trunc you're ignoring all of the high bits. The and implements that. If you don't want this behavior, don't generate the trunc in the first place and just compare the full width to zero.</blockquote><div><br></div><div>Right. Turning this into "myGlobal ? 1.0f : -1.0f" is not correct.</div><div><br></div><div>-Chris</div><br><blockquote type="cite"><div>
<br></div><div>Reid<br><br><div class="gmail_quote">On Wed, Dec 28, 2011 at 6:45 AM, Jochen Wilhelmy <span dir="ltr"><<a href="mailto:j.wilhelmy@arcor.de" target="_blank">j.wilhelmy@arcor.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br>
>> Hi!<br>
>><br>
>> before InstCombine (llvm::createInstructionCombiningPass()) I have<br>
>> a trunc from i8 to i1 and then a select:<br>
>><br>
>> %45 = load i8* @myGlobal, align 1<br>
>> %tobool = trunc i8 %45 to i1<br>
>> %cond = select i1 %tobool, float 1.000000e+00, float -1.000000e+00<br>
>><br>
>> after instCombine I have:<br>
>><br>
>> %29 = load i8* @myGlobal, align 1<br>
>> %30 = and i8 %29, 1<br>
>> %tobool = icmp ne i8 %30, 0<br>
>> %cond = select i1 %tobool, float 1.000000e+00, float -1.000000e+00<br>
>><br>
>> is this a bug or intended? My version is 3.0 release.<br>
>> Please tell me where I can remove this rule even if it is intended for<br>
>> mainline.<br>
> This is intentional: an 'and' must be done in both cases, so this transformation is exposing it to the optimizer.<br>
><br>
> Why do you consider this to be a pessimization? Does one produce inferior machine code?<br>
<br>
</div>I consider it a pessimization as it is one additional instruction and<br>
I'm mainly interested in target<br>
independent optimizations because I regenerate highlevel code from it<br>
("Exporting 3D scenes from Maya to WebGL using clang and llvm").<br>
For example from the given code before the transformation I can easily<br>
regenerate<br>
myGlobal ? 1.0f : -1.0f<br>
while after the transformation I get<br>
(myGlobal & 1) != 0 ? 1.0f : -1.0f<br>
which is not good for shading languages.<br>
<br>
So I can remove the transformation in my local copy (I found it by now)<br>
or if it would be possible to<br>
move it into the optimizer that needs it this would be benificial for me.<br>
<span><font color="#888888"><br>
-Jochen<br>
</font></span><div><div><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>
</blockquote></div><br></body></html>