<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/100855>100855</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [RISC-V] `Cannot select: t32: i32 = RISCVISD::CZERO_EQZ t25, t4` with xventanacondops
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          patrick-rivos
      </td>
    </tr>
</table>

<pre>
    C Testcase:
```c
long long a;
void b();
void c() { b(!0 > a); }
```
`./clang -march=rv32ixventanacondops red.c`

Testcase:
```llvm ir
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128"
target triple = "riscv32-unknown-linux-gnu"

define void @c(i64 %0) #0 {
entry:
  %cmp = icmp sgt i64 1, %0
  %conv = zext i1 %cmp to i32
  store i32 %conv, ptr null, align 4
  ret void
}

attributes #0 = { "target-features"="+32bit,+relax,+xventanacondops,-a,-b,-c,-d,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-f,-h,-m,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-ztso,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b" }
```

Command/backtrace:
```
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc reduced.ll
LLVM ERROR: Cannot select: t32: i32 = RISCVISD::CZERO_EQZ t25, t4
  t25: i32 = setcc t4, Constant:i32<0>, setlt:ch
    t4: i32,ch = CopyFromReg t0, Register:i32 %1
      t3: i32 = Register %1
    t10: i32 = Constant<0>
  t4: i32,ch = CopyFromReg t0, Register:i32 %1
 t3: i32 = Register %1
In function: c
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc reduced.ll
1.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.      Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@c'
 #0 0x00005edc1f7775f0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1dcf5f0)
 #1 0x00005edc1f774a0f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1dcca0f)
 #2 0x00005edc1f774b65 SignalHandler(int) Signals.cpp:0:0
 #3 0x0000788fe3c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000788fe3c969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x0000788fe3c969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x0000788fe3c969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x0000788fe3c42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x0000788fe3c287f3 abort ./stdlib/abort.c:81:7
 #9 0x00005edc1decdc5c llvm::UniqueStringSaver::save(llvm::StringRef) (.cold) StringSaver.cpp:0:0
#10 0x00005edc1f5013bb llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1b593bb)
#11 0x00005edc1f507519 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1b5f519)
#12 0x00005edc1e0b893f llvm::RISCVDAGToDAGISel::Select(llvm::SDNode*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x71093f)
#13 0x00005edc1f4fda84 llvm::SelectionDAGISel::DoInstructionSelection() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1b55a84)
#14 0x00005edc1f50d090 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1b65090)
#15 0x00005edc1f5105f6 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1b685f6)
#16 0x00005edc1f511f2f llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1b69f2f)
#17 0x00005edc1f502af9 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1b5aaf9)
#18 0x00005edc1e68ee97 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#19 0x00005edc1ecad616 llvm::FPPassManager::runOnFunction(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1305616)
#20 0x00005edc1ecad869 llvm::FPPassManager::runOnModule(llvm::Module&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x1305869)
#21 0x00005edc1ecae1c5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x13061c5)
#22 0x00005edc1df90b06 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#23 0x00005edc1ded5aee main (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x52daee)
#24 0x0000788fe3c29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#25 0x0000788fe3c29e40 call_init ./csu/../csu/libc-start.c:128:20
#26 0x0000788fe3c29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#27 0x00005edc1df873d5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc+0x5df3d5)
zsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/llc
```

Found via fuzzer.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWt1y2ziyfhr6BiUVCf7qwheyZOWkKjnJsXNStXPjAgFQwhoEaQCkZT39Fn5IkYoymd2p8WxVAnxoNJr9AQ2wQRkpxfaC0tsgvQvS7Q3q9KGRty3SkuHnhWR9o27KhrzdbsA3qjRGigbxOgi3QbgOstD9w67NG7EHtkBBfOdkfcMIKANYBHA1F2InBEF-5xWiEATxPUBOFQT59uI5Y3MZwB3mSOzBokYSH4J4K_sYsmNPhUYC4UaQplVAUrLE54G2_DkNzvsaMOmkGsk91YAgjTh6azoNgngLAgjpog7iNV20QbyOoS0WLEuCeJ0lCxHDxWNkyMCZGS1Zy-lgQjKF-xguOvEsmlex4Ex0x8VedOMwVxJaMUGBna4gCc2MsSwBAUxDO3MwDs30OWUqtHwbSQGjhevWPpIZoPYamNFRADfOxESxEb3VPNGjBiwaBusGsBgOiko3khrBMMRYarUEouPcYMTZXoBk0JdUW989pXE5bYm0lqzsNFWeh5ma_M5Mj5uzRUWR7iRVZlLirSnhXQxLpgO4CeCdpBwdHbxY9gBuFsgUpSmwKYgpqC2OLZWsNgP4QtV1W1-RimtSdV16VfjSKEZ-lHdXlE8II3VFypGSP4oZrhhvr8uVNVOZ4mAK-yx1wE0nNJVUvLr2HukWOah7xD3s1Vncq1mH7im2ZFSNmJPWmFBO9x4ryYRXoG3dOqQ00pQK21DDOIVxtR9Qq6WHTdXW1YBn3qqJcTUzqcwRpR3W2Nej2xOnVZclR25hjwgdQOdAiaQXMdEjryZQ2zjTfVvWFplgXxxxj3jnUclGoGskW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