|
| 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 | + |
| 9 | +define i32 @test_zext_i8() { |
| 10 | +; RV32I-LABEL: test_zext_i8: |
| 11 | +; RV32I: # %bb.0: # %entry |
| 12 | +; RV32I-NEXT: lui a0, %hi(bytes) |
| 13 | +; RV32I-NEXT: lbu a0, %lo(bytes)(a0) |
| 14 | +; RV32I-NEXT: addi a1, zero, 136 |
| 15 | +; RV32I-NEXT: bne a0, a1, .LBB0_3 |
| 16 | +; RV32I-NEXT: # %bb.1: # %entry |
| 17 | +; RV32I-NEXT: lui a0, %hi(bytes+1) |
| 18 | +; RV32I-NEXT: lb a0, %lo(bytes+1)(a0) |
| 19 | +; RV32I-NEXT: andi a0, a0, 255 |
| 20 | +; RV32I-NEXT: addi a1, zero, 7 |
| 21 | +; RV32I-NEXT: bne a0, a1, .LBB0_3 |
| 22 | +; RV32I-NEXT: # %bb.2: # %if.end |
| 23 | +; RV32I-NEXT: mv a0, zero |
| 24 | +; RV32I-NEXT: ret |
| 25 | +; RV32I-NEXT: .LBB0_3: # %if.then |
| 26 | +; RV32I-NEXT: addi a0, zero, 1 |
| 27 | +; RV32I-NEXT: ret |
| 28 | +entry: |
| 29 | + %0 = load i8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @bytes, i32 0, i32 0), align 1 |
| 30 | + %cmp = icmp eq i8 %0, -120 |
| 31 | + %1 = load i8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @bytes, i32 0, i32 1), align 1 |
| 32 | + %cmp3 = icmp eq i8 %1, 7 |
| 33 | + %or.cond = and i1 %cmp, %cmp3 |
| 34 | + br i1 %or.cond, label %if.end, label %if.then |
| 35 | + |
| 36 | +if.then: |
| 37 | + ret i32 1 |
| 38 | + |
| 39 | +if.end: |
| 40 | + ret i32 0 |
| 41 | +} |
| 42 | + |
| 43 | +@shorts = global [5 x i16] zeroinitializer, align 2 |
| 44 | + |
| 45 | +define i32 @test_zext_i16() { |
| 46 | +; RV32I-LABEL: test_zext_i16: |
| 47 | +; RV32I: # %bb.0: # %entry |
| 48 | +; RV32I-NEXT: lui a0, 16 |
| 49 | +; RV32I-NEXT: addi a1, a0, -120 |
| 50 | +; RV32I-NEXT: lui a2, %hi(shorts) |
| 51 | +; RV32I-NEXT: lhu a2, %lo(shorts)(a2) |
| 52 | +; RV32I-NEXT: bne a2, a1, .LBB1_3 |
| 53 | +; RV32I-NEXT: # %bb.1: # %entry |
| 54 | +; RV32I-NEXT: lui a1, %hi(shorts+2) |
| 55 | +; RV32I-NEXT: lh a1, %lo(shorts+2)(a1) |
| 56 | +; RV32I-NEXT: addi a0, a0, -1 |
| 57 | +; RV32I-NEXT: and a0, a1, a0 |
| 58 | +; RV32I-NEXT: addi a1, zero, 7 |
| 59 | +; RV32I-NEXT: bne a0, a1, .LBB1_3 |
| 60 | +; RV32I-NEXT: # %bb.2: # %if.end |
| 61 | +; RV32I-NEXT: mv a0, zero |
| 62 | +; RV32I-NEXT: ret |
| 63 | +; RV32I-NEXT: .LBB1_3: # %if.then |
| 64 | +; RV32I-NEXT: addi a0, zero, 1 |
| 65 | +; RV32I-NEXT: ret |
| 66 | +entry: |
| 67 | + %0 = load i16, i16* getelementptr inbounds ([5 x i16], [5 x i16]* @shorts, i32 0, i32 0), align 2 |
| 68 | + %cmp = icmp eq i16 %0, -120 |
| 69 | + %1 = load i16, i16* getelementptr inbounds ([5 x i16], [5 x i16]* @shorts, i32 0, i32 1), align 2 |
| 70 | + %cmp3 = icmp eq i16 %1, 7 |
| 71 | + %or.cond = and i1 %cmp, %cmp3 |
| 72 | + br i1 %or.cond, label %if.end, label %if.then |
| 73 | + |
| 74 | +if.then: |
| 75 | + ret i32 1 |
| 76 | + |
| 77 | +if.end: |
| 78 | + ret i32 0 |
| 79 | +} |
0 commit comments