X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2FTransforms%2FInstCombine%2F2004-11-27-SetCCForCastLargerAndConstant.ll;h=6672b6c6d4e5fea950e98327148dfd5aa51c3724;hb=be9ee969260fdc03eebcd9f647dcaa5f1384b0cf;hp=7e12bbf5aee7e098dc3b7016a6104bac464a98af;hpb=7c65d4345ea93967e2d943765c3fa945beb72aab;p=oota-llvm.git diff --git a/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll b/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll index 7e12bbf5aee..6672b6c6d4e 100644 --- a/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll +++ b/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll @@ -1,136 +1,192 @@ ; This test case tests the InstructionCombining optimization that ; reduces things like: -; %Y = cast sbyte %X to uint -; %C = setlt uint %Y, 1024 +; %Y = sext i8 %X to i32 +; %C = icmp ult i32 %Y, 1024 ; to -; %C = bool true +; %C = i1 true ; It includes test cases for different constant values, signedness of the ; cast operands, and types of setCC operators. In all cases, the cast should ; be eliminated. In many cases the setCC is also eliminated based on the ; constant value and the range of the casted value. ; -; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | \ -; RUN: notcast .*int +; RUN: opt < %s -instcombine -S | FileCheck %s ; END. +define i1 @lt_signed_to_large_unsigned(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp ult i32 %Y, 1024 ; [#uses=1] + ret i1 %C +; CHECK: %C1 = icmp sgt i8 %SB, -1 +; CHECK: ret i1 %C1 +} + +define i1 @lt_signed_to_large_signed(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp slt i32 %Y, 1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 true +} -implementation ; Functions: +define i1 @lt_signed_to_large_negative(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp slt i32 %Y, -1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 false +} -bool %lt_signed_to_large_unsigned(sbyte %SB) { - %Y = cast sbyte %SB to uint ; [#uses=1] - %C = setlt uint %Y, 1024 ; [#uses=1] - ret bool %C +define i1 @lt_signed_to_small_unsigned(i8 %SB) { + %Y = sext i8 %SB to i32 + %C = icmp ult i32 %Y, 17 + ret i1 %C +; CHECK: %C = icmp ult i8 %SB, 17 +; CHECK: ret i1 %C } -bool %lt_signed_to_large_signed(sbyte %SB) { - %Y = cast sbyte %SB to int - %C = setlt int %Y, 1024 - ret bool %C +define i1 @lt_signed_to_small_signed(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp slt i32 %Y, 17 ; [#uses=1] + ret i1 %C +; CHECK: %C = icmp slt i8 %SB, 17 +; CHECK: ret i1 %C +} +define i1 @lt_signed_to_small_negative(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp slt i32 %Y, -17 ; [#uses=1] + ret i1 %C +; CHECK: %C = icmp slt i8 %SB, -17 +; CHECK: ret i1 %C } -bool %lt_signed_to_large_negative(sbyte %SB) { - %Y = cast sbyte %SB to int - %C = setlt int %Y, -1024 - ret bool %C +define i1 @lt_unsigned_to_large_unsigned(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp ult i32 %Y, 1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 true } -bool %lt_signed_to_small_signed(sbyte %SB) { - %Y = cast sbyte %SB to int - %C = setlt int %Y, 17 - ret bool %C +define i1 @lt_unsigned_to_large_signed(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp slt i32 %Y, 1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 true } -bool %lt_signed_to_small_negative(sbyte %SB) { - %Y = cast sbyte %SB to int - %C = setlt int %Y, -17 - ret bool %C +define i1 @lt_unsigned_to_large_negative(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp slt i32 %Y, -1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 false } -bool %lt_unsigned_to_large_unsigned(ubyte %SB) { - %Y = cast ubyte %SB to uint ; [#uses=1] - %C = setlt uint %Y, 1024 ; [#uses=1] - ret bool %C +define i1 @lt_unsigned_to_small_unsigned(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp ult i32 %Y, 17 ; [#uses=1] + ret i1 %C +; CHECK: %C = icmp ult i8 %SB, 17 +; CHECK: ret i1 %C } -bool %lt_unsigned_to_large_signed(ubyte %SB) { - %Y = cast ubyte %SB to int - %C = setlt int %Y, 1024 - ret bool %C +define i1 @lt_unsigned_to_small_signed(i8 %SB) { + %Y = zext i8 %SB to i32 + %C = icmp slt i32 %Y, 17 + ret i1 %C +; CHECK: %C = icmp ult i8 %SB, 17 +; CHECK: ret i1 %C } -bool %lt_unsigned_to_large_negative(ubyte %SB) { - %Y = cast ubyte %SB to int - %C = setlt int %Y, -1024 - ret bool %C +define i1 @lt_unsigned_to_small_negative(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp slt i32 %Y, -17 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 false } -bool %lt_unsigned_to_small_unsigned(ubyte %SB) { - %Y = cast ubyte %SB to uint ; [#uses=1] - %C = setlt uint %Y, 17 ; [#uses=1] - ret bool %C +define i1 @gt_signed_to_large_unsigned(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp ugt i32 %Y, 1024 ; [#uses=1] + ret i1 %C +; CHECK: %C = icmp slt i8 %SB, 0 +; CHECK: ret i1 %C } -bool %lt_unsigned_to_small_negative(ubyte %SB) { - %Y = cast ubyte %SB to int - %C = setlt int %Y, -17 - ret bool %C +define i1 @gt_signed_to_large_signed(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp sgt i32 %Y, 1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 false } -bool %gt_signed_to_large_unsigned(sbyte %SB) { - %Y = cast sbyte %SB to uint ; [#uses=1] - %C = setgt uint %Y, 1024 ; [#uses=1] - ret bool %C +define i1 @gt_signed_to_large_negative(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp sgt i32 %Y, -1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 true } -bool %gt_signed_to_large_signed(sbyte %SB) { - %Y = cast sbyte %SB to int - %C = setgt int %Y, 1024 - ret bool %C +define i1 @gt_signed_to_small_unsigned(i8 %SB) { + %Y = sext i8 %SB to i32 + %C = icmp ugt i32 %Y, 17 + ret i1 %C +; CHECK: %C = icmp ugt i8 %SB, 17 +; CHECK: ret i1 %C } -bool %gt_signed_to_large_negative(sbyte %SB) { - %Y = cast sbyte %SB to int - %C = setgt int %Y, -1024 - ret bool %C +define i1 @gt_signed_to_small_signed(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp sgt i32 %Y, 17 ; [#uses=1] + ret i1 %C +; CHECK: %C = icmp sgt i8 %SB, 17 +; CHECK: ret i1 %C } -bool %gt_signed_to_small_signed(sbyte %SB) { - %Y = cast sbyte %SB to int - %C = setgt int %Y, 17 - ret bool %C +define i1 @gt_signed_to_small_negative(i8 %SB) { + %Y = sext i8 %SB to i32 ; [#uses=1] + %C = icmp sgt i32 %Y, -17 ; [#uses=1] + ret i1 %C +; CHECK: %C = icmp sgt i8 %SB, -17 +; CHECK: ret i1 %C } -bool %gt_signed_to_small_negative(sbyte %SB) { - %Y = cast sbyte %SB to int - %C = setgt int %Y, -17 - ret bool %C +define i1 @gt_unsigned_to_large_unsigned(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp ugt i32 %Y, 1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 false } -bool %gt_unsigned_to_large_unsigned(ubyte %SB) { - %Y = cast ubyte %SB to uint ; [#uses=1] - %C = setgt uint %Y, 1024 ; [#uses=1] - ret bool %C +define i1 @gt_unsigned_to_large_signed(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp sgt i32 %Y, 1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 false } -bool %gt_unsigned_to_large_signed(ubyte %SB) { - %Y = cast ubyte %SB to int - %C = setgt int %Y, 1024 - ret bool %C +define i1 @gt_unsigned_to_large_negative(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp sgt i32 %Y, -1024 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 true } -bool %gt_unsigned_to_large_negative(ubyte %SB) { - %Y = cast ubyte %SB to int - %C = setgt int %Y, -1024 - ret bool %C +define i1 @gt_unsigned_to_small_unsigned(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp ugt i32 %Y, 17 ; [#uses=1] + ret i1 %C +; CHECK: %C = icmp ugt i8 %SB, 17 +; CHECK: ret i1 %C } -bool %gt_unsigned_to_small_unsigned(ubyte %SB) { - %Y = cast ubyte %SB to uint ; [#uses=1] - %C = setgt uint %Y, 17 ; [#uses=1] - ret bool %C +define i1 @gt_unsigned_to_small_signed(i8 %SB) { + %Y = zext i8 %SB to i32 + %C = icmp sgt i32 %Y, 17 + ret i1 %C +; CHECK: %C = icmp ugt i8 %SB, 17 +; CHECK: ret i1 %C } -bool %gt_unsigned_to_small_negative(ubyte %SB) { - %Y = cast ubyte %SB to int - %C = setgt int %Y, -17 - ret bool %C +define i1 @gt_unsigned_to_small_negative(i8 %SB) { + %Y = zext i8 %SB to i32 ; [#uses=1] + %C = icmp sgt i32 %Y, -17 ; [#uses=1] + ret i1 %C +; CHECK: ret i1 true } +