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

            Bug ID: 23055
           Summary: Simplify store values that can be proven constant
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Created attachment 14110
  --> https://llvm.org/bugs/attachment.cgi?id=14110&action=edit
Minimum reproducing example

InstCombiner successfully simplifies return values when they can be proven
constant, but misses the same optimization opportunity for store values. This
is illustrated in the attached minimum reproducing example:

  ; ModuleID = 'simplify_constant_store.ll'

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

  ; Function Attrs: nounwind
  define i32 @convert_grayscale(i32, i32* nocapture) #0 {
  entry:
    %2 = icmp eq i32 %0, 3
    tail call void @llvm.assume(i1 %2)
    %3 = add nuw nsw i32 %0, 1
    store i32 %3, i32* %1, align 4
    ret i32 %3
  }

  attributes #0 = { nounwind }

`ret i32 %3` is correctly simplified to `ret i32 4`. `store i32 %3, i32* %1,
align 4` could be simplified to `store i32 4, i32* %1, align 4`, but is not.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to