; ModuleID = '1.c'
source_filename = "1.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: norecurse nounwind uwtable writeonly
define dso_local i32 @foo(i8* %a, i8* %b, i8* %c) {
entry:
%const1 = bitcast i32 -524288 to i32
%0 = ptrtoint i8* %a to i32
%1 = and i32 %0, %const1
%2 = inttoptr i32 %1 to i8*
%3 = getelementptr i8, i8* %2, i32 4
%4 = bitcast i8* %3 to i32*
%5 = load i32, i32* %4, align 4
%6= icmp eq i32 %5, 0
br i1 %6, label %B0, label %B1
B0:
%7 = ptrtoint i8* %a to i32
%8 = and i32 %7, %const1
%9 = inttoptr i32 %8 to i8*
%10 = getelementptr i8, i8* %9, i32 4
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11, align 4
ret i32 %12
B1:
ret i32 -1
}will generates:
foo: # @foo .cfi_startproc # %bb.0: # %entry movl %edi, %eax andl $-524288, %eax # imm = 0xFFF80000 cmpl $0, 4(%rax) je .LBB0_1 # %bb.2: # %B1 movl $-1, %eax retq .LBB0_1: # %B0 => movl $-524288, %eax # imm = 0xFFF80000 andl %eax, %edi movl 4(%rdi), %eax retq
The movl instruction pointed by an arrow is generated by the additional COPY
SDNode.
The patch is to revisit the bitcast instruction to get a valid SDValue for the
constant.