Skip to content

suboptimal code generation in pointer comparison (this also affects std::vector.push_back()) #11610

@llvmbot

Description

@llvmbot
Bugzilla Link 11238
Resolution FIXED
Resolved on Feb 25, 2012 13:19
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @nlewycky

Extended Description

Test Case:

; ModuleID = 'x.ll'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"

%t = type { i32, i32 }

define i32 @​main() nounwind readnone {
r1:
%x = alloca %t, align 8
%a = getelementptr %t* %x, i64 0, i32 0
%b = getelementptr %t* %x, i64 0, i32 1
%equal = icmp eq i32* %a, %b
%merge = select i1 %equal, i32 1, i32 2
ret i32 %merge
}

I think the issue should be obviously.
Have fun fixing it. This code occurs also on code generation of the C++ template std::vector:

#include
#include

using namespace std;

int main() {
vector v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
for(vector::iterator it = v.begin(); it < v.end(); it++) {
cout << *it << endl;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions