1; RUN: llc < %s -march=bpf -mcpu=v2 -verify-machineinstrs | FileCheck %s 2; 3; Source file: 4; int b, c; 5; int test() { 6; int a = b; 7; if (a) 8; a = c; 9; return a; 10; } 11@b = common local_unnamed_addr global i32 0, align 4 12@c = common local_unnamed_addr global i32 0, align 4 13 14; Function Attrs: norecurse nounwind readonly 15define i32 @test() local_unnamed_addr #0 { 16entry: 17 %0 = load i32, i32* @b, align 4 18 %tobool = icmp eq i32 %0, 0 19 %1 = load i32, i32* @c, align 4 20 %. = select i1 %tobool, i32 0, i32 %1 21; CHECK: r1 = b 22; CHECK: r1 = *(u32 *)(r1 + 0) 23; CHECK: if r1 == 0 goto 24 ret i32 %. 25} 26 27attributes #0 = { norecurse nounwind readonly } 28 29; test immediate out of 32-bit range 30; Source file: 31 32; unsigned long long 33; load_word(void *buf, unsigned long long off) 34; asm("llvm.bpf.load.word"); 35; 36; int 37; foo(void *buf) 38; { 39; unsigned long long sum = 0; 40; 41; sum += load_word(buf, 100); 42; sum += load_word(buf, 104); 43; 44; if (sum != 0x1ffffffffULL) 45; return ~0U; 46; 47; return 0; 48;} 49 50; Function Attrs: nounwind readonly 51define i32 @foo(i8*) local_unnamed_addr #0 { 52 %2 = tail call i64 @llvm.bpf.load.word(i8* %0, i64 100) 53 %3 = tail call i64 @llvm.bpf.load.word(i8* %0, i64 104) 54 %4 = add i64 %3, %2 55 %5 = icmp ne i64 %4, 8589934591 56; CHECK: r{{[0-9]+}} = 8589934591 ll 57 %6 = sext i1 %5 to i32 58 ret i32 %6 59} 60 61; Function Attrs: nounwind readonly 62declare i64 @llvm.bpf.load.word(i8*, i64) #1 63 64; Source file: 65; int m, n; 66; int test2() { 67; int a = m; 68; if (a < 6) 69; a = n; 70; return a; 71; } 72 73@m = common local_unnamed_addr global i32 0, align 4 74@n = common local_unnamed_addr global i32 0, align 4 75 76; Function Attrs: norecurse nounwind readonly 77define i32 @test2() local_unnamed_addr #0 { 78entry: 79 %0 = load i32, i32* @m, align 4 80 %cmp = icmp slt i32 %0, 6 81; CHECK: if r{{[0-9]+}} s{{<|>}} 6 goto 82 %1 = load i32, i32* @n, align 4 83 %spec.select = select i1 %cmp, i32 %1, i32 %0 84 ret i32 %spec.select 85} 86 87attributes #0 = { norecurse nounwind readonly } 88