Skip to content

TypePromotion produces invalid IR #58843

Closed
llvm/llvm-project-release-prs
#210
@nikic

Description

@nikic
; RUN: opt -S -type-promotion < %s
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"

define i1 @test(i8 %arg) {
  %ext1 = zext i8 %arg to i64
  %trunc = trunc i64 %ext1 to i3
  %ext2 = zext i3 %trunc to i8
  %cmp = icmp ne i8 %ext2, 0
  ret i1 %cmp
}

Results in a verifier error:

Type too small for ZExt
  %ext2 = zext i64 %1 to i32
in function test
LLVM ERROR: Broken function found, compilation aborted!

The produced IR looks as follows:

define i1 @test(i8 %arg) {
  %ext1 = zext i8 %arg to i64
  %1 = and i64 %ext1, 7
  %ext2 = zext i64 %1 to i32
  %cmp = icmp ne i32 %ext2, 0
  ret i1 %cmp
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions