[llvm-bugs] [Bug 33470] New: EarlyCSE/computeKnownBits regression - assume of xor i1 true, %val is being removed

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 15 10:23:18 PDT 2017


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: unassignedbugs at nondot.org
          Reporter: arielb1 at mail.tau.ac.il
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170615/85b5dcd8/attachment.html>


More information about the llvm-bugs mailing list