[llvm] r302446 - ConstantFold: Fold getelementptr (i32, i32* null, i64 undef) to null.
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Mon May 8 10:37:30 PDT 2017
Author: dannyb
Date: Mon May 8 12:37:29 2017
New Revision: 302446
URL: http://llvm.org/viewvc/llvm-project?rev=302446&view=rev
Log:
ConstantFold: Fold getelementptr (i32, i32* null, i64 undef) to null.
Transforms/IndVarSimplify/2011-10-27-lftrnull will fail if this regresses.
Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll has been changed to still test what it was
trying to test.
Modified:
llvm/trunk/lib/IR/ConstantFold.cpp
llvm/trunk/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll
llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll
Modified: llvm/trunk/lib/IR/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ConstantFold.cpp?rev=302446&r1=302445&r2=302446&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ConstantFold.cpp (original)
+++ llvm/trunk/lib/IR/ConstantFold.cpp Mon May 8 12:37:29 2017
@@ -2054,7 +2054,8 @@ Constant *llvm::ConstantFoldGetElementPt
if (C->isNullValue()) {
bool isNull = true;
for (unsigned i = 0, e = Idxs.size(); i != e; ++i)
- if (!cast<Constant>(Idxs[i])->isNullValue()) {
+ if (!isa<UndefValue>(Idxs[i]) &&
+ !cast<Constant>(Idxs[i])->isNullValue()) {
isNull = false;
break;
}
Modified: llvm/trunk/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll?rev=302446&r1=302445&r2=302446&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll (original)
+++ llvm/trunk/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll Mon May 8 12:37:29 2017
@@ -5,8 +5,7 @@
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"
target triple = "x86_64-apple-macosx10.7.0"
-
-define i1 @rb_intern() nounwind ssp {
+define i1 @rb_intern(i8 *%foo) nounwind ssp {
; CHECK-LABEL: @rb_intern(
bb:
@@ -19,7 +18,7 @@ bb1:
br i1 undef, label %bb3, label %bb15
; CHECK: bb1:
-; CHECK: [[TMP:%.*]] = phi i8* [ getelementptr (i8, i8* null, i64 undef), %bb10 ], [ null, %bb ]
+; CHECK: [[TMP:%.*]] = phi i8* [ %tmp14, %bb10 ], [ null, %bb ]
; CHECK: bb1.bb15_crit_edge:
; CHECK: %tmp17.pre = load i8, i8* [[TMP]], align 1
@@ -41,7 +40,7 @@ bb10:
%tmp11 = load i8*, i8** %tmp, align 8
%tmp12 = load i8, i8* %tmp11, align 1
%tmp13 = zext i8 %tmp12 to i64
- %tmp14 = getelementptr inbounds i8, i8* null, i64 undef
+ %tmp14 = getelementptr inbounds i8, i8* %foo, i64 undef
store i8* %tmp14, i8** %tmp, align 8
br label %bb1
Modified: llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll?rev=302446&r1=302445&r2=302446&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll Mon May 8 12:37:29 2017
@@ -6,7 +6,7 @@ target triple = "thumbv7-apple-darwin"
; CHECK-LABEL: @test(
; CHECK: if.end.i126:
-; CHECK: %exitcond = icmp ne i8* %incdec.ptr.i, getelementptr (i8, i8* null, i32 undef)
+; CHECK: %exitcond = icmp ne i8* %incdec.ptr.i, null
define void @test() nounwind {
entry:
br label %while.cond
More information about the llvm-commits
mailing list