[PATCH] D90231: [GVN] Don't replace argument to @llvm.is.constant.*()

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 28 02:09:33 PDT 2020


lebedev.ri added a comment.

In D90231#2358421 <https://reviews.llvm.org/D90231#2358421>, @jonpa wrote:

>> Was semantics of LLVM's @llvm.is.constant defined in some document since the last time @llvm.is.constant patch?
>
> I see in the reference manual: "If its argument is known to be a manifest compile-time constant value, then the intrinsic will be converted to a constant true value. Otherwise, it will be converted to a constant false value..."  So clearly, having GVN turn this into a run-time check is wrong.

I'm sorry, i do not understand. Is the test case over-reduced?
In `land.rhs` BB, `%shl` *is* constant, and therefore the folding happens:

  $ ./bin/opt -gvn /tmp/test.ll -debug
  Args: ./bin/opt -gvn /tmp/test.ll -debug 
  WARNING: You're attempting to print out a bitcode file.
  This is inadvisable as it may cause display problems. If
  you REALLY want to taste LLVM bitcode first-hand, you
  can force output with the `-f' option.
  
  GVN iteration: 0
  GVN: load i32 %0 has unknown dependence
  Replace dominated use of 'shl' as i32 0 in i32 0
  GVN removed:   %2 = tail call i1 @llvm.is.constant.i32(i32 0)
  GVN removed:   %phi.cast = zext i1 true to i32
  GVN iteration: 1
  GVN: load i32 %0 has unknown dependence


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90231/new/

https://reviews.llvm.org/D90231



More information about the llvm-commits mailing list