[PATCH] D134954: [InstCombine] Switch foldOpIntoPhi() to use InstSimplify

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 01:57:47 PDT 2022


nikic added a comment.

Reduced test case:

  define void @test(ptr %ptr.base, i64 %n) {
  entry:
    %ptr.end = getelementptr inbounds i8, ptr %ptr.base, i64 %n
    br label %loop
  
  loop:
    %ptr = phi ptr [ %ptr.next, %latch ], [ %ptr.base, %entry ]
    %phi = phi i1 [ %cmp, %latch ], [ true, %entry ]
    %v = load i8, ptr %ptr, align 1
    %cmp = icmp eq i8 %v, 95
    br i1 %cmp, label %latch, label %if
  
  if:
    %sel = select i1 %phi, i8 117, i8 100
    call void @use(i8 %sel)
    br label %latch
  
  latch:
    %ptr.next = getelementptr inbounds i8, ptr %ptr, i64 1
    %cmp.i.not = icmp eq ptr %ptr.next, %ptr.end
    br i1 %cmp.i.not, label %exit, label %loop
  
  exit:
    ret void
  }
  
  declare void @use(i8)

This is indeed a problem with the context instruction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134954



More information about the llvm-commits mailing list