Skip to content

TypePromotion produces invalid IR (take 2) #59554

Closed
llvm/llvm-project-release-prs
#222
@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) {
  %arg.ext = zext i8 %arg to i64
  %trunc = trunc i64 %arg.ext to i3
  %switch.tableidx = xor i3 %trunc, 1
  %switch.maskindex = zext i3 %trunc to i8
  %switch.lobit = icmp ne i8 %switch.maskindex, 0
  ret i1 %switch.lobit
}

Results in a verifier error:

Both operands to a binary operator are not of the same type!
  %switch.tableidx = xor i64 %1, i32 1
in function test

The produced IR looks as follows:

define i1 @test(i8 %arg) {
  %arg.ext = zext i8 %arg to i64
  %1 = and i64 %arg.ext, 7
  %switch.tableidx = xor i64 %1, i32 1
  %2 = trunc i64 %1 to i32
  %switch.lobit = icmp ne i32 %2, 0
  ret i1 %switch.lobit
}

The symptoms here are similar to #58843, but the fix for that one did not fix this case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions