[llvm-bugs] [Bug 39578] New: redundant mask op could be eliminated

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 7 06:02:24 PST 2018


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

            Bug ID: 39578
           Summary: redundant mask op could be eliminated
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org

Forking this off from bug 29009:

define void @redundant_mask(i32 %x, i32* %st1, i8* %st2) {
  %and1 = and i32 %x, 7
  store i32 %and1, i32* %st1
  %conv = trunc i32 %x to i8
  %and2 = and i8 %conv, 7
  store i8 %and2, i8* %st2
  ret void
}

We (GVN?) should be able to recognize that the 2nd 'and' can be removed to
reduce the IR:

define void @no_redundant_mask(i32 %x, i32* %st1, i8* %st2) {
  %and1 = and i32 %x, 7
  store i32 %and1, i32* %st1
  %conv2 = trunc i32 %and1 to i8
  store i8 %conv2, i8* %st2
  ret void
}


%and1 = and i32 %x, 7
store i32 %and1, i32* %p
%conv = trunc i32 %x to i8
%r = and i8 %conv, 7
  =>
%and1 = and i32 %x, 7
store i32 %and1, i32* %p
%r = trunc i32 %and1 to i8

https://rise4fun.com/Alive/JGb

-- 
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/20181107/8273046f/attachment.html>


More information about the llvm-bugs mailing list