https://bugs.llvm.org/show_bug.cgi?id=50425

            Bug ID: 50425
           Summary: instcombine transform ruins simplifycfg if-then to
                    select optimization
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: valery.n.dmitr...@intel.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

I recently encountered a case where instcombine transform
icmp (A-B), (C-B) -> icmp A, C
affects simplifycfg ability to fold if-then into a select.

Here is test case:
; begin
target triple = "x86_64-unknown-linux-gnu"

define dso_local void @foo(i32* %p1, i32* %p2, i32 %g, i32 %gh) {
entry:
  %i2 = load i32, i32* %p1, align 4
  %sub17 = sub nsw i32 %i2, %gh
  store i32 %sub17, i32* %p1, align 4
  %i3 = load i32, i32* %p2, align 4
  %i20 = add nsw i32 %i3, %g
  %sub21 = sub nsw i32 %i20, %gh
  %cmp24 = icmp slt i32 %sub17, %sub21
  br i1 %cmp24, label %if.then25, label %if.end28

if.then25:
  store i32 %sub21, i32* %p1, align 4
  br label %if.end28

if.end28:
  br label %end

end:
  ret void
}
; end

To reproduce compare
opt -S -instcombine -simplifycfg  test.ll
versus
opt -S -simplifycfg  test.ll

At first glance it may appear as if instcombine sinking creates an issue for
simplifycfg
but even with -instcombine-code-sinking=false option simplifycfg does not fold
if-then:

https://alive2.llvm.org/ce/z/sYXoZO

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to