[LLVMdev] predicates and conditional execution

Rotem, Nadav nadav.rotem at intel.com
Tue May 24 03:47:39 CDT 2011

Hi Roy, 

The LLVM IR does not support predicated instructions. However, it is possible to generate predicated assembly code. The x86 CMov instruction is one example.

I assume that your input program is not predicated and you are trying to use the unique features of your architecture, which has instruction predication.

I can think of several ways to implement this for your backend:

1. You can implement custom lowering to specific operations. The X86TargetLowering::LowerSELECT method in the X86 backend lowers the SELECT instruction to CMOV in many cases.
2. You can implement DAG combining optimizations for your backend which detect interesting patterns.
3. In some cases you can implement codegen patterns (in the td files). I suspect that this will be more difficult to implement and you will have to use #1 or #2.
4. If you are writing a domain specific language, you can generate intrinsic in your LLVM-IR.


-----Original Message-----
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of roy rosen
Sent: Tuesday, May 24, 2011 10:03
To: llvmdev at cs.uiuc.edu
Subject: [LLVMdev] predicates and conditional execution


I was wondering if LLVM supports predicates and conditional execution.
Something like we have in IA64.
There is a register class of predicates and then every instruction may
be predicated by a register from this class.
For example:

cmp_less p, x, y // p is a predicate which gets the result of x < y
p add x, x, 2 // if p then do the add instruction

Is there support in LLVM to something like that?
Which architecture can show a good example for the implementation of that?

Thanks, Roy.
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

More information about the LLVMdev mailing list