Changeset View
Changeset View
Standalone View
Standalone View
test/Transforms/InstCombine/icmp-div-constant.ll
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||||
; RUN: opt < %s -instcombine -S | FileCheck %s | ; RUN: opt < %s -instcombine -S | FileCheck %s | ||||
; PR30281 - https://llvm.org/bugs/show_bug.cgi?id=30281 | ; PR30281 - https://llvm.org/bugs/show_bug.cgi?id=30281 | ||||
; All of these tests contain foldable division-by-constant instructions, but we | ; All of these tests contain foldable division-by-constant instructions, but we | ||||
; can't assert that those folds have occurred before we process the later icmp. | ; can't assert that those folds have occurred before we process the later icmp. | ||||
define i32 @icmp_div(i16 %a, i16 %c) { | define i32 @icmp_div(i16 %a, i16 %c) { | ||||
; CHECK-LABEL: @icmp_div( | ; CHECK-LABEL: @icmp_div( | ||||
; CHECK-NEXT: entry: | ; CHECK-NEXT: entry: | ||||
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i16 %a, 0 | ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i16 %a, 0 | ||||
; CHECK-NEXT: br i1 [[TOBOOL]], label %then, label %exit | ; CHECK-NEXT: br i1 [[TOBOOL]], label %then, label %exit | ||||
; CHECK: then: | ; CHECK: then: | ||||
; CHECK-NEXT: [[NOT_CMP:%.*]] = icmp eq i16 %c, 0 | ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i16 %c, 0 | ||||
; CHECK-NEXT: [[PHITMP1:%.*]] = sext i1 [[NOT_CMP]] to i32 | ; CHECK-NEXT: [[PHITMP1:%.*]] = sext i1 [[TMP0]] to i32 | ||||
; CHECK-NEXT: br label %exit | ; CHECK-NEXT: br label %exit | ||||
; CHECK: exit: | ; CHECK: exit: | ||||
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ -1, %entry ], [ [[PHITMP1]], %then ] | ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ -1, %entry ], [ [[PHITMP1]], %then ] | ||||
; CHECK-NEXT: ret i32 [[PHI]] | ; CHECK-NEXT: ret i32 [[PHI]] | ||||
; | ; | ||||
entry: | entry: | ||||
%tobool = icmp eq i16 %a, 0 | %tobool = icmp eq i16 %a, 0 | ||||
br i1 %tobool, label %then, label %exit | br i1 %tobool, label %then, label %exit | ||||
Show All 38 Lines | |||||
} | } | ||||
define i32 @icmp_div3(i16 %a, i16 %c) { | define i32 @icmp_div3(i16 %a, i16 %c) { | ||||
; CHECK-LABEL: @icmp_div3( | ; CHECK-LABEL: @icmp_div3( | ||||
; CHECK-NEXT: entry: | ; CHECK-NEXT: entry: | ||||
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i16 %a, 0 | ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i16 %a, 0 | ||||
; CHECK-NEXT: br i1 [[TOBOOL]], label %then, label %exit | ; CHECK-NEXT: br i1 [[TOBOOL]], label %then, label %exit | ||||
; CHECK: then: | ; CHECK: then: | ||||
; CHECK-NEXT: [[NOT_CMP:%.*]] = icmp eq i16 %c, 0 | ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i16 %c, 0 | ||||
; CHECK-NEXT: [[PHITMP1:%.*]] = sext i1 [[NOT_CMP]] to i32 | ; CHECK-NEXT: [[PHITMP1:%.*]] = sext i1 [[TMP0]] to i32 | ||||
; CHECK-NEXT: br label %exit | ; CHECK-NEXT: br label %exit | ||||
; CHECK: exit: | ; CHECK: exit: | ||||
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ -1, %entry ], [ [[PHITMP1]], %then ] | ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ -1, %entry ], [ [[PHITMP1]], %then ] | ||||
; CHECK-NEXT: ret i32 [[PHI]] | ; CHECK-NEXT: ret i32 [[PHI]] | ||||
; | ; | ||||
entry: | entry: | ||||
%tobool = icmp eq i16 %a, 0 | %tobool = icmp eq i16 %a, 0 | ||||
br i1 %tobool, label %then, label %exit | br i1 %tobool, label %then, label %exit | ||||
Show All 13 Lines |