Skip to content

Commit 7d6a772

Browse files
committed
Add new test that re-produces issue #130510
1 parent e931708 commit 7d6a772

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

llvm/test/CodeGen/RISCV/select-constant-xor.ll

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,86 @@ if.end:
274274
unreachable
275275
}
276276

277+
define i32 @xor_branch_imm_ret(i32 %x) {
278+
; RV32-LABEL: xor_branch_imm_ret:
279+
; RV32: # %bb.0: # %entry
280+
; RV32-NEXT: li a1, -1365
281+
; RV32-NEXT: beq a0, a1, .LBB12_2
282+
; RV32-NEXT: # %bb.1: # %if.then
283+
; RV32-NEXT: xori a0, a0, -1365
284+
; RV32-NEXT: ret
285+
; RV32-NEXT: .LBB12_2: # %if.end
286+
; RV32-NEXT: addi sp, sp, -16
287+
; RV32-NEXT: .cfi_def_cfa_offset 16
288+
; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
289+
; RV32-NEXT: .cfi_offset ra, -4
290+
; RV32-NEXT: call abort
291+
;
292+
; RV64-LABEL: xor_branch_imm_ret:
293+
; RV64: # %bb.0: # %entry
294+
; RV64-NEXT: sext.w a1, a0
295+
; RV64-NEXT: li a2, -1365
296+
; RV64-NEXT: beq a1, a2, .LBB12_2
297+
; RV64-NEXT: # %bb.1: # %if.then
298+
; RV64-NEXT: xori a0, a0, -1365
299+
; RV64-NEXT: ret
300+
; RV64-NEXT: .LBB12_2: # %if.end
301+
; RV64-NEXT: addi sp, sp, -16
302+
; RV64-NEXT: .cfi_def_cfa_offset 16
303+
; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
304+
; RV64-NEXT: .cfi_offset ra, -8
305+
; RV64-NEXT: call abort
306+
entry:
307+
%cmp.not = icmp eq i32 %x, -1365
308+
br i1 %cmp.not, label %if.end, label %if.then
309+
if.then:
310+
%xor = xor i32 %x, -1365
311+
ret i32 %xor
312+
if.end:
313+
tail call void @abort() #2
314+
unreachable
315+
}
316+
317+
define i32 @xor_branch_ret(i32 %x) {
318+
; RV32-LABEL: xor_branch_ret:
319+
; RV32: # %bb.0: # %entry
320+
; RV32-NEXT: li a1, 1
321+
; RV32-NEXT: slli a1, a1, 11
322+
; RV32-NEXT: beq a0, a1, .LBB13_2
323+
; RV32-NEXT: # %bb.1: # %if.then
324+
; RV32-NEXT: xor a0, a0, a1
325+
; RV32-NEXT: ret
326+
; RV32-NEXT: .LBB13_2: # %if.end
327+
; RV32-NEXT: addi sp, sp, -16
328+
; RV32-NEXT: .cfi_def_cfa_offset 16
329+
; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
330+
; RV32-NEXT: .cfi_offset ra, -4
331+
; RV32-NEXT: call abort
332+
;
333+
; RV64-LABEL: xor_branch_ret:
334+
; RV64: # %bb.0: # %entry
335+
; RV64-NEXT: sext.w a2, a0
336+
; RV64-NEXT: li a1, 1
337+
; RV64-NEXT: slli a1, a1, 11
338+
; RV64-NEXT: beq a2, a1, .LBB13_2
339+
; RV64-NEXT: # %bb.1: # %if.then
340+
; RV64-NEXT: xor a0, a0, a1
341+
; RV64-NEXT: ret
342+
; RV64-NEXT: .LBB13_2: # %if.end
343+
; RV64-NEXT: addi sp, sp, -16
344+
; RV64-NEXT: .cfi_def_cfa_offset 16
345+
; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
346+
; RV64-NEXT: .cfi_offset ra, -8
347+
; RV64-NEXT: call abort
348+
entry:
349+
%cmp.not = icmp eq i32 %x, 2048
350+
br i1 %cmp.not, label %if.end, label %if.then
351+
if.then:
352+
%xor = xor i32 %x, 2048
353+
ret i32 %xor
354+
if.end:
355+
tail call void @abort() #2
356+
unreachable
357+
}
358+
277359
declare void @abort()

0 commit comments

Comments
 (0)