diff --git a/lib/Target/SystemZ/SystemZISelLowering.cpp b/lib/Target/SystemZ/SystemZISelLowering.cpp index 5959e90d2f6..ee732675fb3 100644 --- a/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -1603,8 +1603,8 @@ static void adjustSubwordCmp(SelectionDAG &DAG, SDLoc DL, Comparison &C) { } else if (Load->getExtensionType() == ISD::ZEXTLOAD) { if (Value > Mask) return; - assert(C.ICmpType == SystemZICMP::Any && - "Signedness shouldn't matter here."); + // If the constant is in range, we can use any comparison. + C.ICmpType = SystemZICMP::Any; } else return; diff --git a/test/CodeGen/SystemZ/int-cmp-52.ll b/test/CodeGen/SystemZ/int-cmp-52.ll new file mode 100644 index 00000000000..a0b72371d1c --- /dev/null +++ b/test/CodeGen/SystemZ/int-cmp-52.ll @@ -0,0 +1,24 @@ +; This used to crash the backend due to a failed assertion. +; No particular output expected, but must compile. +; +; RUN: llc < %s -mtriple=s390x-linux-gnu + +define void @test(i16 *%input, i32 *%result) { +entry: + %0 = load i16, i16* %input, align 2 + %1 = zext i16 %0 to i32 + %2 = icmp slt i32 %1, 0 + br i1 %2, label %if.then, label %if.else + +if.then: + store i32 1, i32* %result, align 4 + br label %return + +if.else: + store i32 0, i32* %result, align 4 + br label %return + +return: + ret void +} +