llvm/llvm/test/Transforms/ExpandMemCmp/X86/memcmp-x32.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -expand-memcmp -mtriple=i686-unknown-unknown   -data-layout=e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128 < %s | FileCheck %s --check-prefix=X32
; RUN: opt -S -passes=expand-memcmp -mtriple=i686-unknown-unknown   -data-layout=e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128 < %s | FileCheck %s --check-prefix=X32

declare i32 @memcmp(ptr nocapture, ptr nocapture, i32)

define i32 @cmp2(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp2(
; X32-NEXT:    [[TMP3:%.*]] = load i16, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP4:%.*]] = load i16, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP5:%.*]] = call i16 @llvm.bswap.i16(i16 [[TMP3]])
; X32-NEXT:    [[TMP6:%.*]] = call i16 @llvm.bswap.i16(i16 [[TMP4]])
; X32-NEXT:    [[TMP7:%.*]] = zext i16 [[TMP5]] to i32
; X32-NEXT:    [[TMP8:%.*]] = zext i16 [[TMP6]] to i32
; X32-NEXT:    [[TMP9:%.*]] = sub i32 [[TMP7]], [[TMP8]]
; X32-NEXT:    ret i32 [[TMP9]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 2)
  ret i32 %call
}

define i32 @cmp2_align2(ptr nocapture readonly align 2 %x, ptr nocapture readonly align 2 %y)  {
; X32-LABEL: @cmp2_align2(
; X32-NEXT:    [[TMP3:%.*]] = load i16, ptr [[X:%.*]], align 2
; X32-NEXT:    [[TMP4:%.*]] = load i16, ptr [[Y:%.*]], align 2
; X32-NEXT:    [[TMP5:%.*]] = call i16 @llvm.bswap.i16(i16 [[TMP3]])
; X32-NEXT:    [[TMP6:%.*]] = call i16 @llvm.bswap.i16(i16 [[TMP4]])
; X32-NEXT:    [[TMP7:%.*]] = zext i16 [[TMP5]] to i32
; X32-NEXT:    [[TMP8:%.*]] = zext i16 [[TMP6]] to i32
; X32-NEXT:    [[TMP9:%.*]] = sub i32 [[TMP7]], [[TMP8]]
; X32-NEXT:    ret i32 [[TMP9]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 2)
  ret i32 %call
}

define i32 @cmp3(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp3(
; X32-NEXT:    br label [[LOADBB:%.*]]
; X32:       res_block:
; X32-NEXT:    [[TMP1:%.*]] = icmp ult i16 [[TMP7:%.*]], [[TMP8:%.*]]
; X32-NEXT:    [[TMP2:%.*]] = select i1 [[TMP1]], i32 -1, i32 1
; X32-NEXT:    br label [[ENDBLOCK:%.*]]
; X32:       loadbb:
; X32-NEXT:    [[TMP5:%.*]] = load i16, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP6:%.*]] = load i16, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP7]] = call i16 @llvm.bswap.i16(i16 [[TMP5]])
; X32-NEXT:    [[TMP8]] = call i16 @llvm.bswap.i16(i16 [[TMP6]])
; X32-NEXT:    [[TMP9:%.*]] = icmp eq i16 [[TMP7]], [[TMP8]]
; X32-NEXT:    br i1 [[TMP9]], label [[LOADBB1:%.*]], label [[RES_BLOCK:%.*]]
; X32:       loadbb1:
; X32-NEXT:    [[TMP10:%.*]] = getelementptr i8, ptr [[X]], i64 2
; X32-NEXT:    [[TMP11:%.*]] = getelementptr i8, ptr [[Y]], i64 2
; X32-NEXT:    [[TMP12:%.*]] = load i8, ptr [[TMP10]], align 1
; X32-NEXT:    [[TMP13:%.*]] = load i8, ptr [[TMP11]], align 1
; X32-NEXT:    [[TMP14:%.*]] = zext i8 [[TMP12]] to i32
; X32-NEXT:    [[TMP15:%.*]] = zext i8 [[TMP13]] to i32
; X32-NEXT:    [[TMP16:%.*]] = sub i32 [[TMP14]], [[TMP15]]
; X32-NEXT:    br label [[ENDBLOCK]]
; X32:       endblock:
; X32-NEXT:    [[PHI_RES:%.*]] = phi i32 [ [[TMP16]], [[LOADBB1]] ], [ [[TMP2]], [[RES_BLOCK]] ]
; X32-NEXT:    ret i32 [[PHI_RES]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 3)
  ret i32 %call
}

