[LLVMdev] A pass to minimize instruction bitwidth?

Duncan Sands baldrick at free.fr
Thu Sep 1 00:08:42 PDT 2011


Hi Andrew,

> Does llvm have a pass that minimizes the bitwidth of llvm instructions?

Douglas do Couto Teixeira and Fernando Magno Quintao Pereira implemented
such a pass already, but it didn't get into LLVM (yet).  One reason is the
lack of interest from most LLVM users for this.  So if you are interested,
perhaps you can help them get their work incorporated into LLVM.

Ciao, Duncan.

> For instance:
>
>    %8 = and i32 %7, 63
>
> 63 is 111111 in binary. So the 'and' instruction only requires 6 bits.
>
> We could rewrite the above code as:
>    %8 = trunc i32 %7 to i6
>    %9 = and i6 %8, 63
>
> Since we only need the lower 6 bits we could also propagate this
> change backwards to reduce the bitwidth of prior instructions.
> I'm synthesizing hardware from LLVM IR so these non-standard bitwidths
> can actually save chip area.
> I've started writing a pass to do this but I figured there might be an
> existing pass for downcasting 64-bit operations to 32-bit operations
> that I could borrow code from.
>
> Thanks,
> Andrew
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list