[llvm-bugs] [Bug 43820] New: llvm.bitreverse.i1000 asserts "Invalid use of small shift amount with oversized value!""

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 26 15:07:20 PDT 2019


            Bug ID: 43820
           Summary: llvm.bitreverse.i1000 asserts "Invalid use of small
                    shift amount with oversized value!""
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: m.gehre at gmx.de
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com


target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i1000 @square(i1000 %A) {
  %Z = call i1000 @llvm.bitreverse.i1000(i1000 %A)
  ret i1000 %Z

declare i1000 @llvm.bitreverse.i1000(i1000)

causes the assertion
llc: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5145: llvm::SDValue
llvm::SelectionDAG::getNode(unsigned int, const llvm::SDLoc &, llvm::EVT,
llvm::SDValue, llvm::SDValue, const llvm::SDNodeFlags): Assertion
`N2.getValueSizeInBits() >= Log2_32_Ceil(N1.getValueSizeInBits()) && "Invalid
use of small shift amount with oversized value!"' failed.
Stack dump:
0.      Program arguments: ./build/bin/llc test1000.ll 
1.      Running pass 'Function Pass Manager' on module
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@square'
 #0 0x000000000205f714 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
 #1 0x000000000205f714 PrintStackTraceSignalHandler(void*)
 #2 0x000000000205d41e llvm::sys::RunSignalHandlers()
 #3 0x000000000205fb28 SignalHandler(int)
 #4 0x00007ffff7bc8890 __restore_rt
 #5 0x00007ffff689be97 raise
 #6 0x00007ffff689d801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #7 0x00007ffff688d39a __assert_fail_base
 #8 0x00007ffff688d412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #9 0x0000000001e881e5 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc
const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags)
#10 0x0000000001f33fab
#11 0x0000000001f32cb7
llvm::DAGTypeLegalizer::PromoteIntegerResult(llvm::SDNode*, unsigned int)

when running it through llc.

>From looking at it, getShiftAmountTyForConstant tries to avoid the assertion by
increasing the type of the shift amount based on how big the actual shift
amount is, but the assert in SelectionDAG checks if the type is big enough to
hold all possible shift amounts.
In the example above, the actual shift amount is 24 (promoting i1000 to i1024),
so i8 is enough to hold 24. Still SelectionDAG asserts because i8 cannot hold
all possible shift values of an i1000.

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/20191026/1a1826b5/attachment.html>

More information about the llvm-bugs mailing list