@@ -239,3 +239,87 @@ define i32 @oneusecmp(i32 %a, i32 %b, i32 %d) {
239239 %x = add i32 %s , %s2
240240 ret i32 %x
241241}
242+
243+ define i32 @xor_branch_imm_ret (i32 %x ) {
244+ ; RV32-LABEL: xor_branch_imm_ret:
245+ ; RV32: # %bb.0: # %entry
246+ ; RV32-NEXT: li a1, -1365
247+ ; RV32-NEXT: beq a0, a1, .LBB11_2
248+ ; RV32-NEXT: # %bb.1: # %if.then
249+ ; RV32-NEXT: xori a0, a0, -1365
250+ ; RV32-NEXT: ret
251+ ; RV32-NEXT: .LBB11_2: # %if.end
252+ ; RV32-NEXT: addi sp, sp, -16
253+ ; RV32-NEXT: .cfi_def_cfa_offset 16
254+ ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
255+ ; RV32-NEXT: .cfi_offset ra, -4
256+ ; RV32-NEXT: call abort
257+ ;
258+ ; RV64-LABEL: xor_branch_imm_ret:
259+ ; RV64: # %bb.0: # %entry
260+ ; RV64-NEXT: sext.w a1, a0
261+ ; RV64-NEXT: li a2, -1365
262+ ; RV64-NEXT: beq a1, a2, .LBB11_2
263+ ; RV64-NEXT: # %bb.1: # %if.then
264+ ; RV64-NEXT: xori a0, a0, -1365
265+ ; RV64-NEXT: ret
266+ ; RV64-NEXT: .LBB11_2: # %if.end
267+ ; RV64-NEXT: addi sp, sp, -16
268+ ; RV64-NEXT: .cfi_def_cfa_offset 16
269+ ; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
270+ ; RV64-NEXT: .cfi_offset ra, -8
271+ ; RV64-NEXT: call abort
272+ entry:
273+ %cmp.not = icmp eq i32 %x , -1365
274+ br i1 %cmp.not , label %if.end , label %if.then
275+ if.then:
276+ %xor = xor i32 %x , -1365
277+ ret i32 %xor
278+ if.end:
279+ tail call void @abort () #2
280+ unreachable
281+ }
282+
283+ define i32 @xor_branch_ret (i32 %x ) {
284+ ; RV32-LABEL: xor_branch_ret:
285+ ; RV32: # %bb.0: # %entry
286+ ; RV32-NEXT: li a1, 1
287+ ; RV32-NEXT: slli a1, a1, 11
288+ ; RV32-NEXT: beq a0, a1, .LBB12_2
289+ ; RV32-NEXT: # %bb.1: # %if.then
290+ ; RV32-NEXT: xor a0, a0, a1
291+ ; RV32-NEXT: ret
292+ ; RV32-NEXT: .LBB12_2: # %if.end
293+ ; RV32-NEXT: addi sp, sp, -16
294+ ; RV32-NEXT: .cfi_def_cfa_offset 16
295+ ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
296+ ; RV32-NEXT: .cfi_offset ra, -4
297+ ; RV32-NEXT: call abort
298+ ;
299+ ; RV64-LABEL: xor_branch_ret:
300+ ; RV64: # %bb.0: # %entry
301+ ; RV64-NEXT: sext.w a2, a0
302+ ; RV64-NEXT: li a1, 1
303+ ; RV64-NEXT: slli a1, a1, 11
304+ ; RV64-NEXT: beq a2, a1, .LBB12_2
305+ ; RV64-NEXT: # %bb.1: # %if.then
306+ ; RV64-NEXT: xor a0, a0, a1
307+ ; RV64-NEXT: ret
308+ ; RV64-NEXT: .LBB12_2: # %if.end
309+ ; RV64-NEXT: addi sp, sp, -16
310+ ; RV64-NEXT: .cfi_def_cfa_offset 16
311+ ; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
312+ ; RV64-NEXT: .cfi_offset ra, -8
313+ ; RV64-NEXT: call abort
314+ entry:
315+ %cmp.not = icmp eq i32 %x , 2048
316+ br i1 %cmp.not , label %if.end , label %if.then
317+ if.then:
318+ %xor = xor i32 %x , 2048
319+ ret i32 %xor
320+ if.end:
321+ tail call void @abort () #2
322+ unreachable
323+ }
324+
325+ declare void @abort ()
0 commit comments