git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123832
91177308-0d34-0410-b5e6-
96231b3b80d8
if (const SCEVSignExtendExpr *SS = dyn_cast<SCEVSignExtendExpr>(Op))
return getSignExtendExpr(SS->getOperand(), Ty);
+ // sext(zext(x)) --> zext(x)
+ if (const SCEVZeroExtendExpr *SZ = dyn_cast<SCEVZeroExtendExpr>(Op))
+ return getZeroExtendExpr(SZ->getOperand(), Ty);
+
// Before doing any expensive analysis, check to see if we've already
// computed a SCEV for this Op and Ty.
FoldingSetNodeID ID;
--- /dev/null
+; RUN: opt -analyze -scalar-evolution %s -S | FileCheck %s
+
+define i16 @test(i8 %x) {
+ %A = zext i8 %x to i12
+ %B = sext i12 %A to i16
+; CHECK: zext i8 %x to i16
+ ret i16 %B
+}