[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

Juneyoung Lee via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 11 01:31:51 PDT 2020


aqjune added a comment.

Seems like a bug in instsimplify:

  define i1 @f(i32 %x, i32 %y) {
    %cmp9.not.1 = icmp eq i32 %x, %y
    %cmp15      = icmp slt i32 %x, %y
    %spec.select39 = select i1 %cmp9.not.1, i1 undef, i1 %cmp15
    %spec.select40 = xor i1 %cmp9.not.1, 1
    %spec.select  = and i1 %spec.select39, %spec.select40
    ret i1 %spec.select
  }
  =>
  define i1 @f(i32 %x, i32 %y) {
    %cmp9.not.1 = icmp eq i32 %x, %y
    %cmp15 = icmp slt i32 %x, %y
    %spec.select39 = select i1 %cmp9.not.1, i1 undef, i1 %cmp15
    ret i1 %spec.select39
  }

https://godbolt.org/z/a8f7hT

Alive2 says it's incorrect: https://alive2.llvm.org/ce/z/-8Q4HL

Seems to be related with ValueTracking's isImpliedCondition since this optimizations happens only when operands of the two icmps are the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360





More information about the cfe-commits mailing list