define i32 @cmp4(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp4(
; X32-NEXT:    [[TMP3:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP4:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP5:%.*]] = call i32 @llvm.bswap.i32(i32 [[TMP3]])
; X32-NEXT:    [[TMP6:%.*]] = call i32 @llvm.bswap.i32(i32 [[TMP4]])
; X32-NEXT:    [[TMP7:%.*]] = icmp ugt i32 [[TMP5]], [[TMP6]]
; X32-NEXT:    [[TMP8:%.*]] = icmp ult i32 [[TMP5]], [[TMP6]]
; X32-NEXT:    [[TMP9:%.*]] = zext i1 [[TMP7]] to i32
; X32-NEXT:    [[TMP10:%.*]] = zext i1 [[TMP8]] to i32
; X32-NEXT:    [[TMP11:%.*]] = sub i32 [[TMP9]], [[TMP10]]
; X32-NEXT:    ret i32 [[TMP11]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 4)
  ret i32 %call
}

define i32 @cmp5(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp5(
; X32-NEXT:    br label [[LOADBB:%.*]]
; X32:       res_block:
; X32-NEXT:    [[TMP1:%.*]] = icmp ult i32 [[TMP7:%.*]], [[TMP8:%.*]]
; X32-NEXT:    [[TMP2:%.*]] = select i1 [[TMP1]], i32 -1, i32 1
; X32-NEXT:    br label [[ENDBLOCK:%.*]]
; X32:       loadbb:
; X32-NEXT:    [[TMP5:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP6:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP7]] = call i32 @llvm.bswap.i32(i32 [[TMP5]])
; X32-NEXT:    [[TMP8]] = call i32 @llvm.bswap.i32(i32 [[TMP6]])
; X32-NEXT:    [[TMP9:%.*]] = icmp eq i32 [[TMP7]], [[TMP8]]
; X32-NEXT:    br i1 [[TMP9]], label [[LOADBB1:%.*]], label [[RES_BLOCK:%.*]]
; X32:       loadbb1:
; X32-NEXT:    [[TMP10:%.*]] = getelementptr i8, ptr [[X]], i64 4
; X32-NEXT:    [[TMP11:%.*]] = getelementptr i8, ptr [[Y]], i64 4
; X32-NEXT:    [[TMP12:%.*]] = load i8, ptr [[TMP10]], align 1
; X32-NEXT:    [[TMP13:%.*]] = load i8, ptr [[TMP11]], align 1
; X32-NEXT:    [[TMP14:%.*]] = zext i8 [[TMP12]] to i32
; X32-NEXT:    [[TMP15:%.*]] = zext i8 [[TMP13]] to i32
; X32-NEXT:    [[TMP16:%.*]] = sub i32 [[TMP14]], [[TMP15]]
; X32-NEXT:    br label [[ENDBLOCK]]
; X32:       endblock:
; X32-NEXT:    [[PHI_RES:%.*]] = phi i32 [ [[TMP16]], [[LOADBB1]] ], [ [[TMP2]], [[RES_BLOCK]] ]
; X32-NEXT:    ret i32 [[PHI_RES]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 5)
  ret i32 %call
}

define i32 @cmp6(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp6(
; X32-NEXT:    br label [[LOADBB:%.*]]
; X32:       res_block:
; X32-NEXT:    [[PHI_SRC1:%.*]] = phi i32 [ [[TMP7:%.*]], [[LOADBB]] ], [ [[TMP18:%.*]], [[LOADBB1:%.*]] ]
; X32-NEXT:    [[PHI_SRC2:%.*]] = phi i32 [ [[TMP8:%.*]], [[LOADBB]] ], [ [[TMP19:%.*]], [[LOADBB1]] ]
; X32-NEXT:    [[TMP1:%.*]] = icmp ult i32 [[PHI_SRC1]], [[PHI_SRC2]]
; X32-NEXT:    [[TMP2:%.*]] = select i1 [[TMP1]], i32 -1, i32 1
; X32-NEXT:    br label [[ENDBLOCK:%.*]]
; X32:       loadbb:
; X32-NEXT:    [[TMP5:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP6:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP7]] = call i32 @llvm.bswap.i32(i32 [[TMP5]])
; X32-NEXT:    [[TMP8]] = call i32 @llvm.bswap.i32(i32 [[TMP6]])
; X32-NEXT:    [[TMP9:%.*]] = icmp eq i32 [[TMP7]], [[TMP8]]
; X32-NEXT:    br i1 [[TMP9]], label [[LOADBB1]], label [[RES_BLOCK:%.*]]
; X32:       loadbb1:
; X32-NEXT:    [[TMP10:%.*]] = getelementptr i8, ptr [[X]], i64 4
; X32-NEXT:    [[TMP11:%.*]] = getelementptr i8, ptr [[Y]], i64 4
; X32-NEXT:    [[TMP14:%.*]] = load i16, ptr [[TMP10]], align 1
; X32-NEXT:    [[TMP15:%.*]] = load i16, ptr [[TMP11]], align 1
; X32-NEXT:    [[TMP16:%.*]] = call i16 @llvm.bswap.i16(i16 [[TMP14]])
; X32-NEXT:    [[TMP17:%.*]] = call i16 @llvm.bswap.i16(i16 [[TMP15]])
; X32-NEXT:    [[TMP18]] = zext i16 [[TMP16]] to i32
; X32-NEXT:    [[TMP19]] = zext i16 [[TMP17]] to i32
; X32-NEXT:    [[TMP20:%.*]] = icmp eq i32 [[TMP18]], [[TMP19]]
; X32-NEXT:    br i1 [[TMP20]], label [[ENDBLOCK]], label [[RES_BLOCK]]
; X32:       endblock:
; X32-NEXT:    [[PHI_RES:%.*]] = phi i32 [ 0, [[LOADBB1]] ], [ [[TMP2]], [[RES_BLOCK]] ]
; X32-NEXT:    ret i32 [[PHI_RES]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 6)
  ret i32 %call
}

define i32 @cmp7(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp7(
; X32-NEXT:    br label [[LOADBB:%.*]]
; X32:       res_block:
; X32-NEXT:    [[PHI_SRC1:%.*]] = phi i32 [ [[TMP7:%.*]], [[LOADBB]] ], [ [[TMP16:%.*]], [[LOADBB1:%.*]] ]
; X32-NEXT:    [[PHI_SRC2:%.*]] = phi i32 [ [[TMP8:%.*]], [[LOADBB]] ], [ [[TMP17:%.*]], [[LOADBB1]] ]
; X32-NEXT:    [[TMP1:%.*]] = icmp ult i32 [[PHI_SRC1]], [[PHI_SRC2]]
; X32-NEXT:    [[TMP2:%.*]] = select i1 [[TMP1]], i32 -1, i32 1
; X32-NEXT:    br label [[ENDBLOCK:%.*]]
; X32:       loadbb:
; X32-NEXT:    [[TMP5:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP6:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP7]] = call i32 @llvm.bswap.i32(i32 [[TMP5]])
; X32-NEXT:    [[TMP8]] = call i32 @llvm.bswap.i32(i32 [[TMP6]])
; X32-NEXT:    [[TMP9:%.*]] = icmp eq i32 [[TMP7]], [[TMP8]]
; X32-NEXT:    br i1 [[TMP9]], label [[LOADBB1]], label [[RES_BLOCK:%.*]]
; X32:       loadbb1:
; X32-NEXT:    [[TMP10:%.*]] = getelementptr i8, ptr [[X]], i64 3
; X32-NEXT:    [[TMP11:%.*]] = getelementptr i8, ptr [[Y]], i64 3
; X32-NEXT:    [[TMP14:%.*]] = load i32, ptr [[TMP10]], align 1
; X32-NEXT:    [[TMP15:%.*]] = load i32, ptr [[TMP11]], align 1
; X32-NEXT:    [[TMP16]] = call i32 @llvm.bswap.i32(i32 [[TMP14]])
; X32-NEXT:    [[TMP17]] = call i32 @llvm.bswap.i32(i32 [[TMP15]])
; X32-NEXT:    [[TMP18:%.*]] = icmp eq i32 [[TMP16]], [[TMP17]]
; X32-NEXT:    br i1 [[TMP18]], label [[ENDBLOCK]], label [[RES_BLOCK]]
; X32:       endblock:
; X32-NEXT:    [[PHI_RES:%.*]] = phi i32 [ 0, [[LOADBB1]] ], [ [[TMP2]], [[RES_BLOCK]] ]
; X32-NEXT:    ret i32 [[PHI_RES]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 7)
  ret i32 %call
}

define i32 @cmp8(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp8(
; X32-NEXT:    br label [[LOADBB:%.*]]
; X32:       res_block:
; X32-NEXT:    [[PHI_SRC1:%.*]] = phi i32 [ [[TMP7:%.*]], [[LOADBB]] ], [ [[TMP16:%.*]], [[LOADBB1:%.*]] ]
; X32-NEXT:    [[PHI_SRC2:%.*]] = phi i32 [ [[TMP8:%.*]], [[LOADBB]] ], [ [[TMP17:%.*]], [[LOADBB1]] ]
; X32-NEXT:    [[TMP1:%.*]] = icmp ult i32 [[PHI_SRC1]], [[PHI_SRC2]]
; X32-NEXT:    [[TMP2:%.*]] = select i1 [[TMP1]], i32 -1, i32 1
; X32-NEXT:    br label [[ENDBLOCK:%.*]]
; X32:       loadbb:
; X32-NEXT:    [[TMP5:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP6:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP7]] = call i32 @llvm.bswap.i32(i32 [[TMP5]])
; X32-NEXT:    [[TMP8]] = call i32 @llvm.bswap.i32(i32 [[TMP6]])
; X32-NEXT:    [[TMP9:%.*]] = icmp eq i32 [[TMP7]], [[TMP8]]
; X32-NEXT:    br i1 [[TMP9]], label [[LOADBB1]], label [[RES_BLOCK:%.*]]
; X32:       loadbb1:
; X32-NEXT:    [[TMP10:%.*]] = getelementptr i8, ptr [[X]], i64 4
; X32-NEXT:    [[TMP11:%.*]] = getelementptr i8, ptr [[Y]], i64 4
; X32-NEXT:    [[TMP14:%.*]] = load i32, ptr [[TMP10]], align 1
; X32-NEXT:    [[TMP15:%.*]] = load i32, ptr [[TMP11]], align 1
; X32-NEXT:    [[TMP16]] = call i32 @llvm.bswap.i32(i32 [[TMP14]])
; X32-NEXT:    [[TMP17]] = call i32 @llvm.bswap.i32(i32 [[TMP15]])
; X32-NEXT:    [[TMP18:%.*]] = icmp eq i32 [[TMP16]], [[TMP17]]
; X32-NEXT:    br i1 [[TMP18]], label [[ENDBLOCK]], label [[RES_BLOCK]]
; X32:       endblock:
; X32-NEXT:    [[PHI_RES:%.*]] = phi i32 [ 0, [[LOADBB1]] ], [ [[TMP2]], [[RES_BLOCK]] ]
; X32-NEXT:    ret i32 [[PHI_RES]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 8)
  ret i32 %call
}

define i32 @cmp9(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp9(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 9)
; X32-NEXT:    ret i32 [[CALL]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 9)
  ret i32 %call
}

define i32 @cmp10(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp10(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 10)
; X32-NEXT:    ret i32 [[CALL]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 10)
  ret i32 %call
}

define i32 @cmp11(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp11(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 11)
; X32-NEXT:    ret i32 [[CALL]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 11)
  ret i32 %call
}

define i32 @cmp12(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp12(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 12)
; X32-NEXT:    ret i32 [[CALL]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 12)
  ret i32 %call
}

define i32 @cmp13(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp13(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 13)
; X32-NEXT:    ret i32 [[CALL]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 13)
  ret i32 %call
}

define i32 @cmp14(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp14(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 14)
; X32-NEXT:    ret i32 [[CALL]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 14)
  ret i32 %call
}

define i32 @cmp15(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp15(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 15)
; X32-NEXT:    ret i32 [[CALL]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 15)
  ret i32 %call
}

define i32 @cmp16(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp16(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 16)
; X32-NEXT:    ret i32 [[CALL]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 16)
  ret i32 %call
}

define i32 @cmp_eq2(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq2(
; X32-NEXT:    [[TMP3:%.*]] = load i16, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP4:%.*]] = load i16, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP5:%.*]] = icmp ne i16 [[TMP3]], [[TMP4]]
; X32-NEXT:    [[TMP6:%.*]] = zext i1 [[TMP5]] to i32
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP6]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 2)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq3(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq3(
; X32-NEXT:    [[TMP3:%.*]] = load i16, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP4:%.*]] = load i16, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP5:%.*]] = xor i16 [[TMP3]], [[TMP4]]
; X32-NEXT:    [[TMP6:%.*]] = getelementptr i8, ptr [[X]], i64 2
; X32-NEXT:    [[TMP7:%.*]] = getelementptr i8, ptr [[Y]], i64 2
; X32-NEXT:    [[TMP8:%.*]] = load i8, ptr [[TMP6]], align 1
; X32-NEXT:    [[TMP9:%.*]] = load i8, ptr [[TMP7]], align 1
; X32-NEXT:    [[TMP10:%.*]] = zext i8 [[TMP8]] to i16
; X32-NEXT:    [[TMP11:%.*]] = zext i8 [[TMP9]] to i16
; X32-NEXT:    [[TMP12:%.*]] = xor i16 [[TMP10]], [[TMP11]]
; X32-NEXT:    [[TMP13:%.*]] = or i16 [[TMP5]], [[TMP12]]
; X32-NEXT:    [[TMP14:%.*]] = icmp ne i16 [[TMP13]], 0
; X32-NEXT:    [[TMP15:%.*]] = zext i1 [[TMP14]] to i32
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP15]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 3)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq4(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq4(
; X32-NEXT:    [[TMP3:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP4:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP5:%.*]] = icmp ne i32 [[TMP3]], [[TMP4]]
; X32-NEXT:    [[TMP6:%.*]] = zext i1 [[TMP5]] to i32
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP6]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 4)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq5(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq5(
; X32-NEXT:    [[TMP3:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP4:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
; X32-NEXT:    [[TMP6:%.*]] = getelementptr i8, ptr [[X]], i64 4
; X32-NEXT:    [[TMP7:%.*]] = getelementptr i8, ptr [[Y]], i64 4
; X32-NEXT:    [[TMP8:%.*]] = load i8, ptr [[TMP6]], align 1
; X32-NEXT:    [[TMP9:%.*]] = load i8, ptr [[TMP7]], align 1
; X32-NEXT:    [[TMP10:%.*]] = zext i8 [[TMP8]] to i32
; X32-NEXT:    [[TMP11:%.*]] = zext i8 [[TMP9]] to i32
; X32-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP10]], [[TMP11]]
; X32-NEXT:    [[TMP13:%.*]] = or i32 [[TMP5]], [[TMP12]]
; X32-NEXT:    [[TMP14:%.*]] = icmp ne i32 [[TMP13]], 0
; X32-NEXT:    [[TMP15:%.*]] = zext i1 [[TMP14]] to i32
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP15]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 5)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq6(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq6(
; X32-NEXT:    [[TMP3:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP4:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
; X32-NEXT:    [[TMP6:%.*]] = getelementptr i8, ptr [[X]], i64 4
; X32-NEXT:    [[TMP7:%.*]] = getelementptr i8, ptr [[Y]], i64 4
; X32-NEXT:    [[TMP10:%.*]] = load i16, ptr [[TMP6]], align 1
; X32-NEXT:    [[TMP11:%.*]] = load i16, ptr [[TMP7]], align 1
; X32-NEXT:    [[TMP12:%.*]] = zext i16 [[TMP10]] to i32
; X32-NEXT:    [[TMP13:%.*]] = zext i16 [[TMP11]] to i32
; X32-NEXT:    [[TMP14:%.*]] = xor i32 [[TMP12]], [[TMP13]]
; X32-NEXT:    [[TMP15:%.*]] = or i32 [[TMP5]], [[TMP14]]
; X32-NEXT:    [[TMP16:%.*]] = icmp ne i32 [[TMP15]], 0
; X32-NEXT:    [[TMP17:%.*]] = zext i1 [[TMP16]] to i32
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP17]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 6)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq6_align4(ptr nocapture readonly align 4 %x, ptr nocapture readonly align 4 %y)  {
; X32-LABEL: @cmp_eq6_align4(
; X32-NEXT:    [[TMP3:%.*]] = load i32, ptr [[X:%.*]], align 4
; X32-NEXT:    [[TMP4:%.*]] = load i32, ptr [[Y:%.*]], align 4
; X32-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
; X32-NEXT:    [[TMP6:%.*]] = getelementptr i8, ptr [[X]], i64 4
; X32-NEXT:    [[TMP7:%.*]] = getelementptr i8, ptr [[Y]], i64 4
; X32-NEXT:    [[TMP10:%.*]] = load i16, ptr [[TMP6]], align 4
; X32-NEXT:    [[TMP11:%.*]] = load i16, ptr [[TMP7]], align 4
; X32-NEXT:    [[TMP12:%.*]] = zext i16 [[TMP10]] to i32
; X32-NEXT:    [[TMP13:%.*]] = zext i16 [[TMP11]] to i32
; X32-NEXT:    [[TMP14:%.*]] = xor i32 [[TMP12]], [[TMP13]]
; X32-NEXT:    [[TMP15:%.*]] = or i32 [[TMP5]], [[TMP14]]
; X32-NEXT:    [[TMP16:%.*]] = icmp ne i32 [[TMP15]], 0
; X32-NEXT:    [[TMP17:%.*]] = zext i1 [[TMP16]] to i32
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP17]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 6)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq7(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq7(
; X32-NEXT:    [[TMP3:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP4:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
; X32-NEXT:    [[TMP6:%.*]] = getelementptr i8, ptr [[X]], i64 3
; X32-NEXT:    [[TMP7:%.*]] = getelementptr i8, ptr [[Y]], i64 3
; X32-NEXT:    [[TMP10:%.*]] = load i32, ptr [[TMP6]], align 1
; X32-NEXT:    [[TMP11:%.*]] = load i32, ptr [[TMP7]], align 1
; X32-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP10]], [[TMP11]]
; X32-NEXT:    [[TMP13:%.*]] = or i32 [[TMP5]], [[TMP12]]
; X32-NEXT:    [[TMP14:%.*]] = icmp ne i32 [[TMP13]], 0
; X32-NEXT:    [[TMP15:%.*]] = zext i1 [[TMP14]] to i32
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP15]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 7)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq8(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq8(
; X32-NEXT:    [[TMP3:%.*]] = load i32, ptr [[X:%.*]], align 1
; X32-NEXT:    [[TMP4:%.*]] = load i32, ptr [[Y:%.*]], align 1
; X32-NEXT:    [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
; X32-NEXT:    [[TMP6:%.*]] = getelementptr i8, ptr [[X]], i64 4
; X32-NEXT:    [[TMP7:%.*]] = getelementptr i8, ptr [[Y]], i64 4
; X32-NEXT:    [[TMP10:%.*]] = load i32, ptr [[TMP6]], align 1
; X32-NEXT:    [[TMP11:%.*]] = load i32, ptr [[TMP7]], align 1
; X32-NEXT:    [[TMP12:%.*]] = xor i32 [[TMP10]], [[TMP11]]
; X32-NEXT:    [[TMP13:%.*]] = or i32 [[TMP5]], [[TMP12]]
; X32-NEXT:    [[TMP14:%.*]] = icmp ne i32 [[TMP13]], 0
; X32-NEXT:    [[TMP15:%.*]] = zext i1 [[TMP14]] to i32
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP15]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 8)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq9(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq9(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 9)
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[CALL]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 9)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq10(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq10(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 10)
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[CALL]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 10)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq11(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq11(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 11)
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[CALL]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 11)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq12(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq12(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 12)
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[CALL]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 12)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq13(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq13(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 13)
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[CALL]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 13)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq14(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq14(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 14)
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[CALL]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 14)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq15(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq15(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 15)
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[CALL]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 15)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @cmp_eq16(ptr nocapture readonly %x, ptr nocapture readonly %y)  {
; X32-LABEL: @cmp_eq16(
; X32-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(ptr [[X:%.*]], ptr [[Y:%.*]], i32 16)
; X32-NEXT:    [[CMP:%.*]] = icmp eq i32 [[CALL]], 0
; X32-NEXT:    [[CONV:%.*]] = zext i1 [[CMP]] to i32
; X32-NEXT:    ret i32 [[CONV]]
;
  %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 16)
  %cmp = icmp eq i32 %call, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}