@@ -396,3 +396,73 @@ define i1 @test61_as1(ptr addrspace(1) %foo, i16 %i, i16 %j) {
396
396
ret i1 %cmp
397
397
; Don't transform non-inbounds GEPs.
398
398
}
399
+
400
+ define i1 @test_scalable_same (ptr %x ) {
401
+ ; CHECK-LABEL: @test_scalable_same(
402
+ ; CHECK-NEXT: ret i1 false
403
+ ;
404
+ %a = getelementptr <vscale x 4 x i8 >, ptr %x , i64 8
405
+ %b = getelementptr inbounds <vscale x 4 x i8 >, ptr %x , i64 8
406
+ %c = icmp ugt ptr %a , %b
407
+ ret i1 %c
408
+ }
409
+
410
+ define i1 @test_scalable_x (ptr %x ) {
411
+ ; CHECK-LABEL: @test_scalable_x(
412
+ ; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.vscale.i64()
413
+ ; CHECK-NEXT: [[A_IDX_MASK:%.*]] = and i64 [[TMP1]], 576460752303423487
414
+ ; CHECK-NEXT: [[C:%.*]] = icmp eq i64 [[A_IDX_MASK]], 0
415
+ ; CHECK-NEXT: ret i1 [[C]]
416
+ ;
417
+ %a = getelementptr <vscale x 4 x i8 >, ptr %x , i64 8
418
+ %c = icmp eq ptr %a , %x
419
+ ret i1 %c
420
+ }
421
+
422
+ define i1 @test_scalable_xc (ptr %x ) {
423
+ ; CHECK-LABEL: @test_scalable_xc(
424
+ ; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.vscale.i64()
425
+ ; CHECK-NEXT: [[A_IDX_MASK:%.*]] = and i64 [[TMP1]], 576460752303423487
426
+ ; CHECK-NEXT: [[C:%.*]] = icmp eq i64 [[A_IDX_MASK]], 0
427
+ ; CHECK-NEXT: ret i1 [[C]]
428
+ ;
429
+ %a = getelementptr <vscale x 4 x i8 >, ptr %x , i64 8
430
+ %c = icmp eq ptr %x , %a
431
+ ret i1 %c
432
+ }
433
+
434
+ define i1 @test_scalable_xy (ptr %foo , i64 %i , i64 %j ) {
435
+ ; CHECK-LABEL: @test_scalable_xy(
436
+ ; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.vscale.i64()
437
+ ; CHECK-NEXT: [[TMP2:%.*]] = shl i64 [[TMP1]], 2
438
+ ; CHECK-NEXT: [[GEP2_IDX:%.*]] = mul nsw i64 [[TMP2]], [[J:%.*]]
439
+ ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
440
+ ; CHECK-NEXT: [[TMP4:%.*]] = shl i64 [[TMP3]], 4
441
+ ; CHECK-NEXT: [[GEP1_IDX:%.*]] = mul nsw i64 [[TMP4]], [[I:%.*]]
442
+ ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[GEP2_IDX]], [[GEP1_IDX]]
443
+ ; CHECK-NEXT: ret i1 [[CMP]]
444
+ ;
445
+ %bit = addrspacecast ptr %foo to ptr addrspace (3 )
446
+ %gep1 = getelementptr inbounds <vscale x 4 x i32 >, ptr addrspace (3 ) %bit , i64 %i
447
+ %gep2 = getelementptr inbounds <vscale x 4 x i8 >, ptr %foo , i64 %j
448
+ %cast1 = addrspacecast ptr addrspace (3 ) %gep1 to ptr
449
+ %cmp = icmp ult ptr %cast1 , %gep2
450
+ ret i1 %cmp
451
+ }
452
+
453
+ define i1 @test_scalable_ij (ptr %foo , i64 %i , i64 %j ) {
454
+ ; CHECK-LABEL: @test_scalable_ij(
455
+ ; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.vscale.i64()
456
+ ; CHECK-NEXT: [[TMP2:%.*]] = shl i64 [[TMP1]], 4
457
+ ; CHECK-NEXT: [[GEP1_IDX:%.*]] = mul nsw i64 [[TMP2]], [[I:%.*]]
458
+ ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
459
+ ; CHECK-NEXT: [[TMP4:%.*]] = shl i64 [[TMP3]], 2
460
+ ; CHECK-NEXT: [[GEP2_IDX:%.*]] = mul nsw i64 [[TMP4]], [[J:%.*]]
461
+ ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[GEP1_IDX]], [[GEP2_IDX]]
462
+ ; CHECK-NEXT: ret i1 [[CMP]]
463
+ ;
464
+ %gep1 = getelementptr inbounds <vscale x 4 x i32 >, ptr %foo , i64 %i
465
+ %gep2 = getelementptr inbounds <vscale x 4 x i8 >, ptr %foo , i64 %j
466
+ %cmp = icmp ult ptr %gep1 , %gep2
467
+ ret i1 %cmp
468
+ }
0 commit comments