1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \ 3; RUN: | FileCheck %s -check-prefix=RV32I 4 5; TODO: lbu and lhu should be selected to avoid the unnecessary masking. 6 7@bytes = global [5 x i8] zeroinitializer, align 1 8 9define i32 @test_zext_i8() nounwind { 10; RV32I-LABEL: test_zext_i8: 11; RV32I: # %bb.0: # %entry 12; RV32I-NEXT: lui a0, %hi(bytes) 13; RV32I-NEXT: lbu a1, %lo(bytes)(a0) 14; RV32I-NEXT: addi a0, a0, %lo(bytes) 15; RV32I-NEXT: lbu a0, 1(a0) 16; RV32I-NEXT: xori a1, a1, 136 17; RV32I-NEXT: xori a0, a0, 7 18; RV32I-NEXT: or a0, a1, a0 19; RV32I-NEXT: bnez a0, .LBB0_2 20; RV32I-NEXT: # %bb.1: # %if.end 21; RV32I-NEXT: mv a0, zero 22; RV32I-NEXT: ret 23; RV32I-NEXT: .LBB0_2: # %if.then 24; RV32I-NEXT: addi a0, zero, 1 25; RV32I-NEXT: ret 26entry: 27 %0 = load i8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @bytes, i32 0, i32 0), align 1 28 %cmp = icmp eq i8 %0, -120 29 %1 = load i8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @bytes, i32 0, i32 1), align 1 30 %cmp3 = icmp eq i8 %1, 7 31 %or.cond = and i1 %cmp, %cmp3 32 br i1 %or.cond, label %if.end, label %if.then 33 34if.then: 35 ret i32 1 36 37if.end: 38 ret i32 0 39} 40 41@shorts = global [5 x i16] zeroinitializer, align 2 42 43define i32 @test_zext_i16() nounwind { 44; RV32I-LABEL: test_zext_i16: 45; RV32I: # %bb.0: # %entry 46; RV32I-NEXT: lui a0, %hi(shorts) 47; RV32I-NEXT: lhu a1, %lo(shorts)(a0) 48; RV32I-NEXT: addi a0, a0, %lo(shorts) 49; RV32I-NEXT: lhu a0, 2(a0) 50; RV32I-NEXT: lui a2, 16 51; RV32I-NEXT: addi a2, a2, -120 52; RV32I-NEXT: xor a1, a1, a2 53; RV32I-NEXT: xori a0, a0, 7 54; RV32I-NEXT: or a0, a1, a0 55; RV32I-NEXT: bnez a0, .LBB1_2 56; RV32I-NEXT: # %bb.1: # %if.end 57; RV32I-NEXT: mv a0, zero 58; RV32I-NEXT: ret 59; RV32I-NEXT: .LBB1_2: # %if.then 60; RV32I-NEXT: addi a0, zero, 1 61; RV32I-NEXT: ret 62entry: 63 %0 = load i16, i16* getelementptr inbounds ([5 x i16], [5 x i16]* @shorts, i32 0, i32 0), align 2 64 %cmp = icmp eq i16 %0, -120 65 %1 = load i16, i16* getelementptr inbounds ([5 x i16], [5 x i16]* @shorts, i32 0, i32 1), align 2 66 %cmp3 = icmp eq i16 %1, 7 67 %or.cond = and i1 %cmp, %cmp3 68 br i1 %or.cond, label %if.end, label %if.then 69 70if.then: 71 ret i32 1 72 73if.end: 74 ret i32 0 75} 76