Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
392 changes: 314 additions & 78 deletions llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

Large diffs are not rendered by default.

50 changes: 21 additions & 29 deletions llvm/test/Transforms/InstCombine/cast-mul-select.ll
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,18 @@ define i8 @select2(i1 %cond, i8 %x, i8 %y, i8 %z) {

define i32 @eval_trunc_multi_use_in_one_inst(i32 %x) {
; CHECK-LABEL: @eval_trunc_multi_use_in_one_inst(
; CHECK-NEXT: [[Z:%.*]] = zext i32 [[X:%.*]] to i64
; CHECK-NEXT: [[A:%.*]] = add nuw nsw i64 [[Z]], 15
; CHECK-NEXT: [[M:%.*]] = mul i64 [[A]], [[A]]
; CHECK-NEXT: [[T:%.*]] = trunc i64 [[M]] to i32
; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], 15
; CHECK-NEXT: [[T:%.*]] = mul i32 [[A]], [[A]]
; CHECK-NEXT: ret i32 [[T]]
;
; DBGINFO-LABEL: @eval_trunc_multi_use_in_one_inst(
; DBGINFO-NEXT: [[Z:%.*]] = zext i32 [[X:%.*]] to i64, !dbg [[DBG57:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i64 [[Z]], [[META52:![0-9]+]], !DIExpression(), [[DBG57]])
; DBGINFO-NEXT: [[A:%.*]] = add nuw nsw i64 [[Z]], 15, !dbg [[DBG58:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i64 [[A]], [[META54:![0-9]+]], !DIExpression(), [[DBG58]])
; DBGINFO-NEXT: [[M:%.*]] = mul i64 [[A]], [[A]], !dbg [[DBG59:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i64 [[M]], [[META55:![0-9]+]], !DIExpression(), [[DBG59]])
; DBGINFO-NEXT: [[T:%.*]] = trunc i64 [[M]] to i32, !dbg [[DBG60:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i32 [[T]], [[META56:![0-9]+]], !DIExpression(), [[DBG60]])
; DBGINFO-NEXT: ret i32 [[T]], !dbg [[DBG61:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i32 [[X:%.*]], [[META52:![0-9]+]], !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_stack_value), [[META57:![0-9]+]])
; DBGINFO-NEXT: [[A:%.*]] = add i32 [[X]], 15, !dbg [[DBG58:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i32 [[X]], [[META54:![0-9]+]], !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_plus_uconst, 15, DW_OP_stack_value), [[DBG58]])
; DBGINFO-NEXT: [[M:%.*]] = mul i32 [[A]], [[A]], !dbg [[DBG59:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(!DIArgList(i32 [[X]], i32 [[X]]), [[META55:![0-9]+]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_plus_uconst, 15, DW_OP_LLVM_arg, 1, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_plus_uconst, 15, DW_OP_mul, DW_OP_stack_value), [[DBG59]])
; DBGINFO-NEXT: #dbg_value(i32 [[M]], [[META56:![0-9]+]], !DIExpression(), [[META60:![0-9]+]])
; DBGINFO-NEXT: ret i32 [[M]], !dbg [[DBG61:![0-9]+]]
;
%z = zext i32 %x to i64
%a = add nsw nuw i64 %z, 15
Expand Down Expand Up @@ -143,25 +139,21 @@ define i32 @eval_zext_multi_use_in_one_inst(i32 %x) {

define i32 @eval_sext_multi_use_in_one_inst(i32 %x) {
; CHECK-LABEL: @eval_sext_multi_use_in_one_inst(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i16
; CHECK-NEXT: [[A:%.*]] = and i16 [[T]], 14
; CHECK-NEXT: [[M:%.*]] = mul nuw nsw i16 [[A]], [[A]]
; CHECK-NEXT: [[O:%.*]] = or disjoint i16 [[M]], -32768
; CHECK-NEXT: [[R:%.*]] = sext i16 [[O]] to i32
; CHECK-NEXT: [[A:%.*]] = and i32 [[X:%.*]], 14
; CHECK-NEXT: [[M:%.*]] = mul nuw nsw i32 [[A]], [[A]]
; CHECK-NEXT: [[R:%.*]] = or disjoint i32 [[M]], -32768
; CHECK-NEXT: ret i32 [[R]]
;
; DBGINFO-LABEL: @eval_sext_multi_use_in_one_inst(
; DBGINFO-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i16, !dbg [[DBG81:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i16 [[T]], [[META76:![0-9]+]], !DIExpression(), [[DBG81]])
; DBGINFO-NEXT: [[A:%.*]] = and i16 [[T]], 14, !dbg [[DBG82:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i16 [[A]], [[META77:![0-9]+]], !DIExpression(), [[DBG82]])
; DBGINFO-NEXT: [[M:%.*]] = mul nuw nsw i16 [[A]], [[A]], !dbg [[DBG83:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i16 [[M]], [[META78:![0-9]+]], !DIExpression(), [[DBG83]])
; DBGINFO-NEXT: [[O:%.*]] = or disjoint i16 [[M]], -32768, !dbg [[DBG84:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i16 [[O]], [[META79:![0-9]+]], !DIExpression(), [[DBG84]])
; DBGINFO-NEXT: [[R:%.*]] = sext i16 [[O]] to i32, !dbg [[DBG85:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i32 [[R]], [[META80:![0-9]+]], !DIExpression(), [[DBG85]])
; DBGINFO-NEXT: ret i32 [[R]], !dbg [[DBG86:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i32 [[X:%.*]], [[META76:![0-9]+]], !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 16, DW_ATE_unsigned, DW_OP_stack_value), [[META81:![0-9]+]])
; DBGINFO-NEXT: [[A:%.*]] = and i32 [[X]], 14, !dbg [[DBG82:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(i32 [[X]], [[META77:![0-9]+]], !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 16, DW_ATE_unsigned, DW_OP_constu, 14, DW_OP_and, DW_OP_stack_value), [[DBG82]])
; DBGINFO-NEXT: [[M:%.*]] = mul nuw nsw i32 [[A]], [[A]], !dbg [[DBG83:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(!DIArgList(i32 [[X]], i32 [[X]]), [[META78:![0-9]+]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 16, DW_ATE_unsigned, DW_OP_constu, 14, DW_OP_and, DW_OP_LLVM_arg, 1, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 16, DW_ATE_unsigned, DW_OP_constu, 14, DW_OP_and, DW_OP_mul, DW_OP_stack_value), [[DBG83]])
; DBGINFO-NEXT: [[O:%.*]] = or disjoint i32 [[M]], -32768, !dbg [[DBG84:![0-9]+]]
; DBGINFO-NEXT: #dbg_value(!DIArgList(i32 [[X]], i32 [[X]]), [[META79:![0-9]+]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 16, DW_ATE_unsigned, DW_OP_constu, 14, DW_OP_and, DW_OP_LLVM_arg, 1, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 16, DW_ATE_unsigned, DW_OP_constu, 14, DW_OP_and, DW_OP_mul, DW_OP_constu, 18446744073709518848, DW_OP_or, DW_OP_stack_value), [[DBG84]])
; DBGINFO-NEXT: #dbg_value(i32 [[O]], [[META80:![0-9]+]], !DIExpression(), [[META85:![0-9]+]])
; DBGINFO-NEXT: ret i32 [[O]], !dbg [[DBG86:![0-9]+]]
;
%t = trunc i32 %x to i16
%a = and i16 %t, 14
Expand Down
144 changes: 144 additions & 0 deletions llvm/test/Transforms/InstCombine/cast.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2238,3 +2238,147 @@ define i32 @test95(i32 %x) {
%5 = zext i8 %4 to i32
ret i32 %5
}

define i16 @test96(i16 %x, i16 %y) {
; ALL-LABEL: @test96(
; ALL-NEXT: [[A:%.*]] = add i16 [[X:%.*]], [[Y:%.*]]
; ALL-NEXT: [[B:%.*]] = add i16 [[A]], 5
; ALL-NEXT: [[C:%.*]] = mul i16 [[A]], 3
; ALL-NEXT: [[T:%.*]] = or i16 [[B]], [[C]]
; ALL-NEXT: ret i16 [[T]]
;
%zx = zext i16 %x to i32
%zy = zext i16 %y to i32
%a = add i32 %zx, %zy
%b = add i32 %a, 5
%c = mul i32 %a, 3
%d = or i32 %b, %c
%t = trunc i32 %d to i16
ret i16 %t
}

define i16 @test97(i16 %x, i16 %y) {
; ALL-LABEL: @test97(
; ALL-NEXT: [[ZX:%.*]] = zext i16 [[X:%.*]] to i32
; ALL-NEXT: [[ZY:%.*]] = zext i16 [[Y:%.*]] to i32
; ALL-NEXT: [[A:%.*]] = add nuw nsw i32 [[ZX]], [[ZY]]
; ALL-NEXT: [[B:%.*]] = add nuw nsw i32 [[A]], 5
; ALL-NEXT: [[C:%.*]] = mul nuw nsw i32 [[A]], 3
; ALL-NEXT: [[D:%.*]] = or i32 [[B]], [[C]]
; ALL-NEXT: call void @use_i32(i32 [[A]])
; ALL-NEXT: [[T:%.*]] = trunc i32 [[D]] to i16
; ALL-NEXT: ret i16 [[T]]
;
%zx = zext i16 %x to i32
%zy = zext i16 %y to i32
%a = add i32 %zx, %zy
%b = add i32 %a, 5
%c = mul i32 %a, 3
%d = or i32 %b, %c
call void @use_i32(i32 %a)
%t = trunc i32 %d to i16
ret i16 %t
}

; expected not to narrow operations to i16 due to a loop in use chains
define i16 @test98(i16 %x, i16 %n) {
; ALL-LABEL: @test98(
; ALL-NEXT: entry:
; ALL-NEXT: [[Z:%.*]] = zext i16 [[X:%.*]] to i32
; ALL-NEXT: br label [[LOOP:%.*]]
; ALL: loop:
; ALL-NEXT: [[P:%.*]] = phi i32 [ [[Z]], [[ENTRY:%.*]] ], [ [[A:%.*]], [[LOOP]] ]
; ALL-NEXT: [[A]] = add i32 [[P]], 1
; ALL-NEXT: [[T:%.*]] = trunc i32 [[A]] to i16
; ALL-NEXT: [[COND:%.*]] = icmp ugt i16 [[N:%.*]], [[T]]
; ALL-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
; ALL: exit:
; ALL-NEXT: ret i16 [[T]]
;
entry:
%z = zext i16 %x to i32
br label %loop

loop:
%p = phi i32 [ %z, %entry ], [ %a, %loop ]
%a = add i32 %p, 1
%t = trunc i32 %a to i16
%cond = icmp ult i16 %t, %n
br i1 %cond, label %loop, label %exit

exit:
ret i16 %t
}

define i32 @test99(i32 %x, i32 %y) {
; ALL-LABEL: @test99(
; ALL-NEXT: [[A:%.*]] = add i32 [[X:%.*]], [[Y:%.*]]
; ALL-NEXT: [[B:%.*]] = add i32 [[A]], 5
; ALL-NEXT: [[C:%.*]] = mul i32 [[A]], 3
; ALL-NEXT: [[D:%.*]] = or i32 [[B]], [[C]]
; ALL-NEXT: [[SEXT:%.*]] = shl i32 [[D]], 16
; ALL-NEXT: [[S:%.*]] = ashr exact i32 [[SEXT]], 16
; ALL-NEXT: ret i32 [[S]]
;
%tx = trunc i32 %x to i16
%ty = trunc i32 %y to i16
%a = add i16 %tx, %ty
%b = add i16 %a, 5
%c = mul i16 %a, 3
%d = or i16 %b, %c
%t = sext i16 %d to i32
ret i32 %t
}

define i32 @test100(i32 %x, i32 %y) {
; ALL-LABEL: @test100(
; ALL-NEXT: [[TX:%.*]] = trunc i32 [[X:%.*]] to i8
; ALL-NEXT: [[TY:%.*]] = trunc i32 [[Y:%.*]] to i8
; ALL-NEXT: [[A:%.*]] = add i8 [[TX]], [[TY]]
; ALL-NEXT: [[B:%.*]] = add i8 [[A]], 5
; ALL-NEXT: [[C:%.*]] = mul i8 [[A]], 3
; ALL-NEXT: [[D:%.*]] = or i8 [[B]], [[C]]
; ALL-NEXT: call void @use_i8(i8 [[A]])
; ALL-NEXT: [[T:%.*]] = sext i8 [[D]] to i32
; ALL-NEXT: ret i32 [[T]]
;
%tx = trunc i32 %x to i8
%ty = trunc i32 %y to i8
%a = add i8 %tx, %ty
%b = add i8 %a, 5
%c = mul i8 %a, 3
%d = or i8 %b, %c
call void @use_i8(i8 %a)
%t = sext i8 %d to i32
ret i32 %t
}

; expected not to extend operations to i32 due to a loop in use chains
define i32 @test101(i32 %x, i8 %n) {
; ALL-LABEL: @test101(
; ALL-NEXT: entry:
; ALL-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; ALL-NEXT: br label [[LOOP:%.*]]
; ALL: loop:
; ALL-NEXT: [[P:%.*]] = phi i8 [ [[T]], [[ENTRY:%.*]] ], [ [[A:%.*]], [[LOOP]] ]
; ALL-NEXT: [[A]] = add i8 [[P]], 1
; ALL-NEXT: [[COND:%.*]] = icmp ult i8 [[A]], [[N:%.*]]
; ALL-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
; ALL: exit:
; ALL-NEXT: [[S:%.*]] = sext i8 [[A]] to i32
; ALL-NEXT: ret i32 [[S]]
;
entry:
%t = trunc i32 %x to i8
br label %loop

loop:
%p = phi i8 [ %t, %entry ], [ %a, %loop ]
%a = add i8 %p, 1
%cond = icmp ult i8 %a, %n
br i1 %cond, label %loop, label %exit

exit:
%s = sext i8 %a to i32
ret i32 %s
}
10 changes: 4 additions & 6 deletions llvm/test/Transforms/InstCombine/catchswitch-phi.ll
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,17 @@ define void @test1() personality ptr @__gxx_wasm_personality_v0 {
; CHECK-NEXT: [[CALL:%.*]] = invoke i32 @baz()
; CHECK-NEXT: to label [[INVOKE_CONT1:%.*]] unwind label [[CATCH_DISPATCH:%.*]]
; CHECK: invoke.cont1:
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i32 [[CALL]], 0
; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
; CHECK-NEXT: [[TOBOOL_INIT:%.*]] = icmp ne i32 [[CALL]], 0
; CHECK-NEXT: br i1 [[TOBOOL_INIT]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
; CHECK: if.then:
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: [[AP_0:%.*]] = phi i8 [ 1, [[IF_THEN]] ], [ 0, [[INVOKE_CONT1]] ]
; CHECK-NEXT: invoke void @foo()
; CHECK-NEXT: to label [[INVOKE_CONT2:%.*]] unwind label [[CATCH_DISPATCH]]
; CHECK: invoke.cont2:
; CHECK-NEXT: br label [[TRY_CONT:%.*]]
; CHECK: catch.dispatch:
; CHECK-NEXT: [[AP_1:%.*]] = phi i8 [ [[AP_0]], [[IF_END]] ], [ 0, [[INVOKE_CONT]] ]
; CHECK-NEXT: [[AP_1:%.*]] = phi i1 [ [[TOBOOL_INIT]], [[IF_END]] ], [ false, [[INVOKE_CONT]] ]
; CHECK-NEXT: [[TMP0:%.*]] = catchswitch within none [label %catch.start] unwind label [[CATCH_DISPATCH1]]
; CHECK: catch.start:
; CHECK-NEXT: [[TMP1:%.*]] = catchpad within [[TMP0]] [ptr null]
Expand All @@ -116,11 +115,10 @@ define void @test1() personality ptr @__gxx_wasm_personality_v0 {
; CHECK-NEXT: invoke void @llvm.wasm.rethrow() #[[ATTR0:[0-9]+]] [ "funclet"(token [[TMP1]]) ]
; CHECK-NEXT: to label [[UNREACHABLE:%.*]] unwind label [[CATCH_DISPATCH1]]
; CHECK: catch.dispatch1:
; CHECK-NEXT: [[AP_2:%.*]] = phi i8 [ [[AP_1]], [[CATCH_DISPATCH]] ], [ [[AP_1]], [[RETHROW]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: [[TOBOOL1:%.*]] = phi i1 [ [[AP_1]], [[CATCH_DISPATCH]] ], [ [[AP_1]], [[RETHROW]] ], [ false, [[ENTRY:%.*]] ]
; CHECK-NEXT: [[TMP2:%.*]] = catchswitch within none [label %catch.start1] unwind to caller
; CHECK: catch.start1:
; CHECK-NEXT: [[TMP3:%.*]] = catchpad within [[TMP2]] [ptr null]
; CHECK-NEXT: [[TOBOOL1:%.*]] = trunc i8 [[AP_2]] to i1
; CHECK-NEXT: br i1 [[TOBOOL1]], label [[IF_THEN1:%.*]], label [[IF_END1:%.*]]
; CHECK: if.then1:
; CHECK-NEXT: br label [[IF_END1]]
Expand Down
7 changes: 3 additions & 4 deletions llvm/test/Transforms/InstCombine/icmp-mul-zext.ll
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ define void @PR33765(i8 %beth) {
; CHECK-LABEL: @PR33765(
; CHECK-NEXT: br i1 false, label [[IF_THEN9:%.*]], label [[IF_THEN9]]
; CHECK: if.then9:
; CHECK-NEXT: [[CONV:%.*]] = zext i8 [[BETH:%.*]] to i32
; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[CONV]], [[CONV]]
; CHECK-NEXT: [[CONV:%.*]] = zext i8 [[BETH:%.*]] to i16
; CHECK-NEXT: [[MUL:%.*]] = mul nuw i16 [[CONV]], [[CONV]]
; CHECK-NEXT: [[TINKY:%.*]] = load i16, ptr @glob, align 2
; CHECK-NEXT: [[TMP1:%.*]] = trunc nuw i32 [[MUL]] to i16
; CHECK-NEXT: [[CONV14:%.*]] = and i16 [[TINKY]], [[TMP1]]
; CHECK-NEXT: [[CONV14:%.*]] = and i16 [[MUL]], [[TINKY]]
; CHECK-NEXT: store i16 [[CONV14]], ptr @glob, align 2
; CHECK-NEXT: ret void
;
Expand Down
14 changes: 6 additions & 8 deletions llvm/test/Transforms/InstCombine/logical-select-inseltpoison.ll
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,12 @@ define <2 x i64> @fp_bitcast(<4 x i1> %cmp, <2 x double> %a, <2 x double> %b) {
define <4 x i32> @computesignbits_through_shuffles(<4 x float> %x, <4 x float> %y, <4 x float> %z) {
; CHECK-LABEL: @computesignbits_through_shuffles(
; CHECK-NEXT: [[CMP:%.*]] = fcmp ole <4 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
; CHECK-NEXT: [[S1:%.*]] = shufflevector <4 x i32> [[SEXT]], <4 x i32> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
; CHECK-NEXT: [[S2:%.*]] = shufflevector <4 x i32> [[SEXT]], <4 x i32> poison, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
; CHECK-NEXT: [[SHUF_OR1:%.*]] = or <4 x i32> [[S1]], [[S2]]
; CHECK-NEXT: [[S3:%.*]] = shufflevector <4 x i32> [[SHUF_OR1]], <4 x i32> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
; CHECK-NEXT: [[S4:%.*]] = shufflevector <4 x i32> [[SHUF_OR1]], <4 x i32> poison, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
; CHECK-NEXT: [[SHUF_OR2:%.*]] = or <4 x i32> [[S3]], [[S4]]
; CHECK-NEXT: [[TMP1:%.*]] = trunc nsw <4 x i32> [[SHUF_OR2]] to <4 x i1>
; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <4 x i1> [[CMP]], <4 x i1> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i1> [[CMP]], <4 x i1> poison, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
; CHECK-NEXT: [[TMP3:%.*]] = or <4 x i1> [[TMP4]], [[TMP2]]
; CHECK-NEXT: [[S3:%.*]] = shufflevector <4 x i1> [[TMP3]], <4 x i1> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
; CHECK-NEXT: [[S4:%.*]] = shufflevector <4 x i1> [[TMP3]], <4 x i1> poison, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
; CHECK-NEXT: [[TMP1:%.*]] = or <4 x i1> [[S3]], [[S4]]
; CHECK-NEXT: [[SEL_V:%.*]] = select <4 x i1> [[TMP1]], <4 x float> [[Z:%.*]], <4 x float> [[X]]
; CHECK-NEXT: [[SEL:%.*]] = bitcast <4 x float> [[SEL_V]] to <4 x i32>
; CHECK-NEXT: ret <4 x i32> [[SEL]]
Expand Down
14 changes: 6 additions & 8 deletions llvm/test/Transforms/InstCombine/logical-select.ll
Original file line number Diff line number Diff line change
Expand Up @@ -676,14 +676,12 @@ define <2 x i64> @fp_bitcast(<4 x i1> %cmp, <2 x double> %a, <2 x double> %b) {
define <4 x i32> @computesignbits_through_shuffles(<4 x float> %x, <4 x float> %y, <4 x float> %z) {
; CHECK-LABEL: @computesignbits_through_shuffles(
; CHECK-NEXT: [[CMP:%.*]] = fcmp ole <4 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
; CHECK-NEXT: [[S1:%.*]] = shufflevector <4 x i32> [[SEXT]], <4 x i32> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
; CHECK-NEXT: [[S2:%.*]] = shufflevector <4 x i32> [[SEXT]], <4 x i32> poison, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
; CHECK-NEXT: [[SHUF_OR1:%.*]] = or <4 x i32> [[S1]], [[S2]]
; CHECK-NEXT: [[S3:%.*]] = shufflevector <4 x i32> [[SHUF_OR1]], <4 x i32> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
; CHECK-NEXT: [[S4:%.*]] = shufflevector <4 x i32> [[SHUF_OR1]], <4 x i32> poison, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
; CHECK-NEXT: [[SHUF_OR2:%.*]] = or <4 x i32> [[S3]], [[S4]]
; CHECK-NEXT: [[TMP1:%.*]] = trunc nsw <4 x i32> [[SHUF_OR2]] to <4 x i1>
; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <4 x i1> [[CMP]], <4 x i1> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i1> [[CMP]], <4 x i1> poison, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
; CHECK-NEXT: [[TMP3:%.*]] = or <4 x i1> [[TMP4]], [[TMP2]]
; CHECK-NEXT: [[S3:%.*]] = shufflevector <4 x i1> [[TMP3]], <4 x i1> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
; CHECK-NEXT: [[S4:%.*]] = shufflevector <4 x i1> [[TMP3]], <4 x i1> poison, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
; CHECK-NEXT: [[TMP1:%.*]] = or <4 x i1> [[S3]], [[S4]]
; CHECK-NEXT: [[SEL_V:%.*]] = select <4 x i1> [[TMP1]], <4 x float> [[Z:%.*]], <4 x float> [[X]]
; CHECK-NEXT: [[SEL:%.*]] = bitcast <4 x float> [[SEL_V]] to <4 x i32>
; CHECK-NEXT: ret <4 x i32> [[SEL]]
Expand Down