Skip to content

miscompiled extractelement instruction #11119

@llvmbot

Description

@llvmbot
Bugzilla Link 10747
Resolution FIXED
Resolved on Dec 26, 2011 16:49
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @efriedma-quic

Extended Description

Testcase:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

define i32 @​main() {
BB0:
%0 = alloca <2 x i64>, align 16
%1 = getelementptr <2 x i64>* %0, i32 0, i32 1
store i64 6, i64* %1
%2 = getelementptr inbounds <2 x i64>* %0, i32 0, i32 0
store i64 1, i64* %2
%3 = ptrtoint <2 x i64>* %0 to i64
%4 = inttoptr i64 %3 to <2 x i64>*
%5 = load <2 x i64>* %4, align 1
store i64 4, i64* %1
store i64 3, i64* %2
%6 = extractelement <2 x i64> %5, i32 1
%7 = trunc i64 %6 to i32
ret i32 %7
}

Compile using:
llvm-as -o temp.bc bug.ll && llc -march=x86-64 -o temp.s temp.bc && gcc temp.s && ./a.out

This should exit with exit code 6, but it exits with code 4.

This is with LLVM HEAD on x86-64.

This seems to be caused by revision 131183, i.e.:

Author: Nadav Rotem nadav.rotem@intel.com
Date: Wed May 11 14:40:50 2011 +0000

Fixes a bug in the DAGCombiner.  LoadSDNodes have two values (data, chain).
If there is a store after the load node, then there is a chain, which means
that there is another user. Thus, asking hasOneUser would fail. Instead we
ask hasNUsesOfValue on the 'data' value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions