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

            Bug ID: 33470
           Summary: EarlyCSE/computeKnownBits regression - assume of xor
                    i1 true, %val is being removed
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Global Analyses
          Assignee: unassignedb...@nondot.org
          Reporter: arie...@mail.tau.ac.il
                CC: llvm-bugs@lists.llvm.org

It seems that LLVM trunk's early-cse is spuriously removing calls to
`llvm.assume(xor %val, 1)`. This can prevent further optimizations downstream.

This seems to occur because computeKnownBits sees that because of the assume,
the condition must be true, and therefore `%val` must be false. This is sound
but of course kills the assume. There's an `isEphemeralValueOf` check which is
supposed to prevent this situation, but it is not working.

## Meta

Verified locally on r304178. Verified not to occur on Rust's branch of 4.0.

## STR

--
; RUN: opt -S -early-cse < %s | FileCheck %s
declare i1 @food()
declare void @llvm.assume(i1)

define void @hungry() {
; CHECK-LABEL: @hungry
entry-block:
  %0 = call i1 @food()
; CHECK: call void @llvm.assume
  %1 = xor i1 %0, true
  call void @llvm.assume(i1 %1)
  ret void
}
--

## Expected Results

The code should remain as-is - there is nothing to simplify.

## Actual Results

The code is optimized into this assume-less version:

--
; ModuleID = '<stdin>'
source_filename = "<stdin>"

declare i1 @food()

; Function Attrs: nounwind
declare void @llvm.assume(i1) #0

define void @hungry() {
entry-block:
  %0 = call i1 @food()
  ret void
}
---

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

Reply via email to