[llvm-bugs] [Bug 42399] InstCombine: shift amount reassociation when doing bit test

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 23 14:14:38 PDT 2019


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

Roman Lebedev <lebedev.ri at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
             Status|RESOLVED                    |REOPENED

--- Comment #5 from Roman Lebedev <lebedev.ri at gmail.com> ---
... and it wasn't enough.

; Function Attrs: norecurse nounwind readnone
define i1 @test(i64 %storage, i32 %nbits) local_unnamed_addr #0 {
bb:
  %skipnbits = sub nsw i32 64, %nbits
  %skipnbitswide = zext i32 %skipnbits to i64
  %datawide = lshr i64 %storage, %skipnbitswide
  %data = trunc i64 %datawide to i32
  %nbitsminusone = add nsw i32 %nbits, -1
  %bitmask = shl i32 1, %nbitsminusone
  %bitmasked = and i32 %bitmask, %data
  %isbitunset = icmp eq i32 %bitmasked, 0
  ret i1 %isbitunset
}

attributes #0 = { norecurse nounwind readnone }

Name: PR42399
  %skipnbits = sub nsw i32 64, %nbits
  %skipnbitswide = zext i32 %skipnbits to i64
  %datawide = lshr i64 %storage, %skipnbitswide
  %data = trunc i64 %datawide to i32
  %nbitsminusone = add nsw i32 %nbits, -1
  %bitmask = shl i32 1, %nbitsminusone
  %bitmasked = and i32 %bitmask, %data
  %isbitunset = icmp eq i32 %bitmasked, 0
=>
  %isbitunset = icmp sgt i64 %storage, -1

https://rise4fun.com/Alive/hUu

-- 
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/20190723/90c0c877/attachment.html>


More information about the llvm-bugs mailing list