[PATCH] Added llvm.is.constant intrinsic

Janusz Sobczak janusz.sobczak at mobica.com
Wed Jun 25 07:05:47 PDT 2014


I agree that we should have more tests. I'd prefer to have an agreement that we want to add llvm.is.constant intrinsic before spending too much time on writing tests.

A follow up work is to add support for the new intrinsic in clang (__builtin_constant_p -> llvm.is.constant) and write more tests in C.

I have a few questions.
1. Do we want the code to promote or expand llvm.is.constant? On one hand it would make the code more complete but on the other it is not really required because zext() and trunc() don't change the 'constantness'

```
	%a = zext i1 %b to i32
	%v = call i1 @llvm.is.constant.i32(i32 %a)

```
and

```
	%a = trunc i256 %b to i32
	%v = call i1 @llvm.is.constant.i32(i32 %a)
```
will do the job. Is there a preference in the llvm community?
2. In my implementation llvm.is.constant is lowered to true/false rather late. Would it help in some cases if we added an early check in InstCombine? InstCombine would lower llvm.is.constant to true if the argument is known to be constant. Otherwise InstCombine would leave it unmodified.

http://reviews.llvm.org/D4276






More information about the llvm-commits mailing list