Files
Davide Italiano b7a48d833a [InstCombine] Fold branches with irrelevant conditions to a constant.
InstCombine folds instructions with irrelevant conditions to undef.
This, as Nuno confirmed is a bug.
(see https://bugs.llvm.org/show_bug.cgi?id=33409#c1 )

Given the original motivation for the change is that of removing an
USE, we now fold to false instead (which reaches the same goal
without undesired side effects).

Fixes PR33409.

Differential Revision:  https://reviews.llvm.org/D36975

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311540 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-23 09:14:37 +00:00

33 lines
1.1 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S %s -instcombine | FileCheck %s
@glob = external global i16
define void @patatino(i8 %beth) {
; CHECK-LABEL: @patatino(
; CHECK-NEXT: [[CONV:%.*]] = zext i8 [[BETH:%.*]] to i32
; CHECK-NEXT: br i1 false, label [[IF_THEN9:%.*]], label [[IF_THEN9]]
; CHECK: if.then9:
; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[CONV]], [[CONV]]
; CHECK-NEXT: [[TINKY:%.*]] = load i16, i16* @glob, align 2
; CHECK-NEXT: [[CONV131:%.*]] = zext i16 [[TINKY]] to i32
; CHECK-NEXT: [[AND:%.*]] = and i32 [[MUL]], [[CONV131]]
; CHECK-NEXT: [[CONV14:%.*]] = trunc i32 [[AND]] to i16
; CHECK-NEXT: store i16 [[CONV14]], i16* @glob, align 2
; CHECK-NEXT: ret void
;
%conv = zext i8 %beth to i32
%mul = mul nuw nsw i32 %conv, %conv
%conv3 = and i32 %mul, 255
%tobool8 = icmp ne i32 %mul, %conv3
br i1 %tobool8, label %if.then9, label %if.then9
if.then9:
%tinky = load i16, i16* @glob
%conv13 = sext i16 %tinky to i32
%and = and i32 %mul, %conv13
%conv14 = trunc i32 %and to i16
store i16 %conv14, i16* @glob
ret void
}