[LLVMdev] InstCombine "pessimizes" trunc i8 to i1?

Chris Lattner clattner at apple.com
Wed Dec 28 00:18:50 PST 2011


On Dec 27, 2011, at 5:09 AM, Jochen Wilhelmy wrote:

> Hi!
> 
> before InstCombine (llvm::createInstructionCombiningPass()) I have
> a trunc from i8 to i1 and then a select:
> 
> %45 = load i8* @myGlobal, align 1
> %tobool = trunc i8 %45 to i1
> %cond = select i1 %tobool, float 1.000000e+00, float -1.000000e+00
> 
> after instCombine I have:
> 
> %29 = load i8* @myGlobal, align 1
> %30 = and i8 %29, 1
> %tobool = icmp ne i8 %30, 0
> %cond = select i1 %tobool, float 1.000000e+00, float -1.000000e+00
> 
> is this a bug or intended? My version is 3.0 release.
> Please tell me where I can remove this rule even if it is intended for 
> mainline.

This is intentional: an 'and' must be done in both cases, so this transformation is exposing it to the optimizer.

Why do you consider this to be a pessimization?  Does one produce inferior machine code?

-Chris



More information about the llvm-dev mailing list