miscompile: miscompile rv32: addi,andi,beq,beqz,bltu,bltz

Run:explore-d9924131a4-20261128-105811
Kind:miscompile
Category:miscompile rv32: addi,andi,beq,beqz,bltu,bltz M
Occurrences:1 in 1 configs, 1 test files
Snippet from:readcyclecounter.bff0a056.1f6bbc8398.ll (mutant of readcyclecounter.bff0a056.ll) @test_builtin_readcyclecounter via llvm-extract
Config:-mtriple=riscv32 -verify-machineinstrs -mattr=+f,+zba -O0
Local check:reproduces at d9924131a4
Compiler Explorer:not applicable: Compiler Explorer compiles RISC-V but cannot run it

Snippet:

@G = external global i64
@G.1 = external global i1
@G.2 = external global i1
@G.3 = external global ptr

; Function Attrs: nounwind
define i64 @test_builtin_readcyclecounter() #0 {
  %A15 = alloca i1, align 1
  store i1 false, ptr %A15, align 1
  %A12 = alloca i1, align 1
  store i1 false, ptr %A12, align 1
  %A8 = alloca i1, align 1
  store i1 false, ptr %A8, align 1
  %A = alloca i1, align 1
  store i1 true, ptr %A, align 1
  %LGV = load i64, ptr @G, align 4
  switch i64 %LGV, label %SW_D [
    i64 4303199021846014237, label %SW_C
    i64 2825014246696475366, label %SW_C1
    i64 -1124663481073590762, label %SW_C2
    i64 -126088060032052412, label %SW_C3
    i64 5381856492718128585, label %SW_C4
    i64 -1449714065303366033, label %SW_C5
    i64 -3830871222338784181, label %SW_C6
    i64 8167191317104177415, label %SW_C7
  ]

BB:                                               ; preds = %SW_C6, %SW_C5, %SW_C4, %SW_C2, %SW_C1, %SW_C, %SW_D
  %1 = tail call i64 @llvm.readcyclecounter()
  %B = ashr i64 %1, %1
  ret i64 %B

SW_D:                                             ; preds = %SW_D, %0
  %C = icmp eq i64 %LGV, %LGV
  %L = load i1, ptr %A, align 1
  store i1 %C, ptr %A15, align 1
  br i1 %L, label %BB, label %SW_D

SW_C:                                             ; preds = %SW_C, %0
  %L9 = load i1, ptr %A8, align 1
  br i1 %L9, label %SW_C, label %BB

SW_C1:                                            ; preds = %0
  br label %BB

SW_C2:                                            ; preds = %SW_C2, %0
  %LGV10 = load i1, ptr @G.1, align 1
  br i1 %LGV10, label %BB, label %SW_C2

SW_C3:                                            ; preds = %0
  %G = getelementptr bfloat, ptr %A8, i64 %LGV
  store ptr %G, ptr @G.3, align 8
  ret i64 0

SW_C4:                                            ; preds = %SW_C4, %0
  %LGV11 = load i1, ptr @G.2, align 1
  br i1 %LGV11, label %BB, label %SW_C4

SW_C5:                                            ; preds = %SW_C5, %0
  %L13 = load i1, ptr %A12, align 1
  br i1 %L13, label %SW_C5, label %BB

SW_C6:                                            ; preds = %SW_C6, %0
  %L16 = load i1, ptr %A15, align 1
  br i1 %L16, label %BB, label %SW_C6

SW_C7:                                            ; preds = %0
  ret i64 %LGV
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare i64 @llvm.readcyclecounter() #1

attributes #0 = { nounwind }
attributes #1 = { nocallback nofree nosync nounwind willreturn }

Reproduce:

./exec_oracle.py --flags '-mtriple=riscv32 -verify-machineinstrs -mattr=+f,+zba -O0' --funcs test_builtin_readcyclecounter snippet.ll

Local execution result:

3 of 64 inputs differ (first: #40)
SelectionDAG hash 24f417568af5bdf5, GlobalISel hash 405961e682a50ffa
b0: llc -mtriple=riscv32 -verify-machineinstrs -mattr=+f,+zba -O0 -global-isel=0
b1: llc -mtriple=riscv32 -verify-machineinstrs -mattr=+f,+zba -O2 -global-isel=0
b2: llc -mtriple=riscv32 -verify-machineinstrs -mattr=+f,+zba -O0 -global-isel -global-isel-abort=2

Occurrences (1):

InputFunctionConfig
readcyclecounter.bff0a056.1f6bbc8398.ll (mutant of readcyclecounter.bff0a056.ll)test_builtin_readcyclecounter-mtriple=riscv32 -verify-machineinstrs -mattr=+f,+zba -O0

Generated 2026-11-29 14:49 UTC.