diff options
author | Davide Italiano <davide@freebsd.org> | 2017-07-27 22:20:44 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2017-07-27 22:20:44 +0000 |
commit | 1a26f24f352798d37bbb66d532224e0c858f6080 (patch) | |
tree | aac6848983c63dba78ab47ba2a2973b2f351b5fc /llvm/test/Transforms | |
parent | 06ad7ed70c7cbe4295ec47c10c9f9e9a802b2948 (diff) | |
download | bcm5719-llvm-1a26f24f352798d37bbb66d532224e0c858f6080.tar.gz bcm5719-llvm-1a26f24f352798d37bbb66d532224e0c858f6080.zip |
[ConstantFolder] Don't try to fold gep when the idx is a vector.
The code in ConstantFoldGetElementPtr() assumes integers, and
therefore it crashes trying to get the integer bidwith of a vector
type (in this case <4 x i32>. I just changed the code to prevent
the folding in case of vectors and I didn't bother to generalize
as this doesn't seem to me something that really happens in
practice, but I'm willing to change the patch if you think
it's worth it.
This is hard to trigger from -instsimplify or -instcombine
only as the second instruction is dead, so the test uses loop-unroll.
Differential Revision: https://reviews.llvm.org/D35956
llvm-svn: 309330
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r-- | llvm/test/Transforms/InstSimplify/pr33957.ll | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/pr33957.ll b/llvm/test/Transforms/InstSimplify/pr33957.ll new file mode 100644 index 00000000000..256bb89e786 --- /dev/null +++ b/llvm/test/Transforms/InstSimplify/pr33957.ll @@ -0,0 +1,29 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -loop-unroll -S %s | FileCheck %s + +%struct.bar = type { i32 } + +@global = external constant [78 x %struct.bar], align 4 + +define void @patatino(i32 %x) { +; CHECK-LABEL: @patatino( +; CHECK-NEXT: bb: +; CHECK-NEXT: br i1 true, label [[BB1_PREHEADER:%.*]], label [[BB3:%.*]] +; CHECK: bb1.preheader: +; CHECK-NEXT: br label [[BB1:%.*]] +; CHECK: bb1: +; CHECK-NEXT: br label [[BB3]] +; CHECK: bb3: +; CHECK-NEXT: ret void +; +bb: + br i1 true, label %bb1, label %bb3 + +bb1: + %tmp = getelementptr inbounds [78 x %struct.bar], [78 x %struct.bar]* @global, i32 0, <4 x i32> undef + %tmp2 = getelementptr inbounds %struct.bar, <4 x %struct.bar*> %tmp, i32 1 + br i1 true, label %bb3, label %bb1 + +bb3: + ret void +} |