1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[NFC][InstCombine] Add sub-of-sub tests with constant expressions

These would cause endless combine loop after 31d219d2997fed1b7dc97e0adf170d5aaf65883e.
This commit is contained in:
Roman Lebedev 2021-04-07 11:50:06 +03:00
parent c1f557c32d
commit a4b8059ee2

View File

@ -168,3 +168,34 @@ define i8 @t12_c1_c2_exrause(i8 %x, i8 %z) {
%r = sub i8 %i0, 24
ret i8 %r
}
; PR49870
@g0 = external global i8, align 1
@g1 = external global i8, align 1
define i32 @constantexpr0(i32 %x, i8* %y) unnamed_addr {
; CHECK-LABEL: @constantexpr0(
; CHECK-NEXT: [[R:%.*]] = sub i32 sub (i32 0, i32 ptrtoint (i8* @g0 to i32)), [[X:%.*]]
; CHECK-NEXT: ret i32 [[R]]
;
%i0 = add i32 %x, ptrtoint (i8* @g0 to i32)
%r = sub i32 0, %i0
ret i32 %r
}
define i32 @constantexpr1(i32 %x, i8* %y) unnamed_addr {
; CHECK-LABEL: @constantexpr1(
; CHECK-NEXT: [[R:%.*]] = sub i32 sub (i32 ptrtoint (i8* @g1 to i32), i32 42), [[X:%.*]]
; CHECK-NEXT: ret i32 [[R]]
;
%i0 = add i32 %x, 42
%r = sub i32 ptrtoint (i8* @g1 to i32), %i0
ret i32 %r
}
define i32 @constantexpr2(i32 %x, i8* %y) unnamed_addr {
; CHECK-LABEL: @constantexpr2(
; CHECK-NEXT: [[R:%.*]] = sub i32 sub (i32 ptrtoint (i8* @g1 to i32), i32 ptrtoint (i8* @g0 to i32)), [[X:%.*]]
; CHECK-NEXT: ret i32 [[R]]
;
%i0 = add i32 %x, ptrtoint (i8* @g0 to i32)
%r = sub i32 ptrtoint (i8* @g1 to i32), %i0
ret i32 %r
}